Skip to content

Commit 364ba98

Browse files
authored
Merge branch 'master' into jb/oome_script
2 parents 620ffe3 + fd65c0a commit 364ba98

27 files changed

Lines changed: 460 additions & 466 deletions

File tree

.claude/skills/migrate-groovy-to-java/SKILL.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Migrate test Groovy files to Java using JUnit 5
1616

1717
When converting Groovy code to Java code, make sure that:
1818
- The Java code generated is compatible with JDK 8
19-
- When translating Spock tests, favor using `@CsvSource` with `|` delimiters
20-
- When using `@MethodSource`, name the arguments method by appending `Arguments` using camelCase to the test method name (e.g. `testMethodArguments`) and return a `Stream` of arguments using `Stream.of(...)` and `arguments(...)` with static import.
19+
- When translating Spock tests, prefer `@TableTest` for data rows that are naturally tabular. See detailed guidance in the "TableTest usage" section.
20+
- `@TableTest` and `@MethodSource` may be combined on the same `@ParameterizedTest` when most cases are tabular but a few cases require programmatic setup.
21+
- In combined mode, keep table-friendly cases in `@TableTest`, and put only non-tabular/complex cases in `@MethodSource`.
22+
- If `@TableTest` is not viable for the test at all, use `@MethodSource` only.
23+
- For `@MethodSource`, name the arguments method `<testMethodName>Arguments` (camelCase, e.g. `testMethodArguments`) and return `Stream<Arguments>` using `Stream.of(...)` and `arguments(...)` with static import.
2124
- Ensure parameterized test names are human-readable (i.e. no hashcodes); instead add a description string as the first `Arguments.arguments(...)` value or index the test case
2225
- When converting tuples, create a light dedicated structure instead to keep the typing system
2326
- Instead of checking a state and throwing an exception, use JUnit asserts
@@ -27,3 +30,35 @@ When converting Groovy code to Java code, make sure that:
2730
- Do not mark local variables `final`
2831
- Ensure variables are human-readable; avoid single-letter names and pre-define variables that are referenced multiple times
2932
- When translating Spock `Mock(...)` usage, use `libs.bundles.mockito` instead of writing manual recording/stub implementations
33+
34+
TableTest usage
35+
Dependency, if missing add:
36+
- Groovy: testImplementation libs.tabletest
37+
- Kotlin: testImplementation(libs.tabletest)
38+
39+
Import: `import org.tabletest.junit.TableTest;`
40+
41+
JDK 8 rules:
42+
- No text blocks.
43+
- @TableTest must use String[] annotation array syntax:
44+
```
45+
@TableTest({
46+
"a | b",
47+
"1 | 2"
48+
})
49+
```
50+
51+
Spock `where:`@TableTest:
52+
- First row = header (column names = method parameters).
53+
- Add `scenario` column as first column (display name, not a method parameter).
54+
- Use `|` delimiter; align columns so pipes line up vertically.
55+
- Prefer single quotes for strings with special chars (e.g., `'a|b'`, `'[]'`).
56+
- Blank cell = null (object types); `''` = empty string.
57+
- Collections: `[a, b]` = List/array, `{a, b}` = Set, `[k: v]` = Map.
58+
59+
Mixed eligibility:
60+
- Prefer combining `@TableTest` + `@MethodSource` on one `@ParameterizedTest` when only some cases are complex.
61+
- Use `@MethodSource` only when tabular representation is not practical for the test.
62+
63+
Do NOT use @TableTest when:
64+
- Majority of rows require complex objects or custom converters.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: migrate-junit-source-to-tabletest
3+
description: Convert JUnit 5 @MethodSource/@CsvSource/@ValueSource parameterized tests to @TableTest (JDK8)
4+
---
5+
Goal: Migrate JUnit 5 parameterized tests using @MethodSource/@CsvSource/@ValueSource to @TableTest with minimal churn and passing tests.
6+
7+
Process (do in this order):
8+
1) Locate targets via Grep (no agent subprocess). Search for: "@ParameterizedTest", "@MethodSource", "@CsvSource", "@ValueSource".
9+
2) Read all matching files up front (parallel is OK).
10+
3) Convert eligible tests to @TableTest.
11+
4) Write each modified file once in full using Write (no incremental per-test edits).
12+
5) Run module tests once and verify "BUILD SUCCESSFUL". If failed, inspect JUnit XML report.
13+
14+
Dependency:
15+
- If missing, add:
16+
- Groovy: testImplementation libs.tabletest
17+
- Kotlin: testImplementation(libs.tabletest)
18+
19+
Import: `import org.tabletest.junit.TableTest;`
20+
21+
JDK 8 rules:
22+
- No text blocks.
23+
- @TableTest must use String[] annotation array syntax:
24+
```
25+
@TableTest({
26+
"a | b",
27+
"1 | 2"
28+
})
29+
```
30+
31+
Table formatting rules (mandatory):
32+
- Always include a header row (parameter names).
33+
- Always add a "scenario" column; using common sense for naming; scenario is NOT a method parameter.
34+
- Use '|' as delimiter.
35+
- Align columns with spaces so pipes line up vertically.
36+
- Prefer single quotes for strings requiring quotes (e.g., 'a|b', '[]', '{}', ' ').
37+
38+
Conversions:
39+
A) @CsvSource
40+
- Remove @ParameterizedTest and @CsvSource.
41+
- If delimiter is '|': rows map directly to @TableTest.
42+
- If delimiter is ',' (default): replace ',' with '|' in rows.
43+
44+
B) @ValueSource
45+
- Convert to @TableTest with header from parameter name.
46+
- Each value becomes one row.
47+
- Add "scenario" column using common sense for name.
48+
49+
C) @MethodSource (convert only if values are representable as strings)
50+
- Convert when argument values are primitives, strings, enums, booleans, nulls, and simple collection literals supported by TableTest:
51+
- Array: [a, b, ...]
52+
- List: [a, b, ...]
53+
- Set: {a, b, ...}
54+
- Map: [k: v, ...]
55+
- `@TableTest` and `@MethodSource` may be combined on the same `@ParameterizedTest` when most cases are tabular but a few cases require programmatic setup.
56+
- In combined mode, keep table-friendly cases in `@TableTest`, and put only non-tabular/complex cases in `@MethodSource`.
57+
- If `@TableTest` is not viable for the test at all, use `@MethodSource` only.
58+
- For `@MethodSource`, name the arguments method `<testMethodName>Arguments` (camelCase, e.g. `testMethodArguments`) and return `Stream<Arguments>` using `Stream.of(...)` and `arguments(...)` with static import.
59+
- Blank cell = null (non-primitive).
60+
- '' = empty string.
61+
- For String params that start with '[' or '{', quote to avoid collection parsing (prefer '[]'/'{}').
62+
63+
Scenario handling:
64+
- If MethodSource includes a leading description string OR @ParameterizedTest(name=...) uses {0}, convert that to a scenario column and remove that parameter from method signature.
65+
66+
Cleanup:
67+
- Delete now-unused @MethodSource provider methods and unused imports.
68+
69+
Mixed eligibility:
70+
- Prefer combining `@TableTest` + `@MethodSource` on one `@ParameterizedTest` when only some cases are complex.
71+
72+
Do NOT convert when:
73+
- Most rows require complex builders/mocks.
74+
75+
Test command (exact):
76+
./gradlew :path:to:module:test --rerun-tasks 2>&1 | tail -20
77+
- If BUILD FAILED: cat path/to/module/build/test-results/test/TEST-*.xml

.github/workflows/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,6 @@ Close them if no following update within a week.
9191

9292
_Recovery:_ Manually trigger the action again.
9393

94-
### update-docker-build-image [🔗](update-docker-build-image.yaml)
95-
96-
_Trigger:_ Quarterly released, loosely [a day after the new image tag is created](https://github.com/DataDog/dd-trace-java-docker-build/blob/master/.github/workflows/docker-tag.yml).
97-
98-
_Action:_ Update the Docker build image used in GitLab CI with the latest tag.
99-
100-
_Recovery:_ Download artifacts and upload them manually to the related _download release_.
101-
102-
_Notes:_ Manually trigger the action again given the desired image tag as input.
103-
10494
### update-download-releases [🔗](update-download-releases.yaml)
10595

10696
_Trigger:_ When a release is published.

.github/workflows/update-docker-build-image.yaml

Lines changed: 0 additions & 96 deletions
This file was deleted.

.gitlab-ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ variables:
2929
GRADLE_VERSION: "8.14.4" # must match gradle-wrapper.properties
3030
MAVEN_REPOSITORY_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
3131
GRADLE_PLUGIN_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
32-
BUILDER_IMAGE_VERSION_PREFIX: "v26.02-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
32+
BUILDER_IMAGE_REPO: "registry.ddbuild.io/images/mirror/dd-trace-java-docker-build" # images are pinned in images/mirror.lock.yaml in the DataDog/images repo
33+
BUILDER_IMAGE_VERSION_PREFIX: "ci-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "ci-" or "123_merge-")
3334
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
3435
DEFAULT_TEST_JVMS: /^(8|11|17|21|25|tip)$/ # the latest "tip" version is 26
3536
PROFILE_TESTS:
@@ -142,7 +143,7 @@ default:
142143
fi
143144
144145
.gradle_build: &gradle_build
145-
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
146+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
146147
stage: build
147148
variables:
148149
MAVEN_OPTS: "-Xms256M -Xmx1024M"
@@ -218,7 +219,7 @@ default:
218219
# on the central publisher portal, it invalidates the old one. This check prevents going further.
219220
# See https://datadoghq.atlassian.net/wiki/x/Oog5OgE
220221
maven-central-pre-release-check:
221-
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
222+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
222223
stage: .pre
223224
rules:
224225
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
@@ -399,7 +400,7 @@ config-inversion-linter:
399400

400401
test_published_artifacts:
401402
extends: .gradle_build
402-
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}7 # Needs Java7 for some tests
403+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}7 # Needs Java7 for some tests
403404
stage: tests
404405
needs: [ build ]
405406
variables:
@@ -566,7 +567,7 @@ muzzle-dep-report:
566567

567568
.test_job:
568569
extends: .gradle_build
569-
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}$testJvm
570+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}$testJvm
570571
tags: [ "docker-in-docker:amd64" ] # use docker-in-docker runner for testcontainers
571572
needs: [ build_tests ]
572573
stage: tests
@@ -794,7 +795,7 @@ test_smoke_semeru8_debugger:
794795
testJvm: "semeru8"
795796

796797
aggregate_test_counts:
797-
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
798+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
798799
stage: test-summary
799800
# Note: No explicit 'needs' or 'dependencies' required
800801
# By default, GitLab CI automatically downloads artifacts from ALL jobs in previous stages

components/json/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ apply(from = "$rootDir/gradle/java.gradle")
77
jmh {
88
jmhVersion = libs.versions.jmh.get()
99
}
10+
11+
dependencies {
12+
testImplementation(libs.tabletest)
13+
}

0 commit comments

Comments
 (0)