Skip to content

Migrate dd-trace-core groovy files to java part 6#11362

Open
jpbempel wants to merge 1 commit into
masterfrom
jpbempel/g2j-core-pt6
Open

Migrate dd-trace-core groovy files to java part 6#11362
jpbempel wants to merge 1 commit into
masterfrom
jpbempel/g2j-core-pt6

Conversation

@jpbempel
Copy link
Copy Markdown
Member

What Does This Do

we migrate 6 tests

  • PendingTracerBufferTest
  • PendingTraceStrictWriteTest
  • PendingTraceTest
  • PendingTraceTestBase
  • TraceInterceptorTest
  • TracingConfigPollerTest

Motivation

this is part of the effort to migrate groovy tests to Java/JUnit
part1: #11053
part2: #11062
part3: #11085
part4: #11146
part5: #11217

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@jpbempel jpbempel requested a review from a team as a code owner May 13, 2026 07:25
@jpbempel jpbempel requested a review from dougqh May 13, 2026 07:25
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 13, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

we migrate 6 tests
 - PendingTracerBufferTest
 - PendingTraceStrictWriteTest
 - PendingTraceTest
 - PendingTraceTestBase
 - TraceInterceptorTest
 - TracingConfigPollerTest
@jpbempel jpbempel force-pushed the jpbempel/g2j-core-pt6 branch from abcd3c1 to 66b5f3c Compare May 13, 2026 08:09
@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes labels May 13, 2026
return "0";
}

// @VisibleForTesting
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd be fine with package visible member variables, but I don't feel strongly either way.

Copy link
Copy Markdown
Contributor

@bric3 bric3 left a comment

Choose a reason for hiding this comment

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

I found a few issues in the port on PendingTraceBufferTest, that's strange that the llm didn't caught them

continuations.get(0).cancel();

assertEquals(0, trace.getPendingReferenceCount());
verify(tracer).write(any());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: It seems this verification is missing the payload size, line 117 on the groovy counterpart:

1 * tracer.write({ it.size() == 1 })

You can probably write that with Mockito's argThat :

Suggested change
verify(tracer).write(any());
verify(tracer).write(argThat(trace -> trace.size() == 1));

It seems to be applicable to other verifications, I didn't commented them all.


assertEquals(0, trace.size());
assertEquals(0, trace.getPendingReferenceCount());
verify(tracer).write(any());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue:

Suggested change
verify(tracer).write(any());
verify(tracer).write(argThat(trace -> trace.size() == 2));

From line 153

1 * tracer.write({ it.size() == 2 })

assertEquals(0, trace.size());
assertEquals(0, trace.getPendingReferenceCount());
assertTrue(trace.isRootSpanWritten());
verify(bufferSpy, atLeastOnce()).enqueue(trace);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: atLeastOnce() allows more than one invocation at line 359, while the original invocation expect only one.

1 * bufferSpy.enqueue(trace)
Suggested change
verify(bufferSpy, atLeastOnce()).enqueue(trace);
verify(bufferSpy, times(1)).enqueue(trace);

Comment on lines +240 to +242
verify(bufferSpy).enqueue(any());
verify(tracer, never()).write(any());
verify(tracer).onRootSpanPublished(any());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: it seems some assertions are missing

1 * tracer.captureTraceConfig() >> tracerConfig
0 * tracer.writeTimer() >> Monitoring.DISABLED.newTimer("")

Note, the verify(tracer, never()).write(any()); is a bit different than 0 * tracer.write({ it.size() == 1 }) but unsure if this is an issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: testing Testing tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants