Skip to content

feat: prevent premature namespace teardown and redundant re-deployments on worker restarts #47

Merged
jrichter1 merged 4 commits intoredhat-developer:mainfrom
subhashkhileri:teardown-using-custom-reporter
Mar 6, 2026
Merged

feat: prevent premature namespace teardown and redundant re-deployments on worker restarts #47
jrichter1 merged 4 commits intoredhat-developer:mainfrom
subhashkhileri:teardown-using-custom-reporter

Conversation

@subhashkhileri
Copy link
Member

@subhashkhileri subhashkhileri commented Mar 6, 2026

https://issues.redhat.com/browse/RHIDP-12518

What

Moves namespace cleanup from the worker fixture's finally block to a custom Playwright reporter, and adds built-in protection against redundant deploy() calls when workers restart after test
failures.

Why

When a test fails, Playwright kills the worker and creates a new one for remaining tests. This caused:

  • The fixture's finally to delete the namespace too early — breaking remaining tests
  • beforeAll to re-run deploy() from scratch — wasting several minutes per failure

How

  • deploy() now skips automatically if it already succeeded in the current test run (uses file-based flags via proper-lockfile)
  • test.runOnce(key, fn) added for wrapping expensive pre-deploy setup (external services, scripts) that also shouldn't repeat
  • TeardownReporter handles namespace deletion in onEnd() — runs in the main process, survives worker restarts, deletes after all tests complete
  • registerTeardownNamespace() exported from ./teardown for consumers using custom namespaces

Consumer impact

No changes needed for the default configure() + deploy() pattern — works out of the box. For pre-deploy setup, wrap in test.runOnce():

// Simple — no changes needed
test.beforeAll(async ({ rhdh }) => {
await rhdh.configure({ auth: "keycloak" });
await rhdh.deploy();
});

// Pre-deploy setup — wrap in test.runOnce
test.beforeAll(async ({ rhdh }) => {
await test.runOnce("tech-radar-setup", async () => {
await rhdh.configure({ auth: "keycloak" });
await $bash deploy-service.sh ${rhdh.deploymentConfig.namespace};
await rhdh.deploy();
});
});

@subhashkhileri subhashkhileri changed the title test.runOnce implementation test.runOnce implementation and spec level cleanup. Mar 6, 2026
@subhashkhileri subhashkhileri requested a review from jrichter1 March 6, 2026 07:29
@jrichter1 jrichter1 merged commit 090747c into redhat-developer:main Mar 6, 2026
1 check passed
@subhashkhileri subhashkhileri changed the title test.runOnce implementation and spec level cleanup. feat: prevent premature namespace teardown and redundant re-deployments on worker restarts Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants