Skip to content

Commit

Permalink
Set a namespace default nodeSelector for nodeSelector kuttl test
Browse files Browse the repository at this point in the history
  • Loading branch information
olliewalsh committed Nov 28, 2024
1 parent 4c23add commit 1e3929e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc annotate namespace $NAMESPACE openshift.io/node-selector="beta.kubernetes.io/os=linux"
- script: |
oc kustomize ../../../../config/samples/nodeselectors/global | oc apply -n $NAMESPACE -f -
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: TestAssert
commands:
- script: |
echo "Checking all pods have expected nodeselector"
EXPECTED_NODE_SELECTOR="node-role.kubernetes.io/worker:"
EXPECTED_NODE_SELECTOR="beta.kubernetes.io/os:linux node-role.kubernetes.io/worker:"
BAD_OR_MISSING_NODE_SELECTOR=$(oc get pods -n $NAMESPACE -l service!=dnsmasq -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d')
BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l)
if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ apiVersion: kuttl.dev/v1beta1
kind: TestStep
timeout: 60
commands:
- script: |
oc patch dnsmasq -n $NAMESPACE dnsmasq --type='json' -p='[{
"op": "replace",
"path": "/spec/nodeSelector",
"value": {"kubernetes.io/os":"linux"}
}]'
- script: |
oc patch openstackcontrolplane -n $NAMESPACE openstack --type='json' -p='[{
"op": "replace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: TestAssert
commands:
- script: |
echo "Checking all running pods have new nodeselector"
EXPECTED_NODE_SELECTOR="kubernetes.io/os:linux"
EXPECTED_NODE_SELECTOR="beta.kubernetes.io/os:linux kubernetes.io/os:linux"
BAD_OR_MISSING_NODE_SELECTOR=$(oc get pods -n $NAMESPACE -l service!=dnsmasq --field-selector=status.phase=Running -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d')
BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l)
if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then
Expand Down
1 change: 1 addition & 0 deletions tests/kuttl/tests/ctlplane-nodeselectors/05-cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ delete:
name: openstack
commands:
- script: |
oc annotate namespace $NAMESPACE openshift.io/node-selector-
oc delete --ignore-not-found=true -n $NAMESPACE pvc \
srv-swift-storage-0
oc delete secret --ignore-not-found=true combined-ca-bundle -n $NAMESPACE
Expand Down

0 comments on commit 1e3929e

Please sign in to comment.