Skip to content

Port TraceMapperV1 payload test from Spock to JUnit 5 - #12124

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
alexeyk/migrate-trace-mapper-v1-payload-test
Aug 4, 2026
Merged

Port TraceMapperV1 payload test from Spock to JUnit 5#12124
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
alexeyk/migrate-trace-mapper-v1-payload-test

Conversation

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor

What Does This Do

Replaces TraceMapperV1PayloadTest.groovy with a JUnit 5 / Java equivalent. All 25 Spock test instances are preserved; the count goes to 31 because test span kind value conversion (one expect block with 7 assertions) became a 7-row @TableTest.

While porting, duplicated helpers were dropped in favour of the existing shared ones:

  • traceIdBytes, newStringTable and the readFirstSpan(byte[]) / readFirstChunk(byte[]) overloads now come from V1PayloadReader, collapsing the hand-rolled unpacker walks in most tests to a single line.
  • PayloadVerifiers.CapturingChannel and PayloadVerifiers.assertEqualsWithNullAsEmpty replace the test's own ByteArrayChannel and null-as-empty helper.
  • Magic msgpack field ids are now V1PayloadReader.PayloadField / ChunkField / SpanField. This required dropping private from those three nested constant classes (test-only file, same package).
  • The ten repeated 16-arg PojoSpan constructions are behind small named factories (span, spanWithBaggage, spanWithIds, spanWithLinks).

Two behaviour-visible tightenings:

  • spanKindValueConversion asserts the literal wire values 05 instead of comparing TraceMapperV1.SPAN_KIND_* to itself, so a protocol-value change now fails the test.
  • Added attributes.size() assertions to the attribute tests, pinning that the encoder emits nothing beyond the tags under test plus thread.id / thread.name.

Motivation

The equivalent V0.4 and V0.5 payload tests were already migrated in #11871, and V1PayloadReader was written with this port in mind. This brings V1 in line with its siblings and lets the three tests share the same decode helpers.

Additional Notes

SpanLink's constructor is protected, which Groovy could call across packages but Java cannot, hence the small TestSpanLink subclass. Config isolation moves from DDSpecification to @ExtendWith(WithConfigExtension.class) plus a ProcessTags.reset(Config.get()) @BeforeEach, matching the V0.4/V0.5 tests.

No production code is touched.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD added tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes comp: core Tracer core type: refactoring labels Jul 31, 2026
@datadog-prod-us1-6

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.03 s 14.00 s [-0.6%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.97 s 12.95 s [-0.5%; +0.9%] (no difference)
startup:petclinic:appsec:Agent 16.86 s 16.77 s [-0.6%; +1.6%] (no difference)
startup:petclinic:iast:Agent 16.35 s 16.98 s [-8.0%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.60 s 16.80 s [-2.3%; -0.1%] (maybe better)
startup:petclinic:sca:Agent 16.82 s 16.52 s [+0.6%; +3.0%] (maybe worse)
startup:petclinic:tracing:Agent 16.07 s 16.05 s [-0.8%; +1.0%] (no difference)

Commit: d6bf61ba · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD marked this pull request as ready for review July 31, 2026 19:01
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested a review from a team as a code owner July 31, 2026 19:01
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD self-assigned this Jul 31, 2026

@datadog-prod-us1-6 datadog-prod-us1-6 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 Java migration preserves all original Spock scenarios and the shared reader changes only package visibility for test constants; no diff-only behavioral regression was identified. The targeted test could not execute because the checkout requires a Java 25 toolchain, while this sandbox provides JDK 8/11/17/21.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 6074405 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@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: 607440569b

ℹ️ 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".

verifySpan asserted a 16-entry span map but not that each field id appeared
exactly once, so a repeated id plus an omitted one left the omitted field's
decoded value at its initialiser. For parentId (0) and error (false) those
sentinels equal the expected values, and TraceGenerator always uses
DDSpanId.ZERO as the parent id, so the parent-id check was inert.

Assert the decoded field-id set instead, which covers all 16 fields and names
the missing id on failure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 4, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-04 21:34:10 UTC ℹ️ Start processing command /merge


2026-08-04 21:34:15 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-08-04 22:22:10 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit ff733f5 into master Aug 4, 2026
780 of 782 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the alexeyk/migrate-trace-mapper-v1-payload-test branch August 4, 2026 22:22
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants