Repository navigation
Description
Problem
E2E tests under hack/e2e-apps/*.bats perform resource cleanup inline at the
end of each @test body (e.g. kubectl delete vminstance ... after the wait
assertions). When an earlier kubectl wait or until step fails, the test
exits before reaching the delete lines, so resources leak into the cluster
and can pollute subsequent retries or unrelated app tests sharing the
tenant-test namespace.
Surfaced in #2555 (comment)
on hack/e2e-apps/vminstance.bats, but the same pattern exists in most
e2e-apps/*.bats files.
Proposal
Move resource deletion into a framework-level teardown() (bats hook that
always runs, even on test failure). Track created resource names in a
shell-array or temp file in setup()/test body, and have teardown()
iterate them with kubectl delete --ignore-not-found --timeout=....
Keep test bodies focused on create + assert; cleanup becomes guaranteed.
Scope
- Audit all files under
hack/e2e-apps/for inlinekubectl deleteat
end-of-test. - Introduce a shared cleanup helper (likely in
hack/e2e-apps/as a sourced
.sh) that test files can register resources with. - Migrate each app's
.batsfile individually so churn is reviewable.
Out of scope
- Changing the actual create/assert logic of any test.
- Reworking
cozytest.shrunner semantics.
Acceptance criteria
- A failing
kubectl waitin anye2e-apps/*.batstest still removes the
resources it created before the next test runs. - No inline post-assertion
kubectl deletecalls remain in test bodies.
Activity
myasnikovdaniil commentedon Aug 14, 2026
Suite doesn't have that shape anymore. App tests moved to chainsaw in #2826, and
hack/e2e-apps/is down to two files where neither usesteardown(): cozytest.sh never invokessetup()/teardown(), so cleanup sits incozy_cleanup()(monitoring-oidc-system.bats:46,monitoring-oidc-customconfig.bats:37) which runs at suite exit and on the first failing test.Those two files also have no invocation site in any Makefile, hack script or workflow. So there is no per-test cleanup left to move and no lane to move it in, closing. #3778 is the gate for the no-runner class, and #3453 decides whether these two get deleted or given a lane.