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 inline kubectl delete at
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
.bats file individually so churn is reviewable.
Out of scope
- Changing the actual create/assert logic of any test.
- Reworking
cozytest.sh runner semantics.
Acceptance criteria
- A failing
kubectl wait in any e2e-apps/*.bats test still removes the
resources it created before the next test runs.
- No inline post-assertion
kubectl delete calls remain in test bodies.
Problem
E2E tests under
hack/e2e-apps/*.batsperform resource cleanup inline at theend of each
@testbody (e.g.kubectl delete vminstance ...after the waitassertions). When an earlier
kubectl waitoruntilstep fails, the testexits before reaching the delete lines, so resources leak into the cluster
and can pollute subsequent retries or unrelated app tests sharing the
tenant-testnamespace.Surfaced in #2555 (comment)
on
hack/e2e-apps/vminstance.bats, but the same pattern exists in moste2e-apps/*.batsfiles.Proposal
Move resource deletion into a framework-level
teardown()(bats hook thatalways runs, even on test failure). Track created resource names in a
shell-array or temp file in
setup()/test body, and haveteardown()iterate them with
kubectl delete --ignore-not-found --timeout=....Keep test bodies focused on create + assert; cleanup becomes guaranteed.
Scope
hack/e2e-apps/for inlinekubectl deleteatend-of-test.
hack/e2e-apps/as a sourced.sh) that test files can register resources with..batsfile individually so churn is reviewable.Out of scope
cozytest.shrunner semantics.Acceptance criteria
kubectl waitin anye2e-apps/*.batstest still removes theresources it created before the next test runs.
kubectl deletecalls remain in test bodies.