Skip to content

[CSP] Fix flaky CSPM GCP integration test - increase Add Agent flyout wait timeout#271993

Open
animehart wants to merge 3 commits into
elastic:mainfrom
animehart:fix/cspm-gcp-flaky-tests
Open

[CSP] Fix flaky CSPM GCP integration test - increase Add Agent flyout wait timeout#271993
animehart wants to merge 3 commits into
elastic:mainfrom
animehart:fix/cspm-gcp-flaky-tests

Conversation

@animehart
Copy link
Copy Markdown
Contributor

Summary

Fixes the consistently flaky describe('Test adding Cloud Security Posture Integrations CSPM GCP') suite in group4/pages/cis_integrations/cspm/cis_integration_gcp.ts (issue #258331).

Root cause: clickFirstElementOnIntegrationTableAddAgent in the shared page object used retry.waitFor to wait for the agentEnrollmentFlyout element. retry.waitFor uses timeouts.waitFor from the FTR config (10 s). In CI, the agent enrollment flyout can take longer than 10 s to render after clicking the Add Agent button, causing:

TimeoutError: Waiting for element to be located By(css selector, [data-test-subj="agentEnrollmentFlyout"])
Wait timed out after 10039ms

Fix:

  • Add waitUntilLoadingHasFinished() before clicking Add Agent so the page is stable before the click.
  • Switch retry.waitForretry.waitForWithTimeout(..., 30_000, ...) giving the flyout the same 30-second budget as saveIntegrationPolicyTimeout.
  • Remove describe.skip and // Failing: See #258331 comment.

The shared page object (add_cis_integration_form_page.ts) is also used by cis_integration_aws.ts and cis_integration_cnvm.ts — the change is strictly additive (longer timeout, extra loading guard) and does not affect their behaviour.

Checklist

Identify risks

  • The shared page object change increases the maximum wait for the agent enrollment flyout from 10 s to 30 s. In the success path (flyout renders quickly) there is no wall-clock impact. In a failure path the test now waits up to 30 s before failing, but this is acceptable for a UI action that creates agent policies.
  • See some risk examples

Made with Cursor

… wait timeout

The 'Add Agent FLyout' tests in the GCP CSPM suite were consistently
timing out with:

  TimeoutError: Waiting for element to be located By(css selector,
  [data-test-subj="agentEnrollmentFlyout"])
  Wait timed out after 10039ms

Root cause: `retry.waitFor` in `clickFirstElementOnIntegrationTableAddAgent`
uses `timeouts.waitFor` from the FTR config (10 s). The agent enrollment
flyout can take longer than that to render in CI after clicking Add Agent,
especially when the page still has pending network requests.

Fix:
- Add `waitUntilLoadingHasFinished()` before clicking the Add Agent button
  so the page is stable before the click.
- Switch `retry.waitFor` → `retry.waitForWithTimeout(..., 30_000, ...)` so
  the flyout has the same 30-second budget used by `saveIntegrationPolicyTimeout`.

Also removes the `describe.skip` and the `// Failing: See elastic#258331` comment
from group4/pages/cis_integrations/cspm/cis_integration_gcp.ts.

Closes elastic#258331

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@animehart
Copy link
Copy Markdown
Contributor Author

/flaky ftrConfig:x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts:50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner

✅ Build triggered - kibana-flaky-test-suite-runner#12526

  • x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts x50

@animehart
Copy link
Copy Markdown
Contributor Author

/flaky ftrConfig:x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts:50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner

✅ Build triggered - kibana-flaky-test-suite-runner#12527

  • x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts x50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#12526

[❌] x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts: 0/50 tests passed.

see run history

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#12527

[❌] x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts: 0/50 tests passed.

see run history

…ssertions

The previous implementation used retry.tryForTime and threw when the
string was absent, meaning it could never return false. Tests asserting
.to.be(false) (e.g. ORG_ID absent in Single Account mode) always timed
out with "retry.tryForTime reached timeout 20000 ms".

Fix: wait up to 30 s for the code block to be non-empty, then return
text.includes(str) as a plain boolean so both .to.be(true) and
.to.be(false) assertions work correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@animehart
Copy link
Copy Markdown
Contributor Author

/flaky ftrConfig:x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts:50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner

✅ Build triggered - kibana-flaky-test-suite-runner#12532

  • x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts x50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#12532

[✅] x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts: 50/50 tests passed.

see run history

@animehart
Copy link
Copy Markdown
Contributor Author

/flaky ftrConfig:x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts:50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner

✅ Build triggered - kibana-flaky-test-suite-runner#12534

  • x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts x50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#12534

[✅] x-pack/solutions/security/test/cloud_security_posture_functional/group4/config.ts: 50/50 tests passed.

see run history

@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/contextual-security-apps (Team:Cloud Security)

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #61 / Cloud Security Posture - Group 5 (KSPM + Flyouts) Security Alerts Page - Graph visualization expanded flyout - filter by node

Metrics [docs]

✅ unchanged

History

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

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v9.5.0

Projects

None yet

2 participants