Skip to content

test(appsec): split FastAPI ddtest jobs for safe parallelism - #19894

Closed
gnufede wants to merge 2 commits into
gnufede/ddtest-dogfoodingfrom
gnufede/ddtest-fastapi-split
Closed

gnufede wants to merge 2 commits into
gnufede/ddtest-dogfoodingfrom
gnufede/ddtest-fastapi-split

Conversation

@gnufede

@gnufede gnufede commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

Split the ddtest FastAPI AppSec IAST coverage into separate snapshot-backed and non-snapshot suites so non-snapshot checks can use pytest xdist safely.

Changes

  • Keep threat/WAF coverage in appsec_threats_fastapi_iast with the testagent-backed snapshot configuration and serialized workers.
  • Add appsec_threats_fastapi_non_snapshot for endpoint and API-security metadata checks.
  • Move the non-snapshot collection surface into _test_fastapi_non_snapshot.py and run it with -n auto.
  • Keep ddtest_nodes: 2 for both suites, so each venv is split across independent CI jobs.
  • Preserve the original FastAPI class for legacy Riot suites; the ddtest snapshot selector excludes the checks now owned by the non-snapshot suite.

The leading underscore on the new file keeps it out of legacy directory-based Riot test discovery; the new suite invokes it explicitly.

Testing

  • Generated the GitLab configuration successfully and verified both suite matrices.
  • Passed formatting/style checks, Riot checks, suitespec validation, and the targeted generator tests (11 passed).

Risks

This is a follow-up to #19870 and is intentionally based on the gnufede/ddtest-dogfooding branch. The main validation is CI: confirm that the non-snapshot suite is safe with xdist and that the snapshot suite remains isolated from testagent cross-contamination.

@gnufede
gnufede requested review from a team as code owners August 27, 2026 16:31
@gnufede
gnufede requested review from florentinl and removed request for a team August 27, 2026 16:31
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 240 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 240 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)
ddtrace.debugging._debugger -×-> ddtrace.trace  (product:debugging -> product:tracing, score=133)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133)
ddtrace.appsec._contrib.flask -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against gnufede/ddtest-dogfooding using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.riot/requirements/12c18d7.txt                                          @DataDog/apm-python
.riot/requirements/15b6bf7.txt                                          @DataDog/apm-python
.riot/requirements/1a6be90.txt                                          @DataDog/apm-python
.riot/requirements/1cb4eaf.txt                                          @DataDog/apm-python
.riot/requirements/1cc6891.txt                                          @DataDog/apm-python
.riot/requirements/b36156a.txt                                          @DataDog/apm-python
.riot/requirements/d098bf6.txt                                          @DataDog/apm-python
.riot/requirements/fc1e799.txt                                          @DataDog/apm-python
docs/ddtest-dogfooding.md                                               @DataDog/python-guild
riotfile.py                                                             @DataDog/apm-python
tests/appsec/contrib_appsec/_test_fastapi_non_snapshot.py               @DataDog/asm-python
tests/appsec/contrib_appsec/utils.py                                    @DataDog/asm-python
tests/appsec/suitespec.yml                                              @DataDog/asm-python

@gnufede gnufede added the changelog/no-changelog A changelog entry is not required for this PR. label Aug 27, 2026
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

⚠️ Warnings

❌ Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 14 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | appsec/appsec_threats_fastapi_iast::ddtest-run: [1391c58, 3.13, 0] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | appsec/appsec_threats_fastapi_iast::ddtest-run: [1477633, 3.13, 0] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | appsec/appsec_threats_fastapi_iast::ddtest-run: [151f23f, 3.13, 0] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 14 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3fdece9 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Aug 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-27 17:16:15

Comparing candidate commit 3fdece9 in PR branch gnufede/ddtest-fastapi-split with baseline commit e21cbaf in branch gnufede/ddtest-dogfooding.

📊 Benchmarking dashboard

Found 0 performance improvements and 6 performance regressions! Performance is the same for 577 metrics, 10 unstable metrics, 18 flaky benchmarks without significant changes.

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 ----------------------------------'

scenario:httppropagationextract-tracecontext_headers

  • 🟥 execution_time [+2.357µs; +2.576µs] or [+7.428%; +8.120%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.571µs; +2.716µs] or [+15.897%; +16.795%]

scenario:iastaspects-repr_aspect

  • 🟥 execution_time [+39.328µs; +48.783µs] or [+10.777%; +13.367%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+118.196µs; +122.925µs] or [+29.891%; +31.086%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+600.199ns; +652.059ns] or [+22.711%; +24.673%]

scenario:tracer-small

  • 🟥 execution_time [+28.717µs; +31.195µs] or [+8.599%; +9.342%]

Unstable benchmarks

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

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-640.867ns; +832.616ns] or [-5.824%; +7.567%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-36.034ns; +30.291ns] or [-5.866%; +4.931%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1699.013ns; +1587.877ns] or [-9.987%; +9.334%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1211.138ns; +1308.533ns] or [-9.264%; +10.009%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-341.157ns; +311.030ns] or [-9.290%; +8.470%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-251.110ns; +269.062ns] or [-8.580%; +9.193%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-12.422ns; +133.050ns] or [-1.088%; +11.652%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3328.907ns; +4682.884ns] or [-8.186%; +11.516%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-614.090ns; +925.102ns] or [-7.631%; +11.496%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-58206.430ns; +59809.995ns] or [-9.329%; +9.586%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-casefold_noaspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_aspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:span-start
  • scenario:telemetryaddmetric-record-100-metrics

@gnufede

gnufede commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Follow-up note: this PR intentionally scopes the snapshot/non-snapshot split to FastAPI as a pilot. The shared Contrib_TestClass_For_Threats architecture is used by Django, Flask, FastAPI, and Tornado, so a complete rollout should extract/reuse the split across all framework threat suites and add the corresponding Riot/suitespec jobs rather than treating FastAPI as a one-off.

@gnufede gnufede closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant