Open Telemetry Auto Instrumentation's minimal supported version is java 8. All jar files that we produce, unless noted otherwise, have bytecode compatible with java 8 runtime. Our test suite is executed against java 8, all LTS versions and the latest non-LTS version.
Some libraries that we auto-instrument may have higher minimal requirements. In this case we compile and test corresponding auto-instrumentation with higher java version as required by library. The resulting classes will have higher bytecode level, but as it matches library's java version, no runtime problem arise.
Executing ./gradlew instrumentation:test
will run tests for all supported
auto-instrumentations using that java version which runs the Gradle build
itself. These tests usually use the minimal supported version of the
instrumented library.
We run all tests on Java 11 by default, along with Java 8 and 15. To run on the later, set the
testJavaVersion
Gradle property to the desired major version, e.g., ./gradlew test -PtestJavaVersion=8
,
./gradlew test -PtestJavaVersion=15
. If you don't have a JDK of these versions
installed, Gradle will automatically download it for you.
This is done as part of the nightly build in order to catch when a new version of a library is released that breaks our instrumentation tests.
To run these tests locally, add -PtestLatestDeps=true
to your existing gradlew
command line.
Executing ./gradlew :instrumentation:<INSTRUMENTATION_NAME>:test --tests <GROOVY TEST FILE NAME>
will run only the selected test.
During local development, you may want to ignore lint warnings when running tests.
To ignore warnings, formatting issues, or other non-fatal issues in tests, use
./gradlew test -Ddev=true -x spotlessCheck -x checkstyleMain
The dev
flag will ignore warnings in tests.
The smoke tests are not run as part of a global test
task run since they take a long time and are
not relevant for most contributions. Explicitly specify :smoke-tests:test
to run them.
If you need to run a specific smoke test suite:
./gradlew :smoke-tests:test -PsmokeTestSuite=payara
If you are on Windows and you want to run the tests using linux containers:
USE_LINUX_CONTAINERS=1 ./gradlew :smoke-tests:test -PsmokeTestSuite=payara
If you want to run a specific smoke test:
./gradlew :smoke-tests:test --tests '*SpringBootSmokeTest*'
Smoke tests for the OpenTelemetry Spring starter.
You can execute the tests in a JVM (./gradlew smoke-tests-otel-starter:test
) or as Spring native tests (./gradlew smoke-tests-otel-starter:nativeTest
).
To execute all the instrumentation tests runnable as GraalVM native executables:
./gradlew nativeTest
A Github workflow executes the native tests every day.
Some of the instrumentation tests (and all of the smoke tests) spin up docker containers via
testcontainers. If you run out of space, you may wish to prune
old containers, images and volumes using docker system prune --volumes
.
For some container environments, such as rootless Podman or a remotely hosted Docker, testcontainers may need additional configuration to successfully run the tests. The following environment variables can be used for configuration:
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
- The location of the Docker socket on the host. Default is /var/run/docker.sock
TESTCONTAINERS_HOST_OVERRIDE
- The hostname used for container-to-container communication. Default Docker is localhost
, but rootless Podman uses host.containers.internal
CI test logs are pretty big around 75MB. To make it easier to troubleshoot test failures, you can download the raw logs from the CI job and then look for
Publishing build scan...
in the logs. Copy the URL from the logs and open it in a browser. This will give you a nice view of the test execution breakdown.
Details
link in one of the failing CI jobs under Some checks were not successful
section of your PR.Setting
gear in the top right corner of the logs panel.Publishing build scan...
to find the URL.Unfortunately, the Build Scan service hosted via Develocity has an allowed size limits of the free build scans. Once you exceed the limit, then you won't be able to view the scan anymore. Then you can just use the raw logs to search for "FAILED" or "Task failed with an exception" to identify the failing tests.