Skip to content

fix(test-optimization): jest instrumentation applies auto test retries on top of other retry mechanisms#7251

Merged
calvinbayer merged 5 commits intomasterfrom
calvin.bayer/fix/retry-mechanism-priority-order
Jan 20, 2026
Merged

fix(test-optimization): jest instrumentation applies auto test retries on top of other retry mechanisms#7251
calvinbayer merged 5 commits intomasterfrom
calvin.bayer/fix/retry-mechanism-priority-order

Conversation

@calvinbayer
Copy link
Copy Markdown
Contributor

What does this PR do?

Introduce an order of priority for applying retry mechanisms:

  • Attempt to Fix
  • Early Flake Detection
  • Auto Test Retries

This change aligns the behavior of the Jest instrumentation with how other tracers do it. It also decreases the number of retries and thus the performance overhead introduced by instrumenting tests with Test Optimization. E.g., before this change, if both EFD and ATR were enabled, a new failing test would be executed 66 times: (1 execution + 10 EFD retries) * (1 execution + 5 ATR retries). After this change, ATR retries will not be applied anymore and this test is only executed 11 times as expected.

Motivation

Working on adding the @test.final_status tag had unexpected side effects with multiple retry mechanisms being applied.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 15, 2026

Overall package size

Self size: 4.41 MB
Deduped: 5.23 MB
No deduping: 5.23 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.87%. Comparing base (b9e9246) to head (14f60c8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7251      +/-   ##
==========================================
- Coverage   86.25%   78.87%   -7.39%     
==========================================
  Files         513      392     -121     
  Lines       22054    18166    -3888     
==========================================
- Hits        19023    14328    -4695     
- Misses       3031     3838     +807     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official

This comment has been minimized.

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Jan 15, 2026

Benchmarks

Benchmark execution time: 2026-01-20 15:17:38

Comparing candidate commit 14f60c8 in PR branch calvin.bayer/fix/retry-mechanism-priority-order with baseline commit b9e9246 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 232 metrics, 28 unstable metrics.

@calvinbayer calvinbayer marked this pull request as ready for review January 15, 2026 16:55
@calvinbayer calvinbayer requested a review from a team as a code owner January 15, 2026 16:55
anmarchenko
anmarchenko previously approved these changes Jan 16, 2026
juan-fernandez
juan-fernandez previously approved these changes Jan 19, 2026
Copy link
Copy Markdown
Collaborator

@juan-fernandez juan-fernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 nice! Only minor comments, otherwise LGTM

})

context('early flake detection', () => {
it('takes precedence over flaky test retries for new tests', (done) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we try to make the test async instead of using done? I've been trying to get rid of done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🫡

Comment on lines +4181 to +4182
}
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick

Suggested change
}
)
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised to see we don't have code formatting as part of linting. Fixed it manually

eventsPromise
])
})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check that attempt to fix takes precedence over retries triggered by impacted_tests_enabled: true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, added a test for that too

const isAttemptToFix = this.isTestManagementTestsEnabled &&
this.testManagementTestsForThisSuite?.attemptToFix?.includes(testFullName)
if (
this.isTestManagementTestsEnabled &&
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: this is redundant as it's already a requirement for isAttemptToFix

Suggested change
this.isTestManagementTestsEnabled &&

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, removed that part of the condition

@calvinbayer calvinbayer force-pushed the calvin.bayer/fix/retry-mechanism-priority-order branch from 13aae60 to 14f60c8 Compare January 20, 2026 15:05
@calvinbayer calvinbayer merged commit b6a0389 into master Jan 20, 2026
797 checks passed
@calvinbayer calvinbayer deleted the calvin.bayer/fix/retry-mechanism-priority-order branch January 20, 2026 16:07
dd-octo-sts bot pushed a commit that referenced this pull request Jan 21, 2026
…s on top of other retry mechanisms (#7251)

* fix(test-optimization): jest instrumentation applies auto test retries on top of other retry mechanisms

* test: refactor test to be asynchronous and not rely on done callback

* style: format closing parenthesis

* refactor: remove redundant condition

* test: add test to check atf takes precedence over efd for impacted tests
@dd-octo-sts dd-octo-sts bot mentioned this pull request Jan 21, 2026
BridgeAR pushed a commit that referenced this pull request Jan 22, 2026
…s on top of other retry mechanisms (#7251)

* fix(test-optimization): jest instrumentation applies auto test retries on top of other retry mechanisms

* test: refactor test to be asynchronous and not rely on done callback

* style: format closing parenthesis

* refactor: remove redundant condition

* test: add test to check atf takes precedence over efd for impacted tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants