Skip to content

Migrate internal-api groovy files to java part 2 - #12766

Open
jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-internal-api-pt2
Open

jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-internal-api-pt2

Conversation

@jpbempel

@jpbempel jpbempel commented Oct 6, 2026

Copy link
Copy Markdown
Member

What Does This Do

we migrate tests:

  • ConfigProviderTest
  • OtelEnvironmentConfigSourceTest
  • StableConfigParserTest
  • BaggageTest
  • SpanLinkTest
  • TaskWrapperTest
  • URIDataAdapterTest
  • URIDefaultDataAdapterTest
  • URINoRawDataAdapterTest
  • URIRawDataAdapterTest
  • URIUtilsTest
  • UnparseableURIAdapterTest
  • Utf8ByteStringTest

Motivation

this is part of the effort to migrate groovy tests to Java/JUnit

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@jpbempel
jpbempel requested a review from a team as a code owner October 6, 2026 22:43
@jpbempel
jpbempel requested review from mcculls and removed request for a team October 6, 2026 22:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T22:46:55.366056Z 6ac6cc6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1-2

This comment has been minimized.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Bits Code Review: PASS

More details

The migrated tests retain the original scenarios, assertions, and relevant configuration cleanup. Confidence is limited to static review because the test suite was not executed.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 6ac6cc6 · @DataDog review to ask questions

@dd-octo-sts

dd-octo-sts Bot commented Oct 6, 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 13.98 s 13.93 s [-0.3%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 12.99 s 13.08 s [-1.5%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 17.25 s 17.16 s [-0.7%; +1.8%] (no difference)
startup:petclinic:iast:Agent 17.12 s 16.60 s [-1.3%; +7.6%] (no difference)
startup:petclinic:profiling:Agent 16.68 s 16.74 s [-1.5%; +0.7%] (no difference)
startup:petclinic:sca:Agent 17.21 s 17.08 s [-0.2%; +1.7%] (no difference)
startup:petclinic:tracing:Agent 16.28 s 16.13 s [-0.1%; +2.0%] (no difference)

Commit: 548ee175 · 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.

@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring labels Oct 7, 2026
we migrate tests:
 - ConfigProviderTest
 - OtelEnvironmentConfigSourceTest
 - StableConfigParserTest
 - BaggageTest
 - SpanLinkTest
 - TaskWrapperTest
 - URIDataAdapterTest
 - URIDefaultDataAdapterTest
 - URINoRawDataAdapterTest
 - URIRawDataAdapterTest
 - URIUtilsTest
 - UnparseableURIAdapterTest
 - Utf8ByteStringTest
@jpbempel
jpbempel force-pushed the jpbempel/g2j-internal-api-pt2 branch from 6ac6cc6 to 12c67f3 Compare October 7, 2026 00:21

@bric3 bric3 left a comment

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.

Overall looks ok to me, I got a few suggestions, some I'd like to see in the PR before merging, some might be later improvements (non-blocking).

}

@Test
@WithConfig(key = "dd.trace.otel.enabled", value = "true", addPrefix = false)

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.

suggestion: Use the already imported TRACE_OTEL_ENABLED in the five system-property overrides, with the default dd. prefix. The span-metrics override can likewise use OTEL_TRACES_SPAN_METRICS_ENABLED while retaining addPrefix = false. This is non-blocking and follows migration rule RULE-A02.

Suggested change
@WithConfig(key = "dd.trace.otel.enabled", value = "true", addPrefix = false)
@WithConfig(key = TRACE_OTEL_ENABLED, value = "true")

Note

I only mention this once, but oter tests could apply this suggestion


@Disabled("enable this test when we enable the OpenTelemetry integration by default")
@Test
@WithConfig(key = "otel.sdk.disabled", value = "true", addPrefix = false)

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.

note (non-blocking): Beyond the scope of this PR it's "odd" these config key do not exists as constant somewhere (they do not).

Comment on lines +219 to +232
String baseYaml =
"\n"
+ "config_id: 12345\n"
+ "apm_configuration_default:\n"
+ " KEY_ONE: \"value_one\"\n"
+ "apm_configuration_rules:\n";
String builderYaml =
"\n"
+ " - selectors:\n"
+ " - origin: language\n"
+ " matches: [\"Java\"]\n"
+ " operator: equals\n"
+ " configuration:\n"
+ " KEY_TWO: \"value_two\"\n";

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.

thought (non-blocking): I just thought that maybe we could use String.join instead in multi-line strings?

Comment on lines +69 to +89
SpanAttributes.Builder builder = SpanAttributes.builder();

builder.put("string", "value");
builder.put("string-empty", "");
builder.put("string-null", (String) null);
builder.put("bool", true);
builder.put("bool-false", false);
builder.put("long", 12345L);
builder.put("long-negative", -12345L);
builder.put("double", 67.89);
builder.put("double-negative", -67.89);
builder.putStringArray("string-array", asList("abc", "", null, "def"));
builder.putStringArray("string-array-null", null);
builder.putBooleanArray("bool-array", asList(true, false, null, Boolean.TRUE, Boolean.FALSE));
builder.putStringArray("bool-array-null", null);
builder.putLongArray("long-array", asList(123L, 456L, null, Long.MIN_VALUE, Long.MAX_VALUE));
builder.putStringArray("long-array-null", null);
builder.putDoubleArray(
"double-array", asList(12.3D, 45.6D, null, Double.MIN_VALUE, Double.MAX_VALUE));
builder.putStringArray("double-array-null", null);
Map<String, String> map = builder.build().asMap();

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.

suggestion (non-blocking): SpanAttributes.Builder api is fluent, the following could be rewritten this way

Map<String, String> map = SpanAttributes.builder()
    .put("string", "value")
    .put("string-empty", "")
    // ...
    .build().asMap();

import java.net.URI;
import org.tabletest.junit.TableTest;

abstract class URIDataAdapterTest {

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.

suggestion: In groovy URIDataAdapterTest is an abstract class, and the file declares the other concrete test classes, e.g. URIDefaultDataAdapterTest.

In order to keep the same organisation, I propose to use JUnit 5's nested classes. In pusedo-code :

class URIDataAdapterTest {

  abstract static class AdapterContract {

    abstract URIDataAdapter adapter(URI uri);

    boolean supportsRaw() {
      return true;
    }

    @TableTest({
      // scenari (yes italian plural :D)
    })
    void testUriParts(
        String input,
        String scheme, String host, int port,
        String path, String fragment, String query,
        String rawPath, String rawQuery, String raw) {

      URIDataAdapter adapter =
          URIDataAdapterBase.fromURI(input, this::adapter);

      // test
    }
  }

  @Nested
  class URIDefaultDataAdapterTest extends AdapterContract {

    @Override
    URIDataAdapter adapter(URI uri) {
      return new URIDefaultDataAdapter(uri);
    }
  }

  @Nested
  class URIRawDataAdapterTest extends AdapterContract {

    @Override
    URIDataAdapter adapter(URI uri) {
      return new RawTestAdapter(uri);
    }
  }

  @Nested
  class URINoRawDataAdapterTest extends AdapterContract {

    @Override
    URIDataAdapter adapter(URI uri) {
      return new NoRawTestAdapter(uri);
    }

    @Override
    boolean supportsRaw() {
      return false;
    }
  }

  @Nested
  class UnparseableURIAdapterTest {

    @Test
    void shouldReturnRawUriOnly() {
      UnparseableURIDataAdapter adapter =
          new UnparseableURIDataAdapter(
              "http://myurl/path?query=value#fragment");

      // test
    }
  }

  static class RawTestAdapter extends URIRawDataAdapter {

    private final URI uri;

    RawTestAdapter(URI uri) {
      this.uri = uri;
    }

    // test
  }

  static class NoRawTestAdapter extends URIDataAdapterBase {

    private final URI uri;

    NoRawTestAdapter(URI uri) {
      this.uri = uri;
    }

    // test
  }
}

Comment on lines +65 to +81
"too few characters | '%' | '�' ",
"too few characters after one digit | '%1' | '�' ",
"illegal 1st character | '%W1' | '�' ",
"illegal 2nd character | '%1X' | '�' ",
"illegal 1st character in word | 'wh%Y1t' | 'wh�t' ",
"illegal 2nd character in word | 'wh%1Zt' | 'wh�t' ",
"too few characters at end | 'wh%' | 'wh�' ",
"too few characters after one digit at end | 'wh%1' | 'wh�' ",
"invalid 2 byte sequence | '%C3%28' | '�(' ",
"invalid sequence identifier | '%A0%A1' | '��' ",
"invalid 3 byte sequence in 2nd byte | '%E2%28%A1' | '�(�' ",
"invalid 3 byte sequence in 3rd byte | '%E2%82%28' | '�(' ",
"invalid 4 byte sequence in 2nd byte | '%F0%28%8C%BC' | '�(��' ",
"invalid 4 byte sequence in 3rd byte | '%F0%90%28%BC' | '�(�' ",
"invalid 4 byte sequence in 4th byte | '%F0%28%8C%28' | '�(�(' ",
"valid 5 byte sequence but not unicode | '%F8%A1%A1%A1%A1' | '�����' ",
"valid 6 byte sequence but not unicode | '%FC%A1%A1%A1%A1%A1' | '������' "

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.

quibble (if-minor): I know it was there before, but I wonder if it could be safer to use escaped chars here.

This branch has not been deployed

No deployments
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 type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants