Skip to content

cozytest.sh implements no skip: a skipping test hard-fails at exit 127 #3827

Description

hack/cozytest.sh runs every test body in a subshell under set -eu -x and defines no skip command; the only match for the word in the file is the unrelated skip_next variable. A test that calls skip therefore hits a missing command, exits 127, and set -e fails the test. The thing written to tolerate a condition is what breaks on it.

Three call sites today:

  • hack/e2e-install-cozystack.bats:593, the file CI actually runs. The call guards a ValidatingAdmissionPolicy assertion for clusters below Kubernetes 1.30, so the branch is out of reach in practice, since the platform requires a much newer management cluster. Unreachable is not the same as harmless: the guard is dead weight that would fail closed the day it fired.
  • hack/e2e-apps/monitoring-oidc-system.bats:132 and hack/e2e-apps/monitoring-oidc-customconfig.bats:112, which nothing has executed since the suite moved to Chainsaw. Latent rather than live.

In a cozytest suite the working form is echo "…" >&2; return 0, which reads the same and also behaves under real bats.

There is a second defect in the same spot, at the prose layer. The comment above hack/e2e-install-cozystack.bats:592 reads: "Detect by attempting to fetch the policy by name; if the API is present, the resource will be retrievable, otherwise kubectl exits non-zero on an unknown resource type." The code below it fetches nothing by name and tests output instead (api-resources … | grep -qw), which is the correct shape. But the comment teaches precisely the exit-code model that caused #3516, where kubectl api-resources on an absent API group exits 0 and the guard never fires. A comment that explains the right code with the wrong mechanism is worse than no comment: the next person copies the reasoning, not the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/testingIssues or PRs related to testing (e2e, bats, unit tests)kind/bugCategorizes issue or PR as related to a bugtriage/needs-triageIndicates an issue needs triage by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions