Skip to content

Share test fixtures through java-test-fixtures and one capture codec module - #20

Merged
lhotari merged 1 commit into
mainfrom
test-fixtures
Sep 24, 2026
Merged

lhotari merged 1 commit into
mainfrom
test-fixtures

Conversation

@lhotari

@lhotari lhotari commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Why

Test helpers lived inside test classes, so tests called into other test classes, the integration suite compiled against the unit tests' output, and the agent and the correlator each carried a copy of the fixture that encodes capture stream records. Each Java module also generated its own copy of the capture codec from docs/schema.

What changes

Test fixtures. Every module applies Gradle's java-test-fixtures plugin through jonoffcpu.java-conventions. src/testFixtures holds what the suites share:

  • fixture builders and JFR event types, including helpers extracted from test classes: CorrelationFixture (from OfflineCorrelatorTest), CommandLineFixture (from CommandLineTest), ExportFixture (from ExportTest);
  • the *Workload and *Check main classes the integration tests and proof tools launch, and the C helpers in src/testFixtures/c.

Fixtures may use AssertJ; the fixture variants are never published.

One capture codec. A new unpublished jonoffcpu-capture-codec module owns src/main/proto/jonoffcpu-capture.proto and generates the Java codec once. The agent and the correlator embed it through embeddedRuntime and relocate its protobuf runtime as before; the correlator generates only its own profile schema, now in jonoffcpu-correlator/src/main/proto. The duplicated JSON-row encoder is one CaptureRecordFixture in the codec module's test fixtures, used through testFixtures(project(":jonoffcpu-capture-codec")). The Rust collector's build.rs and both native-bundle Dockerfiles read the schema from its new location, and the native bundle build lists it as an input.

Shaded modules. The plain JAR used to be disabled and shared the shaded JAR's file name, so any in-build consumer of the module's ordinary variant got the relocated JAR. It now has a plain classifier and declares its unrelocated libraries; it is not published. Only external embedded libraries are checked against pinned digests. CI's shaded-JAR selection skips *-test-fixtures.jar.

Docs. CODING.md documents the fixture conventions; AGENTS.md, the READMEs and OFFLINE.md point at the new schema locations and module.

Verification

  • A clean ./gradlew check passes with the same test counts as before: agent 80 unit, packaged-JAR and the host-native container tests; correlator 183 unit, 19 integration, packaged-JAR and scale tests. A second run reuses the configuration cache.
  • Both shaded JARs embed CaptureProto once with protobuf relocated; only the correlator's has ProfileProto. No publication references the codec module, fixtures or plain JARs.
  • The musl and glibc arm64 native bundles build in Docker from the moved schema.
  • The privileged-container end-to-end tests ran only where CI has Linux.

The proof tools under jonoffcpu-native/tools/ still reference a make all test-java step and build/test-classes, which the Gradle build no longer has; only their C helper paths are updated here.

…module

Move everything the tests use but that is not a test into each module's
`src/testFixtures`, with Gradle's java-test-fixtures plugin: fixture
builders, JFR event types, the command-line and export helpers, and the
workloads and checks that tests and proof tools launch. Helpers that
other test classes called inside OfflineCorrelatorTest, CommandLineTest
and ExportTest become CorrelationFixture, CommandLineFixture and
ExportFixture. The fixture variants are never published.

The capture stream's Java codec is now generated once, in a new
unpublished jonoffcpu-capture-codec module that owns
src/main/proto/jonoffcpu-capture.proto; the agent and the correlator
embed it through embeddedRuntime and relocate its protobuf runtime as
before, and the correlator generates only its own profile schema from
src/main/proto. The fixture that encodes JSON rows as stream records,
duplicated in both modules, is one CaptureRecordFixture in the codec
module's test fixtures. The Rust collector and both native-bundle
Dockerfiles read the schema from its new location, and the native build
now lists it as an input.

The plain JAR of a shaded module gets a `plain` classifier and declares
its unrelocated libraries, so consumers inside the build no longer
resolve the shaded JAR in its place; only external embedded libraries
are checked against pinned digests. CODING.md documents the fixture
conventions.
@lhotari
lhotari merged commit eea5de0 into main Sep 24, 2026
5 checks passed
lhotari added a commit that referenced this pull request Sep 24, 2026
@lhotari
lhotari deleted the test-fixtures branch September 24, 2026 13:11
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