Skip to content

[FTR] add mocha retry support (testing only — do not merge)#268582

Draft
TamerlanG wants to merge 4 commits intoelastic:mainfrom
TamerlanG:tamerlan/ftr-mocha-retries-test
Draft

[FTR] add mocha retry support (testing only — do not merge)#268582
TamerlanG wants to merge 4 commits intoelastic:mainfrom
TamerlanG:tamerlan/ftr-mocha-retries-test

Conversation

@TamerlanG
Copy link
Copy Markdown
Contributor

Testing only — do not merge

This PR is opened purely for testing purposes to exercise the FTR mocha retry behavior in CI. It is not intended to be merged in its current form.

What's in here

Three commits adding a retry mechanism to the Functional Test Runner:

  1. mochaOpts.retries config + --retries CLI flag — new schema field with default 1 (each test runs at least twice on failure). Explicit --retries N overrides per-run; config files can opt out via mochaOpts.retries: 0.
  2. Lifecycle gatingwrapTestFunction in decorate_mocha_ui.js now suppresses lifecycle.testFailure (and --pauseOnError) on non-final retry attempts, so screenshots/snapshots/ES dumps only run for the real final failure.
  3. Reporter updatesreporter.js, ci_stats_ftr_reporter.ts, and scout_ftr_reporter.ts now handle mocha's 'retry' event so retried-then-passed tests aren't double-counted in logs, ci-stats, or Scout reports.

Things to validate before this could land for real

  • JUnit reporter (@kbn/mocha) hasn't been audited for retry awareness yet.
  • Default of retries: 1 may produce false-positive passes in CRUD-style FTR suites that share state across it blocks.
  • CI-stats accounting on flaky tests should be sanity-checked against a known-flaky config.

TamerlanG added 3 commits May 10, 2026 03:51
Adds a retries setting to the FTR mocha config so failed tests are
re-run automatically. The schema default is 1 (each test runs at least
twice on failure), and an explicit --retries N CLI flag overrides the
default per-run without clobbering values set in config files.
Mocha emits a failure for every failed attempt of a retried test. FTR's
wrapTestFunction previously triggered lifecycle.testFailure (and the
--pauseOnError handler) on every attempt, which would cause screenshot
capture, snapshot updates and ES dump-on-fail subscribers to run on
transient failures that ultimately pass.

Gate the trigger on _currentRetry === _retries so these only fire for
the final, real failure.
With retries enabled, mocha emits 'fail' for every failed attempt and
'retry' when it will re-run the test. Update the three FTR reporters to
treat retried-then-passed tests as a single passing test:

- reporter.js: log a concise 'attempt N/M failed, retrying' line on
  'retry'; suppress the multi-line failure block on non-final attempts.
- ci_stats_ftr_reporter.ts: skip failCount increments and trackRunnable
  for non-final attempts so retried tests aren't double-counted.
- scout_ftr_reporter.ts: skip TEST_END events for non-final attempts so
  the report only reflects the final outcome of each test.
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

infra-vault-gh-plugin-prod Bot commented May 10, 2026

🤖 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

kibanamachine commented May 10, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Integration Tests #15 / failure hooks runs and prints expected output
  • [job] [logs] Jest Integration Tests #15 / failure hooks runs and prints expected output
  • [job] [logs] Scout Lane #10 - stateful-classic / default / local-stateful-classic - APM integration not installed but setup completed - Admin user
  • [job] [logs] Scout Lane #8 - stateful-classic / default / local-stateful-classic - Observability Landing Page - redirects to onboarding when log data that should be ignored exists
  • [job] [logs] Scout Lane #10 - stateful-classic / default / local-stateful-classic - Observability Landing Page (discover.isEsqlDefault enabled) - redirects to onboarding when no logs data exists
  • [job] [logs] Scout Lane #5 - stateful-classic / default / local-stateful-classic - Tags management — accessibility - tags management page a11y

Metrics [docs]

✅ unchanged

History

The console reporter increments indent on every 'test' event (each
retry attempt) but mocha only emits 'test end' once after the final
attempt, so retried tests were leaking +2 indent each and subsequent
tests appeared progressively nested in the log output.

Unwind the indent in the 'retry' handler so all attempts and all
subsequent tests render at the same level.
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.

2 participants