Skip to content

test(mocha): stabilize atf final status assertion#9253

Merged
juan-fernandez merged 1 commit into
masterfrom
juan-fernandez/fix-mocha-atf-flake
Jul 8, 2026
Merged

test(mocha): stabilize atf final status assertion#9253
juan-fernandez merged 1 commit into
masterfrom
juan-fernandez/fix-mocha-atf-flake

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Stabilizes the Mocha Test Optimization attempt-to-fix integration assertion by identifying original attempts, retry attempts, and the final-status attempt from their tags instead of relying on retry span timestamp ordering.

Motivation

The integration-mocha (latest, latest) GitHub Actions job flaked because the parallel-mode test sorted retry spans by start and expected the final attempt to be last. In parallel mode, equivalent or close timestamps can make that ordering unstable, so the assertion could inspect a span without test.final_status even though the final-status span was present.

@dd-octo-sts

dd-octo-sts Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.65 MB
Deduped: 7.31 MB
No deduping: 7.31 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

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

@juan-fernandez
juan-fernandez marked this pull request as ready for review July 8, 2026 09:16
@juan-fernandez
juan-fernandez requested a review from a team as a code owner July 8, 2026 09:16
@pr-commenter

pr-commenter Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-08 09:17:45

Comparing candidate commit 94cc66c in PR branch juan-fernandez/fix-mocha-atf-flake with baseline commit a619775 in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-213902.352µs; +214920.518µs] or [-8.030%; +8.069%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-229.313ms; +236.755ms] or [-9.053%; +9.347%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-174.210ms; +189.912ms] or [-6.031%; +6.574%]

scenario:appsec-control-20

  • unstable execution_time [-120.620ms; +131.445ms] or [-7.352%; +8.012%]

scenario:appsec-control-24

  • unstable execution_time [-114.266ms; +117.633ms] or [-9.224%; +9.496%]

scenario:appsec-control-26

  • unstable execution_time [-123.880ms; +134.499ms] or [-10.036%; +10.896%]

scenario:appsec-iast-no-vulnerability-control-20

  • unstable execution_time [-17.163ms; +9.085ms] or [-6.585%; +3.486%]

scenario:appsec-iast-no-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-22.432ms; +9.951ms] or [-8.582%; +3.807%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-27.235ms; +31.473ms] or [-4.994%; +5.771%]

scenario:child_process-shell-string-24

  • unstable execution_time [-17.992ms; +20.811ms] or [-5.570%; +6.443%]
  • unstable throughput [-193823.004op/s; +169328.210op/s] or [-5.359%; +4.682%]

scenario:debugger-line-probe-with-snapshot-default-24

  • unstable cpu_user_time [-1889.662ms; +3018.623ms] or [-22.532%; +35.994%]
  • unstable execution_time [-1873.226ms; +3047.028ms] or [-20.610%; +33.525%]
  • unstable instructions [-16.3G instructions; +26.2G instructions] or [-23.765%; +38.090%]
  • unstable max_rss_usage [-8.570MB; +12.819MB] or [-5.457%; +8.163%]
  • unstable throughput [-821.314op/s; +499.960op/s] or [-22.708%; +13.823%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-2977.133ms; +2875.540ms] or [-29.861%; +28.842%]
  • unstable execution_time [-3081.539ms; +3012.954ms] or [-28.850%; +28.208%]
  • unstable instructions [-26252.4M instructions; +25610.5M instructions] or [-31.464%; +30.695%]
  • unstable max_rss_usage [-9294.146KB; +9314.946KB] or [-5.780%; +5.793%]
  • unstable throughput [-643.242op/s; +683.688op/s] or [-20.530%; +21.821%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable instructions [-3358.2M instructions; +3277.6M instructions] or [-5.174%; +5.050%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-3.621s; -0.040s] or [-34.186%; -0.373%]
  • unstable execution_time [-3.643s; -0.058s] or [-32.104%; -0.509%]
  • unstable instructions [-32.5G instructions; -0.1G instructions] or [-36.539%; -0.161%]
  • unstable throughput [+16.625op/s; +803.599op/s] or [+0.560%; +27.064%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1.552s; +3.564s] or [-17.390%; +39.935%]
  • unstable execution_time [-1.607s; +3.635s] or [-16.640%; +37.647%]
  • unstable instructions [-13.0G instructions; +30.1G instructions] or [-17.693%; +40.935%]
  • unstable max_rss_usage [-6.726MB; +15.851MB] or [-4.230%; +9.970%]
  • unstable throughput [-1007.172op/s; +435.820op/s] or [-29.351%; +12.701%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-1818.589ms; +615.601ms] or [-19.520%; +6.608%]
  • unstable execution_time [-1859.659ms; +610.195ms] or [-18.539%; +6.083%]
  • unstable instructions [-16.2G instructions; +5.5G instructions] or [-20.841%; +7.068%]
  • unstable throughput [-143.438op/s; +416.917op/s] or [-4.378%; +12.726%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-201.630ms; +504.209ms] or [-4.193%; +10.484%]
  • unstable execution_time [-197.951ms; +499.248ms] or [-4.051%; +10.216%]
  • unstable throughput [-176238.810op/s; +60222.746op/s] or [-10.224%; +3.494%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-3.630%; +7.861%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-6.212MB; +9.063MB] or [-4.743%; +6.920%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable cpu_user_time [-729.657ms; +719.967ms] or [-5.680%; +5.604%]
  • unstable execution_time [-734.224ms; +719.798ms] or [-5.590%; +5.480%]
  • unstable throughput [-3.336op/s; +3.375op/s] or [-5.442%; +5.506%]

scenario:plugin-memcached-hashring-24

  • unstable execution_time [-136.553ms; +276.542ms] or [-5.183%; +10.496%]
  • unstable throughput [-1274560.655op/s; +620061.488op/s] or [-8.745%; +4.254%]

scenario:plugin-pg-service-26

  • unstable cpu_usage_percentage [-10.540%; +6.615%]
  • unstable execution_time [-92.633ms; +144.823ms] or [-10.166%; +15.894%]
  • unstable throughput [-710071.015op/s; +463516.951op/s] or [-10.568%; +6.898%]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94cc66cad4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread integration-tests/mocha/mocha.spec.js
@datadog-official

datadog-official Bot commented Jul 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 96.50% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 94cc66c | Docs | Datadog PR Page | Give us feedback!

@juan-fernandez
juan-fernandez enabled auto-merge (squash) July 8, 2026 09:22

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Datadog Autotest: PASS

More details

The new tag-based filtering in assertAttemptToFixFailThenPass correctly fixes the parallel-mode flake: all three adversarial timestamp-ordering scenarios (normal, reversed, identical) pass cleanly. The assertion is now semantically stable — retriedTests.length === 2 is now explicitly checked (stronger than before), and the final-status span is located by tag rather than last-by-timestamp, which was the root cause of the nondeterminism.

Was this helpful? React 👍 or 👎

📊 Validated against 5 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 94cc66c · What is Autotest? · Any feedback? Reach out in #autotest

@juan-fernandez
juan-fernandez merged commit 98df480 into master Jul 8, 2026
770 of 771 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/fix-mocha-atf-flake branch July 8, 2026 09:25
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (a619775) to head (94cc66c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9253      +/-   ##
==========================================
- Coverage   96.54%   96.54%   -0.01%     
==========================================
  Files         915      915              
  Lines      121018   121018              
  Branches    20693    20851     +158     
==========================================
- Hits       116837   116836       -1     
- Misses       4181     4182       +1     
Flag Coverage Δ
aiguard 53.57% <ø> (-0.05%) ⬇️
aiguard-integration 57.01% <ø> (ø)
apm-bucket-0 53.80% <ø> (-0.05%) ⬇️
apm-bucket-1 58.11% <ø> (-0.05%) ⬇️
apm-bucket-2 56.12% <ø> (-0.05%) ⬇️
apm-capabilities-tracing 60.30% <ø> (ø)
apm-integrations-aerospike 52.95% <ø> (-0.05%) ⬇️
apm-integrations-confluentinc-kafka-javascript 57.01% <ø> (-0.05%) ⬇️
apm-integrations-couchbase 53.27% <ø> (-0.05%) ⬇️
apm-integrations-http 57.99% <ø> (-0.04%) ⬇️
apm-integrations-kafkajs 57.73% <ø> (-0.07%) ⬇️
apm-integrations-next 54.25% <ø> (-0.05%) ⬇️
apm-integrations-prisma 54.19% <ø> (-0.05%) ⬇️
apm-integrations-tedious 53.05% <ø> (-0.05%) ⬇️
appsec 69.09% <ø> (-0.04%) ⬇️
appsec-express_fastify_graphql 65.70% <ø> (-0.05%) ⬇️
appsec-integration 45.51% <ø> (ø)
appsec-kafka_ldapjs_lodash 59.13% <ø> (-0.04%) ⬇️
appsec-mongodb-core_mongoose_mysql 62.29% <ø> (-0.04%) ⬇️
appsec-next 52.86% <ø> (-0.04%) ⬇️
appsec-node-serialize_passport_postgres 61.93% <ø> (-0.04%) ⬇️
appsec-sourcing_stripe_template 60.27% <ø> (-0.04%) ⬇️
debugger 65.70% <ø> (-0.02%) ⬇️
instrumentations-bucket-0 48.75% <ø> (-0.05%) ⬇️
instrumentations-bucket-1 54.98% <ø> (-0.05%) ⬇️
instrumentations-bucket-10 56.65% <ø> (-0.05%) ⬇️
instrumentations-bucket-11 48.74% <ø> (-0.05%) ⬇️
instrumentations-bucket-12 48.85% <ø> (-0.05%) ⬇️
instrumentations-bucket-13 48.68% <ø> (-0.05%) ⬇️
instrumentations-bucket-2 49.74% <ø> (-0.05%) ⬇️
instrumentations-bucket-3 53.84% <ø> (-0.05%) ⬇️
instrumentations-bucket-4 49.17% <ø> (-0.05%) ⬇️
instrumentations-bucket-5 53.02% <ø> (-0.05%) ⬇️
instrumentations-bucket-6 55.63% <ø> (-0.05%) ⬇️
instrumentations-bucket-7 53.62% <ø> (-0.04%) ⬇️
instrumentations-bucket-8 54.65% <ø> (-0.05%) ⬇️
instrumentations-bucket-9 56.11% <ø> (-0.04%) ⬇️
instrumentations-instrumentation-couchbase 48.17% <ø> (-0.05%) ⬇️
instrumentations-integration-esbuild 33.91% <ø> (ø)
llmobs-ai_anthropic_bedrock 57.76% <ø> (-0.04%) ⬇️
llmobs-bucket-1 56.82% <ø> (-0.04%) ⬇️
llmobs-openai 57.59% <ø> (-0.04%) ⬇️
llmobs-sdk 59.99% <ø> (-0.05%) ⬇️
llmobs-vertex-ai 54.22% <ø> (-0.05%) ⬇️
master-coverage 96.54% <ø> (?)
openfeature 54.61% <ø> (-0.01%) ⬇️
openfeature-unit 49.82% <ø> (-0.05%) ⬇️
platform-core_esbuild_instrumentations-misc 38.38% <ø> (-0.03%) ⬇️
platform-integration 62.19% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 37.19% <ø> (-0.03%) ⬇️
plugins-bucket-0 53.19% <ø> (-0.05%) ⬇️
plugins-bucket-1 55.08% <ø> (ø)
plugins-bucket-11 56.74% <ø> (-0.05%) ⬇️
plugins-bucket-17 56.76% <ø> (-0.05%) ⬇️
plugins-bucket-18 57.61% <ø> (-0.05%) ⬇️
plugins-bucket-19 57.14% <ø> (-0.05%) ⬇️
plugins-bucket-20 59.39% <ø> (-0.05%) ⬇️
plugins-bucket-4 53.86% <ø> (-0.05%) ⬇️
plugins-bullmq_cassandra_cookie 57.41% <ø> (-0.05%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 52.33% <ø> (-0.05%) ⬇️
plugins-fetch_fs_generic-pool 54.55% <ø> (-0.05%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 59.89% <ø> (-0.05%) ⬇️
plugins-hapi_hono_ioredis 55.88% <ø> (-0.05%) ⬇️
plugins-jest_knex_langgraph 51.67% <ø> (-0.05%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 53.42% <ø> (-0.05%) ⬇️
plugins-lodash_mariadb_memcached 54.22% <ø> (-0.05%) ⬇️
plugins-mongodb_mongodb-core_mongoose 55.47% <ø> (-0.05%) ⬇️
plugins-multer_mysql_mysql2 54.38% <ø> (-0.05%) ⬇️
plugins-nats_node-serialize_opensearch 56.08% <ø> (-0.05%) ⬇️
plugins-passport-http_pino_postgres 54.76% <ø> (-0.05%) ⬇️
plugins-process_pug_redis 53.88% <ø> (-0.05%) ⬇️
plugins-undici_url_valkey 54.40% <ø> (-0.05%) ⬇️
plugins-vm_winston_ws 55.28% <ø> (-0.05%) ⬇️
profiling 58.22% <ø> (-0.05%) ⬇️
serverless-aws-sdk-aws-sdk 50.67% <ø> (-0.04%) ⬇️
serverless-aws-sdk-bedrockruntime 50.68% <ø> (-0.05%) ⬇️
serverless-aws-sdk-client 51.96% <ø> (-0.05%) ⬇️
serverless-aws-sdk-dynamodb 51.75% <ø> (-0.05%) ⬇️
serverless-aws-sdk-eventbridge 46.22% <ø> (-0.05%) ⬇️
serverless-aws-sdk-kinesis 54.71% <ø> (-0.05%) ⬇️
serverless-aws-sdk-lambda 52.79% <ø> (-0.05%) ⬇️
serverless-aws-sdk-s3 51.53% <ø> (-0.05%) ⬇️
serverless-aws-sdk-serverless-peer-service 54.74% <ø> (-0.05%) ⬇️
serverless-aws-sdk-sns 55.49% <ø> (-0.05%) ⬇️
serverless-aws-sdk-sqs 55.92% <ø> (-0.05%) ⬇️
serverless-aws-sdk-stepfunctions 51.25% <ø> (-0.05%) ⬇️
serverless-aws-sdk-util 48.46% <ø> (-0.05%) ⬇️
serverless-bucket-0 55.24% <ø> (-0.01%) ⬇️
serverless-bucket-1 56.02% <ø> (-0.05%) ⬇️
test-optimization-cucumber 72.94% <ø> (-0.04%) ⬇️
test-optimization-cypress 66.41% <ø> (+0.01%) ⬆️
test-optimization-jest 73.91% <ø> (-0.05%) ⬇️
test-optimization-mocha 74.32% <ø> (+0.04%) ⬆️
test-optimization-playwright-playwright-atr 61.59% <ø> (-0.01%) ⬇️
test-optimization-playwright-playwright-efd 61.78% <ø> (ø)
test-optimization-playwright-playwright-final-status 61.73% <ø> (-0.01%) ⬇️
test-optimization-playwright-playwright-impacted-tests 61.46% <ø> (+0.16%) ⬆️
test-optimization-playwright-playwright-reporting 61.60% <ø> (+0.05%) ⬆️
test-optimization-playwright-playwright-test-management 62.27% <ø> (-0.12%) ⬇️
test-optimization-playwright-playwright-test-span 61.50% <ø> (-0.06%) ⬇️
test-optimization-selenium 60.69% <ø> (-0.17%) ⬇️
test-optimization-testopt 59.15% <ø> (+0.08%) ⬆️
test-optimization-vitest 72.76% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

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.

2 participants