Skip to content

[CSP] Fix flaky status_indexing API test - add missing Fleet setup call#272018

Draft
animehart wants to merge 3 commits into
elastic:mainfrom
animehart:fix/csp-status-flaky-tests
Draft

[CSP] Fix flaky status_indexing API test - add missing Fleet setup call#272018
animehart wants to merge 3 commits into
elastic:mainfrom
animehart:fix/csp-status-flaky-tests

Conversation

@animehart
Copy link
Copy Markdown
Contributor

@animehart animehart commented May 30, 2026

Summary

The STATUS = INDEXING TEST suite in status_indexing.ts was consistently returning not-deployed instead of indexing because the beforeEach block was missing the POST /api/fleet/setup call required to initialise Fleet before creating agent and package policies.

Without Fleet setup, the CSP status API cannot resolve agent policy references and falls back to not-deployed. The sibling status_indexed.ts suite (non-skipped) already includes this call — this fix brings status_indexing.ts into parity with that pattern.

Closes #240000

Checklist

Identify risks

  • Adding POST /api/fleet/setup to beforeEach increases per-test setup time by ~1–2 s in CI. This is acceptable; all other status test suites already pay this cost.
  • See some risk examples

animehart and others added 3 commits May 29, 2026 13:33
… 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>
…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>
The STATUS = INDEXING TEST suite was consistently returning 'not-deployed'
instead of 'indexing' because the beforeEach block was missing the
POST /api/fleet/setup call required to initialise Fleet before creating
agent and package policies.

Without Fleet setup, the CSP status API cannot resolve agent policy
references and falls back to 'not-deployed'. The sibling status_indexed.ts
suite (non-skipped) already includes this call; this fix brings
status_indexing.ts into parity with that pattern.

Closes elastic#240000

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/api_integration/apis/cloud_security_posture/config.ts:50

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

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner

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

  • x-pack/solutions/security/test/api_integration/apis/cloud_security_posture/config.ts x50

@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

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

[✅] x-pack/solutions/security/test/api_integration/apis/cloud_security_posture/config.ts: 50/50 tests passed.

see run history

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