Skip to content

Commit 44feb45

Browse files
test(e2e): fail the platform verify when it has no baseline to compare
`comm -13 "$dir/unbound-pv.txt" ... || true` turns a missing baseline file into an empty diff, and an empty diff reads as "nothing newly broken". A verify phase run without its seed phase therefore reported the platform healthy having compared nothing at all — the most expensive kind of green. The sibling suites already guard theirs: verify/vm and verify/redis fail fast with `[ -f "$before" ] || { ...; exit 1; }`. Assert both baselines exist before either diff, and drop the `|| true` that was swallowing the missing-file error along with everything else. The two `kubectl get` calls had the same shape of hole one layer down: a pipeline takes the exit status of its LAST command, so `kubectl get pv | awk ... > file` left an empty list and a passing diff whenever the kubectl call failed. Write the listing to a file first, where `set -e` sees the failure. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent f11bd3b commit 44feb45

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

‎hack/e2e-chainsaw-upgrade/verify/platform/chainsaw-test.yaml‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,27 @@ spec:
3838
apiservices/v1alpha1.apps.cozystack.io \
3939
apiservices/v1alpha1.core.cozystack.io --timeout=3m
4040
41+
# Both diffs below compare against a file the seed phase wrote. A
42+
# missing file makes `comm -13` print nothing, which reads as "nothing
43+
# newly broken" — so a verify run without its seed phase would report
44+
# the platform healthy having compared nothing at all. Fail fast
45+
# instead, the way verify/vm and verify/redis already do for theirs.
4146
dir=/workspace/_out/upgrade-baseline
47+
for f in unbound-pv.txt crashloop.txt; do
48+
[ -f "$dir/$f" ] || {
49+
echo "FAIL: missing baseline $dir/$f (seed phase did not run?)" >&2
50+
exit 1
51+
}
52+
done
53+
4254
echo "=== gate: no new unbound PersistentVolumes vs baseline ==="
43-
kubectl get pv --no-headers 2>/dev/null | awk '$5 != "Bound" {print $1}' | sort > /tmp/post-unbound-pv.txt
44-
new_pv=$(comm -13 "$dir/unbound-pv.txt" /tmp/post-unbound-pv.txt || true)
55+
# Written through a file rather than piped straight into awk: a pipeline
56+
# takes the exit status of its LAST command, so a failed `kubectl get`
57+
# would leave an empty list and pass the diff. Under `set -e` the
58+
# redirect below fails the step instead.
59+
kubectl get pv --no-headers > /tmp/pv-raw.txt
60+
awk '$5 != "Bound" {print $1}' /tmp/pv-raw.txt | sort > /tmp/post-unbound-pv.txt
61+
new_pv=$(comm -13 "$dir/unbound-pv.txt" /tmp/post-unbound-pv.txt)
4562
if [ -n "$new_pv" ]; then
4663
echo "FAIL: PersistentVolumes newly unbound after upgrade:" >&2
4764
echo "$new_pv" >&2
@@ -51,8 +68,9 @@ spec:
5168
echo "no new unbound PVs"
5269
5370
echo "=== warning-only: new CrashLoopBackOff pods vs baseline ==="
54-
kubectl get pods -A --no-headers 2>/dev/null | awk '/CrashLoopBackOff/ {print $1"/"$2}' | sort > /tmp/post-crashloop.txt
55-
new_cl=$(comm -13 "$dir/crashloop.txt" /tmp/post-crashloop.txt || true)
71+
kubectl get pods -A --no-headers > /tmp/pods-raw.txt
72+
awk '/CrashLoopBackOff/ {print $1"/"$2}' /tmp/pods-raw.txt | sort > /tmp/post-crashloop.txt
73+
new_cl=$(comm -13 "$dir/crashloop.txt" /tmp/post-crashloop.txt)
5674
if [ -n "$new_cl" ]; then
5775
echo "::warning::pods in CrashLoopBackOff after upgrade not present in baseline (name churn expected; triage only):" >&2
5876
echo "$new_cl" >&2

0 commit comments

Comments
 (0)