Skip to content

fix(tests): Add keycloak warmup step for CLI tests - #7555

Closed
maverbiest wants to merge 1 commit into
mainfrom
cli-test-keycloack-warmup
Closed

maverbiest wants to merge 1 commit into
mainfrom
cli-test-keycloack-warmup

Conversation

@maverbiest

@maverbiest maverbiest commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

I noticed integration tests were sometimes failing the first time they were run for a PR because of a failure to load resources or stylesheets, e.g.:

Rerunning the job fixed it each time, it turns out it's due to keycloak gzipping and caching resources when they're requested for the first time. When several requests for theme files arrive at once on a freshly started pod, some of them fail with a 404.

This PR adds a warmup step to the CLI integration tests that loads keycloak resources so they are gzipped and cached in advance of the actual tests running.

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by appropriate, automated tests.
  • Any manual testing that has been done is documented (i.e. what exactly was tested?)

🚀 Preview: Add preview label to enable

@claude

claude Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @maverbiest's task in 29s —— View job


Code review

  • Read the diff and related files
  • Post inline comments
  • Write the summary

This is a small, focused fix for a real race condition, and I found no blocking issues. The comment in the setup file explains why the warmup exists and why it uses the plain Playwright test instead of the console-warnings fixture.

Config filtering: The warmup project runs in the cli and all (with BROWSER set) modes. With no BROWSER set, every project runs, so the warmup is included there too. In browser mode it does not run, which is consistent with it only being a dependency of cli-tests.

Inline comments (both optional):

  1. The browser suites probably hit the same Keycloak race, so they could also depend on the warmup.
  2. If the warmup itself fails, every CLI test is skipped. Consider making it best-effort with try/catch if that's the intent.

Docs: The TEST_SUITE sections in integration-tests/README.md and AGENTS.md don't mention the warmup. A one-line note there would help, but it isn't required.

Testing: Please record in the PR checklist which manual check you ran, for example several CLI runs against a freshly deployed instance with no failures.

name: keycloakWarmupName,
use: { ...devices['Desktop Chrome'] },
testMatch: /keycloak-warmup\.setup\.ts/,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Browser suites can hit the same race: chromium-without-dep and firefox-without-dep start many parallel tests that load Keycloak pages on a fresh pod. Consider adding dependencies: [keycloakWarmupName] to those projects too, and keeping keycloakWarmupName in the TEST_SUITE === 'browser' filter. Leaving it CLI-only is fine if the flakiness has only shown up there, but it's cheap to add.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These already have their own readonlySetupName, IIUC that should already ensure the keycloak cache is populated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah but not all browser tests are run with-dep! So sometimes they run into this failure mode as well, will add the warmup to those as well

Comment on lines +10 to +14
await page.goto('/');
await page.getByRole('link', { name: 'Login' }).click();
await page.waitForLoadState('networkidle');
await page.getByRole('link', { name: 'Register' }).click();
await page.waitForLoadState('networkidle');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small robustness point: if this step fails (for example, the Login link is renamed or the page loads slowly), Playwright skips every dependent CLI test. Those tests would then show as skipped rather than failed, which is easy to miss. If the warmup is meant to be best-effort, consider wrapping the body in try/catch and logging the error. Otherwise it's fine as is, since a failure here usually means the real tests would fail too.

Also, auth.page.ts already does the same Login → Register navigation. The duplication is OK because this test intentionally avoids the console-warnings fixture.

@maverbiest

Copy link
Copy Markdown
Contributor Author

Closing as duplicate: #7429

@maverbiest maverbiest closed this Oct 19, 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.

1 participant