Skip to content

CONSOLE-5196: Fix Playwright e2e flakes across multiple test suites - #16881

Open
rhamilto wants to merge 3 commits into
openshift:mainfrom
rhamilto:CONSOLE-5196-e2e-flake-fixes
Open

CONSOLE-5196: Fix Playwright e2e flakes across multiple test suites#16881
rhamilto wants to merge 3 commits into
openshift:mainfrom
rhamilto:CONSOLE-5196-e2e-flake-fixes

Conversation

@rhamilto

@rhamilto rhamilto commented Jul 29, 2026

Copy link
Copy Markdown
Member

Analysis / Root cause:

Multiple pre-existing flaky Playwright e2e tests are causing CI failures across PRs (e.g. #16658). Follow-on to #16863 which addressed some of these. Root causes:

  1. Alertmanager testsalertmanager.spec.ts and receivers/receivers.spec.ts both mutate the shared alertmanager-main secret via resetAlertmanagerConfig() in beforeEach/afterEach. With WORKERS=2, these files land on different workers and clobber each other's config.
  2. warmupSPA — Single-attempt page.goto('/') + heading visibility check with no retry. On slow CI clusters, this regularly exceeds the combined 90s timeout.
  3. a11y teststestA11y runs axe-core immediately after assertLoaded, but some assertLoaded callbacks only check toBeAttached() (in DOM, not necessarily rendered). Axe finds false-positive violations in partially rendered DOM.
  4. Topology tests — Tests that create workloads via git URL (validation + deployment) use the global 120s timeout, which is insufficient.
  5. Topology application namefillApplicationName assumes the text input is always visible, but it's conditionally rendered only when no applications exist or "Create application" is selected. When prior tests leave application groups in the namespace, the dropdown shows instead.
  6. Perspective-switcher — The "Developer query parameter" test patches the Console operator to enable Developer perspective but never restores it on failure.

Solution description:

  1. Merge receivers/receivers.spec.ts into alertmanager.spec.ts so all alertmanager tests share a single worker via the file-level test.describe.configure({ mode: 'serial' }).
  2. Wrap warmupSPA in expect().toPass() with escalating retry intervals (1s, 2s, 5s) and 90s overall timeout.
  3. Add loading indicator wait inside testA11y before running axe-core. Upgrade toBeAttached() to toBeVisible() in assertLoaded callbacks for routes /, /k8s/cluster/clusterroles/view, /api-resource/.../schema, and /settings/cluster.
  4. Add test.setTimeout(300_000) to the 4 topology tests that create and delete workloads.
  5. Update fillApplicationName to detect when the application dropdown is visible and select "Create application" before filling the text input.
  6. Add afterAll cleanup to remove the Console operator perspectives patch when it was applied.

Screenshots / screen recording:
N/A — test infrastructure only, no UI changes.

Test setup:
None required.

Test cases:
All affected test suites pass locally against a live cluster:

  • alertmanager.spec.ts — 14/14 passed (merged file)
  • search.spec.ts — 7/7 passed (warmupSPA retry)
  • other-routes.spec.ts — 28/28 passed (a11y + perspective cleanup)
  • topology-ci.spec.ts — 9/9 passed (timeout + application name fix)

Browser conformance:

  • Chrome

Additional info:
Continues the flake-fixing work from #16863. Should unblock PRs like #16658 that are stuck on pre-existing CI flakes.

Reviewers and assignees:

Summary by CodeRabbit

  • Tests
    • Expanded Alertmanager receiver E2E flows to cover Webhook, Email, Slack, and PagerDuty creation/editing, including advanced settings and YAML/global-default validation (with receiver-form coverage consolidated).
    • Improved reliability by retrying initial console navigation, using visibility-based waits for key UI elements, and adding explicit network waits for update toasts.
    • Increased timeouts for selected topology CI scenarios and improved topology form handling for conditional dropdown behavior.
    • Enhanced a11y testing by waiting for loading indicators to disappear; added cleanup for perspective customization changes.

Address several sources of flaky Playwright e2e test failures:

1. Alertmanager parallel worker interference: Merge receivers.spec.ts
   into alertmanager.spec.ts so all tests that mutate the shared
   alertmanager-main secret run on a single worker.

2. warmupSPA resilience: Wrap the goto + heading check in toPass()
   with retry intervals so a single slow cluster response doesn't
   cause immediate failure.

3. a11y test stabilization: Wait for loading indicators to clear
   before running axe-core analysis. Upgrade toBeAttached() checks
   to toBeVisible() in assertLoaded callbacks so pages are fully
   rendered before a11y checks run.

4. Topology test timeouts: Add test.setTimeout(300_000) to tests
   that create workloads via git URL, since validation + deployment
   regularly exceeds the 120s default.

5. Topology application name field: Handle the conditional rendering
   of the application name input by selecting "Create application"
   from the dropdown when existing applications are present.

6. Perspective-switcher cleanup: Add afterAll to remove the Console
   operator perspectives patch, preventing cluster-wide side effects
   from leaking into other tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 29, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references CONSOLE-5196 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Analysis / Root cause:

Multiple pre-existing flaky Playwright e2e tests are causing CI failures across PRs (e.g. #16658). Follow-on to #16863 which addressed some of these. Root causes:

  1. Alertmanager testsalertmanager.spec.ts and receivers/receivers.spec.ts both mutate the shared alertmanager-main secret via resetAlertmanagerConfig() in beforeEach/afterEach. With WORKERS=2, these files land on different workers and clobber each other's config.
  2. warmupSPA — Single-attempt page.goto('/') + heading visibility check with no retry. On slow CI clusters, this regularly exceeds the combined 90s timeout.
  3. a11y teststestA11y runs axe-core immediately after assertLoaded, but some assertLoaded callbacks only check toBeAttached() (in DOM, not necessarily rendered). Axe finds false-positive violations in partially rendered DOM.
  4. Topology tests — Tests that create workloads via git URL (validation + deployment) use the global 120s timeout, which is insufficient.
  5. Topology application namefillApplicationName assumes the text input is always visible, but it's conditionally rendered only when no applications exist or "Create application" is selected. When prior tests leave application groups in the namespace, the dropdown shows instead.
  6. Perspective-switcher — The "Developer query parameter" test patches the Console operator to enable Developer perspective but never restores it on failure.

Solution description:

  1. Merge receivers/receivers.spec.ts into alertmanager.spec.ts so all alertmanager tests share a single worker via the file-level test.describe.configure({ mode: 'serial' }).
  2. Wrap warmupSPA in expect().toPass() with escalating retry intervals (1s, 2s, 5s) and 90s overall timeout.
  3. Add loading indicator wait inside testA11y before running axe-core. Upgrade toBeAttached() to toBeVisible() in assertLoaded callbacks for routes /, /k8s/cluster/clusterroles/view, /api-resource/.../schema, and /settings/cluster.
  4. Add test.setTimeout(300_000) to the 4 topology tests that create and delete workloads.
  5. Update fillApplicationName to detect when the application dropdown is visible and select "Create application" before filling the text input.
  6. Add afterAll cleanup to remove the Console operator perspectives patch when it was applied.

Screenshots / screen recording:
N/A — test infrastructure only, no UI changes.

Test setup:
None required.

Test cases:
All affected test suites pass locally against a live cluster:

  • alertmanager.spec.ts — 14/14 passed (merged file)
  • search.spec.ts — 7/7 passed (warmupSPA retry)
  • other-routes.spec.ts — 28/28 passed (a11y + perspective cleanup)
  • topology-ci.spec.ts — 9/9 passed (timeout + application name fix)

Browser conformance:

  • Chrome

Additional info:
Continues the flake-fixing work from #16863. Should unblock PRs like #16658 that are stuck on pre-existing CI flakes.

Reviewers and assignees:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested a review from cajieh July 29, 2026 18:07
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
openshift-ci Bot requested a review from TheRealJon July 29, 2026 18:07
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b1938005-31e4-4387-aa72-d2c5b5688733

📥 Commits

Reviewing files that changed from the base of the PR and between c5f7c9e and dee182d.

📒 Files selected for processing (2)
  • frontend/e2e/pages/topology-page.ts
  • frontend/e2e/tests/console/app/poll-console-updates.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/e2e/pages/topology-page.ts

Walkthrough

Changes

The E2E suite now retries SPA warmup, waits for visible UI and loading states, handles optional topology application selection, synchronizes console update checks, cleans up perspective patches, extends selected topology timeouts, and adds Alertmanager receiver form coverage.

E2E readiness and synchronization

Layer / File(s) Summary
UI readiness and navigation handling
frontend/e2e/pages/base-page.ts, frontend/e2e/pages/topology-page.ts, frontend/e2e/tests/console/crud/other-routes.spec.ts, frontend/e2e/utils/a11y.ts
SPA navigation retries, topology application selection handles an optional dropdown, route checks require visible elements, and accessibility checks wait for loading indicators to disappear.
Test state and network synchronization
frontend/e2e/tests/console/crud/other-routes.spec.ts, frontend/e2e/tests/console/app/poll-console-updates.spec.ts, frontend/e2e/tests/topology/topology-ci.spec.ts
Perspective patches are cleaned up, console update tests wait for /api/check-updates, and four topology tests use 300-second timeouts.

Alertmanager receiver validation

Layer / File(s) Summary
Alertmanager receiver form coverage
frontend/e2e/tests/console/cluster-settings/alertmanager/alertmanager.spec.ts
Adds Webhook, Email, Slack, and PagerDuty creation and editing flows with YAML assertions for receiver and global configuration.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested labels: component/core

Suggested reviewers: cajieh, therealjon

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning The added Alertmanager Receiver Forms suite patches alertmanager-main in openshift-monitoring and has no MicroShift skip/tag guard. Add a [Skipped:MicroShift] label or runtime exutil.IsMicroShiftCluster() skip for these tests, or otherwise exclude them from MicroShift CI.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title is Jira-prefixed and clearly summarizes the main change: fixing multiple Playwright e2e flakes across suites.
Description check ✅ Passed The description follows the template sections and includes root cause, solution, testing, browser conformance, and additional info.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All changed test titles are static; interpolations are from fixed route/test constants, and dynamic IDs/dates appear only in bodies, not names.
Test Structure And Quality ✅ Passed The touched Playwright suites use explicit setup/cleanup, serial isolation, and bounded timeouts; the Ginkgo-specific checklist isn’t directly applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Touched files are Playwright e2e/helpers, and I found no multi-node/HA assumptions or SNO-specific skip needs in them.
Topology-Aware Scheduling Compatibility ✅ Passed PASS: The PR only changes a Playwright page object (frontend/e2e/pages/topology-page.ts); no manifests, operators, controllers, replicas, affinities, selectors, or PDBs are modified.
Ote Binary Stdout Contract ✅ Passed Changed files are only frontend/e2e TS tests/pages; no main/TestMain/BeforeSuite or stdout/logging writes were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No IPv4-only code found; external hosts in the new tests are only mocked or entered as config strings, not live network dependencies.
No-Weak-Crypto ✅ Passed No weak crypto, custom crypto, or secret/token comparisons appear in the touched files; repo search found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB usage.
Container-Privileges ✅ Passed PASS: The only changed file is a Playwright TS page-object, and the diff contains no privileged container/K8s settings (no privileged/hostPID/hostNetwork/hostIPC/allowPrivilegeEscalation).
No-Sensitive-Data-In-Logs ✅ Passed No new logging calls or debug output were added; sensitive values appear only as test inputs/assertions, not emitted logs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@rhamilto

Copy link
Copy Markdown
Member Author

/test e2e-playwright

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
frontend/e2e/tests/console/crud/other-routes.spec.ts (1)

155-169: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider logging cleanup patch failures instead of silently swallowing.

If the remove patch for /spec/customization/perspectives fails, the error is discarded via .catch(() => {}), leaving the customization on the cluster with no trace in CI logs — this can silently pollute state for later test runs.

♻️ Log cleanup failures for visibility
       await k8sClient.customObjectsApi
         .patchClusterCustomObject({
           group: 'operator.openshift.io',
           version: 'v1',
           plural: 'consoles',
           name: 'cluster',
           body: [{ op: 'remove', path: '/spec/customization/perspectives' }],
         })
-        .catch(() => {});
+        .catch((error) => {
+          console.error('[Cleanup] Failed to remove perspectives customization:', error);
+        });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/e2e/tests/console/crud/other-routes.spec.ts` around lines 155 - 169,
Update the cleanup logic in the test.afterAll handler for patchedPerspectives so
failures from patchClusterCustomObject are logged instead of being silently
discarded by catch. Preserve the existing cleanup attempt and patch payload, and
include the caught error in the CI-visible log output.
frontend/e2e/utils/a11y.ts (1)

9-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate loading-indicator selector list across two files. The same CSS selector list is maintained independently in a11y.ts and base-page.ts, risking drift as new loading/skeleton patterns are added.

  • frontend/e2e/utils/a11y.ts#L9-L19: extract LOADING_SELECTORS to a shared module (e.g., re-export from or import BasePage's selector list) instead of redeclaring it.
  • frontend/e2e/pages/base-page.ts#L35-L45: source the shared selector list from the same module so both files stay in sync.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/e2e/utils/a11y.ts` around lines 9 - 19, Eliminate the duplicated
loading selector list by defining one shared LOADING_SELECTORS source and
importing or re-exporting it wherever needed. Update frontend/e2e/utils/a11y.ts
lines 9-19 to consume the shared list, and update
frontend/e2e/pages/base-page.ts lines 35-45 to consume that same source instead
of redeclaring it; preserve the existing selector values and behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/e2e/pages/topology-page.ts`:
- Around line 197-201: Update the applicationDropdown handling in the topology
page flow to wait for visibility with a real 2-second wait, replacing the
timeout-bearing isVisible check. Preserve the fallback behavior when the
dropdown does not appear, then click the dropdown and the “Create application”
option only after the visibility wait succeeds.

---

Nitpick comments:
In `@frontend/e2e/tests/console/crud/other-routes.spec.ts`:
- Around line 155-169: Update the cleanup logic in the test.afterAll handler for
patchedPerspectives so failures from patchClusterCustomObject are logged instead
of being silently discarded by catch. Preserve the existing cleanup attempt and
patch payload, and include the caught error in the CI-visible log output.

In `@frontend/e2e/utils/a11y.ts`:
- Around line 9-19: Eliminate the duplicated loading selector list by defining
one shared LOADING_SELECTORS source and importing or re-exporting it wherever
needed. Update frontend/e2e/utils/a11y.ts lines 9-19 to consume the shared list,
and update frontend/e2e/pages/base-page.ts lines 35-45 to consume that same
source instead of redeclaring it; preserve the existing selector values and
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a4a114a1-842b-4cb0-98ff-858775c7d03d

📥 Commits

Reviewing files that changed from the base of the PR and between e6cdc2c and c5f7c9e.

📒 Files selected for processing (7)
  • frontend/e2e/pages/base-page.ts
  • frontend/e2e/pages/topology-page.ts
  • frontend/e2e/tests/console/cluster-settings/alertmanager/alertmanager.spec.ts
  • frontend/e2e/tests/console/cluster-settings/alertmanager/receivers/receivers.spec.ts
  • frontend/e2e/tests/console/crud/other-routes.spec.ts
  • frontend/e2e/tests/topology/topology-ci.spec.ts
  • frontend/e2e/utils/a11y.ts
💤 Files with no reviewable changes (1)
  • frontend/e2e/tests/console/cluster-settings/alertmanager/receivers/receivers.spec.ts

Comment thread frontend/e2e/pages/topology-page.ts Outdated
rhamilto and others added 2 commits July 29, 2026 14:17
After swapping the route handler, explicitly wait for the next
check-updates response before asserting the toast. This eliminates
the race where the 15s polling interval drifts under CI load and
the toast assertion times out before the component receives the
new data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
locator.isVisible() returns immediately and ignores the timeout
parameter. Use waitFor({ state: 'visible' }) to actually wait up
to 2s for the application dropdown to render.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rhamilto

Copy link
Copy Markdown
Member Author

/test e2e-playwright

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@rhamilto: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console-techpreview dee182d link false /test e2e-gcp-console-techpreview
ci/prow/e2e-playwright dee182d link false /test e2e-playwright

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@rhamilto

Copy link
Copy Markdown
Member Author

/test e2e-playwright

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants