Skip to content

test(test-optimization): handle 5xx retry in getKnownTests error test#9110

Merged
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-06-27-fix-getknowntests-flake
Jun 29, 2026
Merged

test(test-optimization): handle 5xx retry in getKnownTests error test#9110
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-06-27-fix-getknowntests-flake

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Summary

The getKnownTests "should return an error if the request fails" test timed
out on a clean master. The request helper retries once on a 5xx with a
5–7.5 s jittered delay, but the test mocked a single 500 interceptor and used
real timers. The retried request had no interceptor and its retry timer always
exceeded mocha's 5 s timeout, so the callback never fired.

The fix collapses the retry delay to 0 ms (the same setTimeout stub the
dedicated request.spec.js already uses) and adds a second 500 interceptor,
so the test exercises the real retry path and asserts both requests are
consumed. No production code changes.

Test plan

  • ./node_modules/.bin/mocha packages/dd-trace/test/ci-visibility/exporters/ci-visibility-exporter.spec.js --grep "getKnownTests" → 10 passing (was 9 passing, 1 failing on master).

The request helper retries once on a 5xx with a 5–7.5 s jittered delay, but
the getKnownTests "should return an error if the request fails" test mocked a
single 500 interceptor and used real timers. The retried request had no
interceptor and its retry timer always exceeded mocha's 5 s timeout, so the
callback never fired and the test timed out. Collapse the retry delay to 0 ms
and add a second 500 interceptor so the test exercises the real retry path and
asserts both requests are consumed.
@dd-octo-sts

dd-octo-sts Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.39 MB
Deduped: 7.46 MB
No deduping: 7.46 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 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

@datadog-official

datadog-official Bot commented Jun 27, 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: 87.98% (+0.00%)

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

@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.69%. Comparing base (27dcc31) to head (f08c4ef).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9110   +/-   ##
=======================================
  Coverage   93.69%   93.69%           
=======================================
  Files         889      889           
  Lines       50856    50856           
  Branches    11830    11830           
=======================================
+ Hits        47647    47648    +1     
+ Misses       3209     3208    -1     
Flag Coverage Δ
aiguard 34.88% <ø> (-0.08%) ⬇️
aiguard-integration 41.79% <ø> (ø)
apm-bucket-0 34.85% <ø> (-0.08%) ⬇️
apm-bucket-1 40.34% <ø> (-0.07%) ⬇️
apm-bucket-2 37.35% <ø> (-0.07%) ⬇️
apm-capabilities-tracing 48.30% <ø> (+<0.01%) ⬆️
apm-integrations-aerospike 33.13% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript 40.04% <ø> (-0.08%) ⬇️
apm-integrations-couchbase 33.25% <ø> (-0.35%) ⬇️
apm-integrations-http 42.04% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs 40.27% <ø> (-0.07%) ⬇️
apm-integrations-next 29.51% <ø> (-0.07%) ⬇️
apm-integrations-prisma 35.04% <ø> (-0.07%) ⬇️
apm-integrations-tedious 33.90% <ø> (-0.08%) ⬇️
appsec 57.38% <ø> (-0.06%) ⬇️
appsec-express_fastify_graphql 53.76% <ø> (-0.05%) ⬇️
appsec-integration 36.25% <ø> (ø)
appsec-kafka_ldapjs_lodash 43.60% <ø> (-0.07%) ⬇️
appsec-mongodb-core_mongoose_mysql 48.83% <ø> (-0.04%) ⬇️
appsec-next 28.01% <ø> (-0.07%) ⬇️
appsec-node-serialize_passport_postgres 48.01% <ø> (-0.06%) ⬇️
appsec-sourcing_stripe_template 45.56% <ø> (-0.06%) ⬇️
debugger 44.42% <ø> (ø)
instrumentations-bucket-0 28.16% <ø> (-0.08%) ⬇️
instrumentations-bucket-1 37.41% <ø> (-0.07%) ⬇️
instrumentations-bucket-10 40.44% <ø> (-0.07%) ⬇️
instrumentations-bucket-11 27.96% <ø> (-0.08%) ⬇️
instrumentations-bucket-12 28.67% <ø> (-0.08%) ⬇️
instrumentations-bucket-13 27.79% <ø> (-0.08%) ⬇️
instrumentations-bucket-2 30.24% <ø> (-0.07%) ⬇️
instrumentations-bucket-3 35.91% <ø> (-0.07%) ⬇️
instrumentations-bucket-4 28.07% <ø> (-0.08%) ⬇️
instrumentations-bucket-5 36.28% <ø> (-0.07%) ⬇️
instrumentations-bucket-6 38.26% <ø> (-0.08%) ⬇️
instrumentations-bucket-7 36.01% <ø> (-0.07%) ⬇️
instrumentations-bucket-8 36.96% <ø> (-0.07%) ⬇️
instrumentations-bucket-9 39.53% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-couchbase 46.54% <ø> (ø)
instrumentations-integration-esbuild 24.87% <ø> (ø)
llmobs-ai_anthropic_bedrock 39.54% <ø> (-0.07%) ⬇️
llmobs-google-genai_langchain_vertex-ai 36.98% <ø> (-0.06%) ⬇️
llmobs-openai 39.59% <ø> (-0.07%) ⬇️
llmobs-sdk 43.60% <ø> (-0.08%) ⬇️
master-coverage 93.69% <ø> (?)
openfeature 37.76% <ø> (ø)
openfeature-unit 50.39% <ø> (ø)
platform-core_esbuild_instrumentations-misc 23.36% <ø> (ø)
platform-integration 47.44% <ø> (+0.01%) ⬆️
platform-shimmer_unit-guardrails_webpack 18.89% <ø> (ø)
plugins-bucket-0 36.34% <ø> (-0.07%) ⬇️
plugins-bucket-1 39.61% <ø> (ø)
plugins-bucket-11 38.47% <ø> (-0.08%) ⬇️
plugins-bucket-17 39.16% <ø> (-0.07%) ⬇️
plugins-bucket-18 42.01% <ø> (-0.07%) ⬇️
plugins-bucket-19 39.57% <ø> (-0.07%) ⬇️
plugins-bucket-20 43.29% <ø> (-0.07%) ⬇️
plugins-bucket-4 37.72% <ø> (-0.07%) ⬇️
plugins-bullmq_cassandra_cookie 39.77% <ø> (-0.07%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 33.23% <ø> (-0.08%) ⬇️
plugins-fetch_fs_generic-pool 36.06% <ø> (-0.07%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 43.11% <ø> (-0.08%) ⬇️
plugins-hapi_hono_ioredis 37.79% <ø> (-0.07%) ⬇️
plugins-jest_knex_langgraph 32.61% <ø> (-0.08%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 27.69% <ø> (-0.24%) ⬇️
plugins-lodash_mariadb_memcached 35.18% <ø> (-0.08%) ⬇️
plugins-mongodb_mongodb-core_mongoose 36.32% <ø> (-0.07%) ⬇️
plugins-multer_mysql_mysql2 35.15% <ø> (-0.08%) ⬇️
plugins-nats_node-serialize_opensearch 37.16% <ø> (-0.08%) ⬇️
plugins-passport-http_pino_postgres 35.54% <ø> (-0.08%) ⬇️
plugins-process_pug_redis 34.27% <ø> (-0.08%) ⬇️
plugins-undici_url_valkey 35.88% <ø> (-0.07%) ⬇️
plugins-vm_winston_ws 37.56% <ø> (-0.08%) ⬇️
profiling 43.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-aws-sdk 33.30% <ø> (-0.07%) ⬇️
serverless-aws-sdk-bedrockruntime 32.17% <ø> (-0.07%) ⬇️
serverless-aws-sdk-client 37.21% <ø> (ø)
serverless-aws-sdk-dynamodb 34.15% <ø> (-0.07%) ⬇️
serverless-aws-sdk-eventbridge 27.25% <ø> (-0.07%) ⬇️
serverless-aws-sdk-kinesis 37.41% <ø> (-0.07%) ⬇️
serverless-aws-sdk-lambda 34.60% <ø> (-0.07%) ⬇️
serverless-aws-sdk-s3 32.60% <ø> (-0.07%) ⬇️
serverless-aws-sdk-serverless-peer-service 39.47% <ø> (-0.08%) ⬇️
serverless-aws-sdk-sns 38.26% <ø> (-0.19%) ⬇️
serverless-aws-sdk-sqs 38.01% <ø> (-0.07%) ⬇️
serverless-aws-sdk-stepfunctions 33.19% <ø> (-0.07%) ⬇️
serverless-aws-sdk-util 47.95% <ø> (ø)
serverless-bucket-0 39.47% <ø> (ø)
serverless-lambda 34.33% <ø> (-0.09%) ⬇️
test-optimization-cucumber 52.57% <ø> (+0.11%) ⬆️
test-optimization-cypress 49.73% <ø> (+0.17%) ⬆️
test-optimization-jest 55.67% <ø> (+0.11%) ⬆️
test-optimization-mocha 53.69% <ø> (+0.11%) ⬆️
test-optimization-playwright-playwright-atr 43.59% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-efd 43.87% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-final-status 43.93% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-impacted-tests 43.41% <ø> (ø)
test-optimization-playwright-playwright-reporting 43.50% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-management 44.93% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-span 44.78% <ø> (+0.07%) ⬆️
test-optimization-selenium 45.52% <ø> (+0.06%) ⬆️
test-optimization-testopt 48.28% <ø> (+0.08%) ⬆️
test-optimization-vitest 50.93% <ø> (+0.10%) ⬆️

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.

@BridgeAR
BridgeAR marked this pull request as ready for review June 27, 2026 08:16
@BridgeAR
BridgeAR requested a review from a team as a code owner June 27, 2026 08:16
@BridgeAR BridgeAR changed the title test(ci-visibility): handle 5xx retry in getKnownTests error test test(test-optimization): handle 5xx retry in getKnownTests error test Jun 27, 2026

@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

PR fixes a test flake by collapsing the 5-7.5s request retry delay to 0ms in the test stub and adding a second mock interceptor so the retry path completes within mocha's 5s timeout. Test-only change; no production code impact. Pattern matches dedicated request.spec.js tests already in the codebase.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@pr-commenter

pr-commenter Bot commented Jun 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-27 08:24:47

Comparing candidate commit f08c4ef in PR branch BridgeAR/2026-06-27-fix-getknowntests-flake with baseline commit 27dcc31 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2252 metrics, 34 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-20

  • unstable execution_time [-190.609ms; +186.296ms] or [-5.099%; +4.983%]

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-180342.177µs; +179649.110µs] or [-6.852%; +6.825%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-212.891ms; +202.759ms] or [-8.478%; +8.075%]

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

  • unstable execution_time [-158736.490µs; +156892.390µs] or [-5.509%; +5.445%]

scenario:appsec-control-20

  • unstable execution_time [-170.813ms; +155.406ms] or [-9.795%; +8.911%]

scenario:appsec-control-24

  • unstable execution_time [-101.377ms; +105.861ms] or [-8.349%; +8.718%]

scenario:appsec-control-26

  • unstable execution_time [-115.148ms; +106.457ms] or [-9.498%; +8.781%]

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

  • unstable cpu_user_time [-1611.181ms; +534.942ms] or [-20.365%; +6.761%]
  • unstable execution_time [-1627.723ms; +548.324ms] or [-18.942%; +6.381%]
  • unstable instructions [-13.8G instructions; +4.5G instructions] or [-21.477%; +7.068%]
  • unstable throughput [-167.882op/s; +482.286op/s] or [-4.374%; +12.565%]

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

  • unstable cpu_user_time [-2923.205ms; +2840.265ms] or [-29.137%; +28.310%]
  • unstable execution_time [-2948.677ms; +2834.505ms] or [-27.460%; +26.396%]
  • unstable instructions [-26747.8M instructions; +25386.4M instructions] or [-31.926%; +30.301%]
  • unstable max_rss_usage [-8642.820KB; +9131.620KB] or [-5.366%; +5.669%]
  • unstable throughput [-611.119op/s; +648.780op/s] or [-19.657%; +20.869%]

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

  • unstable cpu_user_time [-1883.024ms; +581.643ms] or [-20.137%; +6.220%]
  • unstable execution_time [-1906.661ms; +596.814ms] or [-18.989%; +5.944%]
  • unstable instructions [-16.7G instructions; +5.0G instructions] or [-21.439%; +6.453%]
  • unstable throughput [-129.718op/s; +422.257op/s] or [-3.962%; +12.896%]

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

  • unstable cpu_user_time [-2677.932ms; +2605.595ms] or [-31.540%; +30.688%]
  • unstable execution_time [-2756.118ms; +2688.646ms] or [-30.031%; +29.296%]
  • unstable instructions [-22897.5M instructions; +22587.7M instructions] or [-33.006%; +32.559%]
  • unstable max_rss_usage [-10055.273KB; +9884.873KB] or [-6.274%; +6.168%]
  • unstable throughput [-785.683op/s; +812.085op/s] or [-21.383%; +22.101%]

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

  • unstable cpu_user_time [-1820.014ms; +604.214ms] or [-19.447%; +6.456%]
  • unstable execution_time [-1855.208ms; +657.178ms] or [-18.457%; +6.538%]
  • unstable instructions [-16.0G instructions; +5.3G instructions] or [-20.509%; +6.801%]
  • unstable throughput [-149.698op/s; +397.557op/s] or [-4.578%; +12.158%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-480.857ms; +246.415ms] or [-9.759%; +5.001%]
  • unstable execution_time [-479.951ms; +246.845ms] or [-9.598%; +4.936%]
  • unstable throughput [-84719.806op/s; +163840.756op/s] or [-5.041%; +9.748%]

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

  • unstable max_rss_usage [-47.022MB; +19.164MB] or [-12.045%; +4.909%]

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

  • unstable max_rss_usage [-52.547MB; +73.325MB] or [-25.800%; +36.001%]

@juan-fernandez juan-fernandez left a comment

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.

Thanks! I wonder why this hasn't failed before 🤔

@BridgeAR
BridgeAR merged commit 2d0ccbe into master Jun 29, 2026
807 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-06-27-fix-getknowntests-flake branch June 29, 2026 09:59
This was referenced Jun 30, 2026
rochdev pushed a commit that referenced this pull request Jul 2, 2026
…#9110)

The request helper retries once on a 5xx with a 5–7.5 s jittered delay, but
the getKnownTests "should return an error if the request fails" test mocked a
single 500 interceptor and used real timers. The retried request had no
interceptor and its retry timer always exceeded mocha's 5 s timeout, so the
callback never fired and the test timed out. Collapse the retry delay to 0 ms
and add a second 500 interceptor so the test exercises the real retry path and
asserts both requests are consumed.
rochdev pushed a commit that referenced this pull request Jul 2, 2026
…#9110)

The request helper retries once on a 5xx with a 5–7.5 s jittered delay, but
the getKnownTests "should return an error if the request fails" test mocked a
single 500 interceptor and used real timers. The retried request had no
interceptor and its retry timer always exceeded mocha's 5 s timeout, so the
callback never fired and the test timed out. Collapse the retry delay to 0 ms
and add a second 500 interceptor so the test exercises the real retry path and
asserts both requests are consumed.
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