Skip to content

build(test): pin Testcontainers images in the version catalog - #199

Open
adityamparikh wants to merge 4 commits into
apache:mainfrom
adityamparikh:build/pin-testcontainers-images
Open

adityamparikh wants to merge 4 commits into
apache:mainfrom
adityamparikh:build/pin-testcontainers-images

Conversation

@adityamparikh

@adityamparikh adityamparikh commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Stacked on #198; the first commit here is that PR's. Merge #198 first and this diff shrinks to the pinning commit.

Summary

Pins the Docker images the Testcontainers-based tests start to exact tags, declared once in gradle/libs.versions.toml:

test-image-solr = "solr:9.9.0-slim"
test-image-lgtm = "grafana/otel-lgtm:0.33.0"

Why

  • solr:9.9-slim was spelled out three times (twice in build.gradle.kts, once in TestcontainersConfiguration) and is a moving minor tag.
  • The LGTM image was latest; a cached latest on one machine was 0.28.0 while Docker Hub's was 0.33.0, so the same green run meant different images.

How the pins reach the tests

  • processTestResources expands them into src/test/resources/test-images.properties; tasks.withType<Test> also forwards them as the solr.test.image / lgtm.test.image system properties.
  • TestImages prefers a non-blank system property, so ./gradlew test -Dsolr.test.image=solr:9.4-slim and the CI compatibility matrix keep working, and falls back to the expanded resource otherwise (which keeps @Container static initialisers working where properties are not forwarded, e.g. processTestAot).
  • The resource is added to the native test binary with -H:IncludeResources.
  • TestImagesTest fails the build if either pin is missing, floats on latest, or is not an exact release tag. It reads the expanded resource through TestImages.pinned and never touches system properties, so it cannot interfere with a -D override in the same test JVM.
  • AGENTS.md and dev-docs/DEVELOPMENT.md point at the catalog instead of quoting a tag.

Bumping an image

Edit the two catalog entries. Dependabot's gradle ecosystem cannot resolve Docker tags in the catalog, so these stay manual.

Verification

./gradlew build on Java 25: 405 tests, 0 failures, 0 skipped. OtlpExportIntegrationTest 7/7 against grafana/otel-lgtm:0.33.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ

adityamparikh and others added 4 commits September 12, 2026 13:47
The class had been @disabled since #41 because starting the Grafana LGTM
Testcontainer threw a ClassNotFoundException for
org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP. The Jetty
pin has since moved with the SolrJ 10 bump, jetty-client 12.0.34 is on the
test runtime classpath and contains that class, and the container now
starts cleanly.

With the annotation removed, three methods failed with
AuthenticationCredentialsNotFoundException: the test calls @PreAuthorize
service methods directly, with no MCP request and hence no principal. Rather
than switch http.security.enabled off, the test authenticates its own thread
with a TestingAuthenticationToken in @beforeeach and clears it in
@AfterEach, so method security stays active while OTLP export is verified.

All seven methods pass; the build no longer reports any skipped tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019zJ9WA8nNyA5Yxb8ueM7vV
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Pin the Solr and Grafana LGTM images the tests start to exact tags,
solr:9.9.0-slim and grafana/otel-lgtm:0.33.0, declared once as
test-image-solr / test-image-lgtm in gradle/libs.versions.toml. Previously
the Solr default was spelled out three times and the LGTM image floated on
latest: the locally cached "latest" was 0.28.0 from May while Docker Hub's
had moved to 0.33.0, so the same test run meant different things on
different machines.

processTestResources expands the pins into test-images.properties and the
Gradle test tasks also forward them as system properties. A new TestImages
resolver prefers a non-blank -Dsolr.test.image / -Dlgtm.test.image, so the
Solr compatibility matrix keeps working, and falls back to the resource
otherwise; the resource is included in the native test binary explicitly.
TestImagesTest fails the build if a pin is missing, floats on latest, or is
not an exact release tag.

Verified: ./gradlew build 407 tests, 0 failures, 0 skipped;
./gradlew nativeTest -Pnative 405 tests, 0 failures, 138 skipped (Mockito).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019zJ9WA8nNyA5Yxb8ueM7vV
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
TestImagesTest cleared the real solr.test.image / lgtm.test.image system
properties, and Gradle runs every test class in one fork, so any container
started after it fell back to the catalog pin. The Solr compatibility matrix
in CI passes -Dsolr.test.image and could end up testing the pinned version
while reporting another. The pin-guard tests now read the expanded resource
through TestImages.pinned(key) and never touch system properties; the two
override tests that covered three lines of resolve() are dropped.

Also hoists the catalog pins to one declaration in build.gradle.kts, removes
the duplicate systemProperty forwarding on integrationTest (withType<Test>
already covers it), and stops the docs from demonstrating the moving
solr:9.9-slim tag as an override example.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…ticated

The class javadoc still said the test was disabled for a Jetty
ClassNotFoundException; that paragraph now describes the LGTM container and
the self-authenticated test thread. TestingAuthenticationToken's authorities
constructor already marks the token authenticated, so the explicit call goes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant