Skip to content

Fix vacuous passes in v1 payload tests - #7450

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
dario.castane/busy-hofstadter-60817c
Aug 7, 2026
Merged

Fix vacuous passes in v1 payload tests#7450
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
dario.castane/busy-hofstadter-60817c

Conversation

@darccio

@darccio darccio commented Aug 4, 2026

Copy link
Copy Markdown
Member

⚠️ Merge order: this PR must land AFTER #7447.
Test_V1TopLevelSpans is currently activated for the 6 nodejs weblogs on main off a vacuous pass (see below). This PR adds an assertion that makes that vacuous pass fail honestly. #7447 deactivates Test_V1TopLevelSpans for nodejs. If this PR merges before #7447, nodejs Test_V1TopLevelSpans goes red until #7447 follows.

Motivation

Two tests in tests/test_v1_payloads.py could pass without asserting anything.

Test_V1TopLevelSpans::test_root_span_is_top_level iterates interfaces.library.get_root_spans(self.r) with no non-empty guard. get_root_spans (utils/interfaces/_library/core.py:145) is a generator that yields nothing when no root spans match, so when the tracer sends v0.4 instead of v1 the loop body never executes and the test passes — despite its own docstring asserting that a root span must exist and be marked top-level. Compare get_root_span singular (core.py:159), which does assert spans, "No root spans found".

Test_V1PayloadByDefault::test_main has the same shape over get_traces().

This is not theoretical. It caused a real misclassification: the easy-win auto-activation script observed Test_V1TopLevelSpans "passing" for the 6 nodejs weblogs and activated it in manifests/nodejs.yml, even though dd-trace-js has no v1 trace encoder at any version — packages/dd-trace/src/encode/ ships only 0.4.js and 0.5.js on every ref including master and tag v6.8.0. The tracer sends v0.4, zero v1 root spans are collected, and the test reports success.

Changes

Collect each generator into a list and assert it is non-empty before looping, so an empty result is a failure rather than a silent pass.

Test-only — no manifest changes.

Merge order: this must land after #7447

Test_V1TopLevelSpans is currently activated for the 6 nodejs weblogs on main, off the back of the vacuous pass described above. Once the guard lands, that test genuinely fails for nodejs.

#7447 removes the bogus file-level version gate for tests/test_v1_payloads.py and collapses the block to a single missing_feature entry, which deactivates Test_V1TopLevelSpans for all six nodejs weblogs (and Test_V1SpanEvents for ruby rack). #7447 must merge first.

An earlier revision of this PR carried its own per-class deactivation block to stay independently mergeable, but it duplicated what #7447's file-level entry already covers and attached to context lines #7447 deletes, so the two conflicted. Dropped it in favour of a clean split: #7447 owns manifests, this PR owns test logic.

Reviewer notes

Test_V1SpanLinks and Test_V1SpanEvents already assert non-emptiness and are unchanged.

java and golang have Test_V1TopLevelSpans activated too (java: ratpack, uds-spring-boot, spring-boot-wildfly, spring-boot-undertow; golang: net-http, net-http-orchestrion). The guard should be a no-op there — both also have Test_V1Payloads activated, which asserts real v1 payload structure, so spans are demonstrably being collected. Worth confirming on CI rather than assuming.

The upstream cause is the auto-activation script treating a vacuous pass as an easy win. This PR removes the vacuous passes; whether the script needs its own fix is a question for #apm-shared-testing.

Workflow

  1. Create your PR as draft
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

Once your PR is reviewed and the CI green, you can merge it!

#apm-shared-testing

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team — only tests/ is modified
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

🤖 Generated with Claude Code

…pans

`interfaces.library.get_root_spans()` and `get_traces()` are generators that
yield nothing when no matching data is collected. Two tests in
tests/test_v1_payloads.py only iterated them without asserting non-emptiness,
so they PASSED when zero spans/traces were found, contradicting their own
docstrings:

- Test_V1TopLevelSpans::test_root_span_is_top_level
- Test_V1PayloadByDefault::test_main

Note the asymmetry that made this easy to miss: the singular
`get_root_span()` does `assert spans, "No root spans found"`, but the plural
`get_root_spans()` has no such guard. Sibling classes Test_V1SpanLinks,
Test_V1SpanEvents and Test_V1Payloads already assert non-emptiness and are
unaffected.

This was not theoretical. The easy win activation script observed
Test_V1TopLevelSpans "passing" for the 6 nodejs weblogs and activated it in
manifests/nodejs.yml, even though dd-trace-js ships no v1 trace encoder:
packages/dd-trace/src/encode/ contains only 0.4.js and 0.5.js on both master
and v6.8.0, and getEncoder() falls back to the 0.4 encoder for any value
other than '0.5'. So DD_TRACE_AGENT_PROTOCOL_VERSION=1.0 produces no v1
payload, zero v1 root spans are collected, and the test reported success.
Deactivated for the 6 nodejs weblogs with a comment recording why.

Blast radius checked with Manifest(...).get_declarations(...) across every
library/weblog rather than by reading the YAML, since manifest declarations
only ever disable. Test_V1TopLevelSpans was active for nodejs (6 weblogs),
java (15) and golang (net-http, net-http-orchestrion); off everywhere else.
Test_V1PayloadByDefault is off for every library/weblog, so its guard is
zero-risk. java and golang genuinely support v1 (ProtocolVersion.V1_0 in
dd-trace-java, tracesAPIPathV1 in dd-trace-go) and already run other classes
in the same scenario that assert non-emptiness and are green, so the new
guard is a no-op there.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

tests/test_v1_payloads.py                                               @DataDog/system-tests-core

The Test_V1TopLevelSpans deactivation added here overlapped #7447, which
removes the bogus file-level version gate for tests/test_v1_payloads.py and
collapses the whole block to a single `missing_feature` entry. That entry
already covers Test_V1TopLevelSpans for all six nodejs weblogs, so the
per-class block added here was redundant, and it attached to context lines
that #7447 deletes -- so whichever PR merged second would have conflicted.

Keep this PR test-only and let #7447 own all manifest deactivation.

This creates a merge-order dependency: #7447 must land first, otherwise the
new "Expected at least one root span" assertion turns nodejs
Test_V1TopLevelSpans red, since it is still activated on main.

Co-Authored-By: Claude <noreply@anthropic.com>
@darccio darccio changed the title Fix vacuous passes in v1 payload tests, deactivate nodejs top-level spans Fix vacuous passes in v1 payload tests Aug 4, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 4, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@darccio
darccio marked this pull request as ready for review August 6, 2026 13:00
@darccio
darccio requested a review from a team as a code owner August 6, 2026 13:00
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit dd3bcd3 into main Aug 7, 2026
423 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dario.castane/busy-hofstadter-60817c branch August 7, 2026 15:28
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