OCPBUGS-105789: Recover expired Playwright sessions via auto re-login - #610
Closed
rhamilto wants to merge 1 commit into
Closed
OCPBUGS-105789: Recover expired Playwright sessions via auto re-login#610rhamilto wants to merge 1 commit into
rhamilto wants to merge 1 commit into
Conversation
The Playwright e2e suite authenticates once in the setup projects and freezes the session into a storageState snapshot that every test reuses. Nothing re-authenticates, so when the OpenShift OAuth token expires during a long run, navigations silently redirect to the login page and tests hang waiting for elements that never appear. Add a self-healing auth fixture that overrides the built-in page fixture: a main-frame navigation listener detects when a navigation lands on the login page and transparently re-runs performLogin for the active persona (resolved from the project storageState path), then refreshes the stored session so later tests reuse the fresh state. Re-entrancy is guarded so the login flow's own navigations don't recurse. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
/hold for openshift#16953 to merge first |
Owner
Author
|
Wrong base — reopening against openshift/console:main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Analysis / Root cause:
The Playwright e2e suite authenticates exactly once, in the setup projects (
admin-auth.setup.ts,developer-auth.setup.ts), and freezes the session into astorageStatesnapshot. Every test project loads that static snapshot (playwright.config.ts) and nothing ever re-authenticates —performLoginis only referenced by the two setup files.When the OpenShift OAuth token expires during a long run, subsequent
page.goto()calls silently redirect to the login page, and tests hang waiting for elements (e.g.user-dropdown-toggle,#page-sidebar) that never appear, failing with generictoBeVisible/test-timeout errors. This showed up as widespread login-page hangs in CI.Jira: https://redhat.atlassian.net/browse/OCPBUGS-105789
Solution description:
Add a self-healing auth fixture that overrides Playwright's built-in
pagefixture:e2e/fixtures/auth-fixture.ts(new) — attaches a main-frameframenavigatedlistener that detects when a navigation lands on the login page and transparently re-runsperformLoginfor the active persona, then re-savesstorageStateso later tests reuse the fresh session. Re-entrancy is guarded via aWeakMapso the login flow's own navigations don't recurse, and it logs a warning when recovery fires so future occurrences are visible in CI logs.e2e/setup/login-helper.ts— addsisOnLoginPage()andresolveCredentialsForStorageState()(dispatches to the existinggetAdminCredentials()/getDeveloperCredentials()helpers based on the project's storage-state filename).e2e/fixtures/index.ts— wires recovery into the sharedpagefixture. Since every spec importstestfrom here, coverage is suite-wide with no per-test changes.Auth-disabled clusters and unset developer credentials cause recovery to no-op safely.
Screenshots / screen recording:
Test setup:
Requires a cluster whose OAuth access-token lifetime is shorter than the full e2e run so the session expires mid-run; the recovery path then re-authenticates transparently.
Test cases:
Browser conformance:
Additional info:
Test-infrastructure only — no product/runtime code changes.
Reviewers and assignees:
🤖 Generated with Claude Code