Skip to content

Commit

Permalink
Force conformance tests to fail properly (nginxinc#1786)
Browse files Browse the repository at this point in the history
Problem: If the conformance test Pod runner failed, the `make` process would still pass. This is because the failure code would not propagate to outside of the Pod.

Solution: After the Pod runs, check the exit code and fail it it's non-zero. Used a bash script for this because running the `kubectl get pod` command in the Makefile would not return an Errored Pod for some reason. Only worked in bash.
  • Loading branch information
sjberman authored Mar 28, 2024
1 parent 72381e2 commit 03e24fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions conformance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ run-conformance-tests: ## Run conformance tests
--restart=Never -- sh -c "go test -v . -tags conformance,experimental -args --gateway-class=$(GATEWAY_CLASS) \
--supported-features=$(SUPPORTED_FEATURES) --version=$(VERSION) \
--report-output=output.txt; cat output.txt" | tee output.txt
bash scripts/check-pod-exit-code.sh
sed -e '1,/CONFORMANCE PROFILE/d' output.txt > conformance-profile.yaml
rm output.txt
[ $(shell cat conformance-profile.yaml | yq '.profiles[0].core.result') != "failure" ] \
Expand Down
6 changes: 6 additions & 0 deletions conformance/scripts/check-pod-exit-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

CODE=$(kubectl get pod conformance -o jsonpath='{.status.containerStatuses[].state.terminated.exitCode}')
if [ $CODE -ne 0 ]; then
exit 2
fi

0 comments on commit 03e24fe

Please sign in to comment.