-
Notifications
You must be signed in to change notification settings - Fork 1k
convert groovy smoke tests to java, part 1 #14648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
laurit
merged 16 commits into
open-telemetry:main
from
zeitlinger:convert-groovy-smoke-tests-to-java
Sep 16, 2025
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0e913af
convert groovy smoke tests to java
zeitlinger a7c48f6
convert groovy smoke tests to java
zeitlinger d6d7322
convert groovy smoke tests to java
zeitlinger 80278bd
convert groovy smoke tests to java
zeitlinger b83306a
convert groovy smoke tests to java
zeitlinger e357f58
convert groovy smoke tests to java
zeitlinger 959f4a5
convert groovy smoke tests to java
zeitlinger 301ce8e
convert groovy smoke tests to java
zeitlinger 5300d52
quarkus
zeitlinger 6999a3d
format
zeitlinger 2c9ac75
fix
zeitlinger 2ed4ddb
pr review
zeitlinger 5e8f1d2
pr review
zeitlinger 745bab1
fix shading
laurit 8cb9615
review
laurit 0fcfaff
rename variable
laurit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/AgentDebugLoggingTest.groovy
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/LogsSmokeTest.groovy
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/QuarkusSmokeTest.groovy
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/SecurityManagerSmokeTest.groovy
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
smoke-tests/src/test/java/io/opentelemetry/smoketest/AgentDebugLoggingTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.smoketest; | ||
|
|
||
| import java.time.Duration; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.condition.DisabledIf; | ||
|
|
||
| @DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers") | ||
| class AgentDebugLoggingTest extends JavaSmokeTest { | ||
| @Override | ||
| protected String getTargetImage(String jdk) { | ||
| return "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-spring-boot:jdk" | ||
| + jdk | ||
| + "-20250915.17728045097"; | ||
| } | ||
|
|
||
| @Override | ||
| protected TargetWaitStrategy getWaitStrategy() { | ||
| return new TargetWaitStrategy.Log( | ||
| Duration.ofMinutes(1), ".*DEBUG io.opentelemetry.javaagent.tooling.VersionLogger.*"); | ||
| } | ||
|
|
||
| @DisplayName("verifies that debug logging is working by checking for a debug log on startup") | ||
| @Test | ||
| void verifyLogging() throws Exception { | ||
| withTarget(8, () -> {}); | ||
| } | ||
| } |
135 changes: 135 additions & 0 deletions
135
smoke-tests/src/test/java/io/opentelemetry/smoketest/JavaSmokeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.smoketest; | ||
|
|
||
| import static java.util.Collections.emptyList; | ||
| import static java.util.Collections.emptyMap; | ||
|
|
||
| import io.opentelemetry.sdk.logs.data.LogRecordData; | ||
| import io.opentelemetry.sdk.metrics.data.MetricData; | ||
| import io.opentelemetry.sdk.trace.data.SpanData; | ||
| import io.opentelemetry.smoketest.windows.WindowsTestContainerManager; | ||
| import io.opentelemetry.testing.internal.armeria.client.WebClient; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.function.Consumer; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.testcontainers.containers.output.OutputFrame; | ||
|
|
||
| public abstract class JavaSmokeTest { | ||
| protected static final TestContainerManager containerManager = createContainerManager(); | ||
| private JavaTelemetryRetriever telemetryRetriever; | ||
|
|
||
| protected String agentPath = | ||
| System.getProperty("io.opentelemetry.smoketest.agent.shadowJar.path"); | ||
|
|
||
| protected WebClient client() { | ||
| return WebClient.of("h1c://localhost:" + containerManager.getTargetMappedPort(8080)); | ||
| } | ||
|
|
||
| /** Subclasses can override this method to pass jvm arguments in another environment variable */ | ||
| protected String getJvmArgsEnvVarName() { | ||
| return "JAVA_TOOL_OPTIONS"; | ||
| } | ||
|
|
||
| /** Subclasses can override this method to customise target application's environment */ | ||
| protected Map<String, String> getExtraEnv() { | ||
| return emptyMap(); | ||
| } | ||
|
|
||
| /** Subclasses can override this method to disable setting default service name */ | ||
| protected boolean getSetServiceName() { | ||
| return true; | ||
| } | ||
|
|
||
| /** Subclasses can override this method to provide additional files to copy to target container */ | ||
| protected List<ResourceMapping> getExtraResources() { | ||
| return emptyList(); | ||
| } | ||
|
|
||
| /** | ||
| * Subclasses can override this method to provide additional ports that should be exposed from the | ||
| * target container | ||
| */ | ||
| protected List<Integer> getExtraPorts() { | ||
| return emptyList(); | ||
| } | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| containerManager.startEnvironmentOnce(); | ||
| telemetryRetriever = new JavaTelemetryRetriever(containerManager.getBackendMappedPort()); | ||
| } | ||
|
|
||
| public void withTarget(int jdk, TargetRunner runner) throws Exception { | ||
| startTarget(jdk); | ||
| try { | ||
| runner.runInTarget(); | ||
| } finally { | ||
| stopTarget(); | ||
| } | ||
| } | ||
|
|
||
| public Consumer<OutputFrame> startTarget(int jdk) { | ||
| return startTarget(String.valueOf(jdk), null, false); | ||
| } | ||
|
|
||
| public Consumer<OutputFrame> startTarget(String jdk, String serverVersion, boolean windows) { | ||
| String targetImage = getTargetImage(jdk, serverVersion, windows); | ||
| return containerManager.startTarget( | ||
| targetImage, | ||
| agentPath, | ||
| getJvmArgsEnvVarName(), | ||
| getExtraEnv(), | ||
| getSetServiceName(), | ||
| getExtraResources(), | ||
| getExtraPorts(), | ||
| getWaitStrategy(), | ||
| getCommand()); | ||
| } | ||
|
|
||
| protected abstract String getTargetImage(String jdk); | ||
|
|
||
| protected String getTargetImage(String jdk, String serverVersion, boolean windows) { | ||
| return getTargetImage(jdk); | ||
| } | ||
|
|
||
| protected TargetWaitStrategy getWaitStrategy() { | ||
| return null; | ||
| } | ||
|
|
||
| protected String[] getCommand() { | ||
| return null; | ||
| } | ||
|
|
||
| public void cleanup() { | ||
| telemetryRetriever.clearTelemetry(); | ||
| } | ||
|
|
||
| public void stopTarget() { | ||
| containerManager.stopTarget(); | ||
| cleanup(); | ||
| } | ||
|
|
||
| protected List<SpanData> waitForTraces() { | ||
| return telemetryRetriever.waitForTraces(); | ||
| } | ||
|
|
||
| protected Collection<MetricData> waitForMetrics() { | ||
| return telemetryRetriever.waitForMetrics(); | ||
| } | ||
|
|
||
| protected Collection<LogRecordData> waitForLogs() { | ||
| return telemetryRetriever.waitForLogs(); | ||
| } | ||
|
|
||
| private static TestContainerManager createContainerManager() { | ||
| return TestContainerManager.useWindowsContainers() | ||
| ? new WindowsTestContainerManager() | ||
| : new LinuxTestContainerManager(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really a fan of using the
Javaprefix, guess we can rename it back once all tests are convertedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, waiting for ideas here - cound also rename the groovy classes to have a "Legacy" prefix