Skip to content

Commit 0a3546e

Browse files
committed
test(e2e): tell a missing object from a failed read
The assertion that the no-delete guardrail can be bypassed decides on `kubectl get`'s exit status alone. That status is 1 for a NotFound and 1 for a connection, auth or discovery failure, so an api-server the test cannot reach reads as proof the configmap is gone. `--ignore-not-found` collapses the NotFound alone into success with empty output, which leaves the status free to mean a failed read. Read the two separately: a non-zero status fails the test naming the read that did not answer, non-empty output fails it naming the object that must not be there. Capture stdout only. kubectl writes deprecation and throttling notices to stderr on a call that succeeded, and folding those into the value under test would report an object that is not there. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent cd448fd commit 0a3546e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎hack/e2e-install-cozystack.bats‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,16 @@ EOF
532532
kubectl delete configmap cozystack-version -n cozy-system
533533
# A bare `! kubectl get` is vacuous under cozytest's `set -e` (errexit is
534534
# suppressed for any command whose status is inverted with `!`), so a
535-
# delete that silently failed would not fail the test; assert the absence
536-
# via `if kubectl get; then ...; false`.
537-
if kubectl get configmap cozystack-version -n cozy-system 2>/dev/null; then echo "FAIL: cozystack-version configmap must be gone after delete with the no-delete label removed"; false; fi
535+
# delete that silently failed would not fail the test. Nor may the absence
536+
# rest on the exit status alone: `kubectl get` exits 1 for a NotFound and 1
537+
# for a connection, auth or discovery failure, so an api-server the test
538+
# cannot reach would read as proof the delete worked. `--ignore-not-found`
539+
# collapses the NotFound alone into success with empty output, leaving the
540+
# status free to mean a failed read.
541+
if ! still_there=$(kubectl get configmap cozystack-version -n cozy-system --ignore-not-found -o name); then
542+
echo "FAIL: reading the cozystack-version configmap did not answer"; false
543+
fi
544+
if [ -n "$still_there" ]; then echo "FAIL: cozystack-version configmap must be gone after delete with the no-delete label removed"; false; fi
538545
# Reconstruct: declarative apply matches the chart template at
539546
# packages/core/platform/templates/cozystack-version.yaml — same label set
540547
# AND the helm.sh/resource-policy: keep annotation that pins the ConfigMap

0 commit comments

Comments
 (0)