Skip to content

Commit f6faa48

Browse files
committed
use builder
1 parent afcc739 commit f6faa48

17 files changed

+136
-409
lines changed

smoke-tests/src/main/java/io/opentelemetry/smoketest/SmokeTestInstrumentationExtension.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
1111
import io.opentelemetry.smoketest.windows.WindowsTestContainerManager;
1212
import io.opentelemetry.testing.internal.armeria.client.WebClient;
13+
import java.io.IOException;
1314
import java.time.Duration;
1415
import java.util.HashMap;
1516
import java.util.List;
1617
import java.util.Map;
1718
import java.util.function.Function;
19+
import java.util.jar.Attributes;
20+
import java.util.jar.JarFile;
1821
import javax.annotation.Nullable;
1922
import org.junit.jupiter.api.extension.ExtensionContext;
2023

@@ -116,8 +119,15 @@ public void afterEach(ExtensionContext context) throws Exception {
116119
super.afterEach(context);
117120
}
118121

119-
public String getAgentPath() {
120-
return agentPath;
122+
public String getAgentImplementationVersion() {
123+
try (JarFile agentJar = new JarFile(agentPath)) {
124+
return agentJar
125+
.getManifest()
126+
.getMainAttributes()
127+
.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
128+
} catch (IOException e) {
129+
throw new IllegalStateException(e);
130+
}
121131
}
122132

123133
public SmokeTestOutput start(int jdk) {

smoke-tests/src/test/java/io/opentelemetry/smoketest/AgentDebugLoggingTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
import org.junit.jupiter.api.DisplayName;
1010
import org.junit.jupiter.api.Test;
1111
import org.junit.jupiter.api.condition.DisabledIf;
12+
import org.junit.jupiter.api.extension.RegisterExtension;
1213

1314
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
14-
class AgentDebugLoggingTest extends JavaSmokeTest {
15+
class AgentDebugLoggingTest {
1516

16-
public AgentDebugLoggingTest() {
17-
super(
18-
SmokeTestTarget.springBoot("20250915.17728045097")
19-
.waitStrategy(
20-
new TargetWaitStrategy.Log(
21-
Duration.ofMinutes(1),
22-
".*DEBUG io.opentelemetry.javaagent.tooling.VersionLogger.*")));
23-
}
17+
@RegisterExtension
18+
static final SmokeTestInstrumentationExtension testing =
19+
SmokeTestInstrumentationExtension.springBoot("20250915.17728045097")
20+
.waitStrategy(
21+
new TargetWaitStrategy.Log(
22+
Duration.ofMinutes(1),
23+
".*DEBUG io.opentelemetry.javaagent.tooling.VersionLogger.*"))
24+
.build();
2425

2526
@DisplayName("verifies that debug logging is working by checking for a debug log on startup")
2627
@Test
2728
void verifyLogging() {
28-
startTarget(8);
29+
testing.start(8);
2930
}
3031
}

smoke-tests/src/test/java/io/opentelemetry/smoketest/DeclarativeConfigurationSmokeTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
1414
import io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes;
1515
import org.junit.jupiter.api.condition.DisabledIf;
16+
import org.junit.jupiter.api.extension.RegisterExtension;
1617
import org.junit.jupiter.params.ParameterizedTest;
1718
import org.junit.jupiter.params.provider.ValueSource;
1819

1920
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
20-
class DeclarativeConfigurationSmokeTest extends JavaSmokeTest {
21-
22-
public DeclarativeConfigurationSmokeTest() {
23-
super(
24-
SmokeTestTarget.springBoot("20241021.11448062567")
25-
.env("OTEL_EXPERIMENTAL_CONFIG_FILE", "declarative-config.yaml")
26-
.extraResources(
27-
ResourceMapping.of("declarative-config.yaml", "/declarative-config.yaml")));
28-
}
21+
class DeclarativeConfigurationSmokeTest {
22+
23+
@RegisterExtension
24+
static final SmokeTestInstrumentationExtension testing =
25+
SmokeTestInstrumentationExtension.springBoot("20241021.11448062567")
26+
.env("OTEL_EXPERIMENTAL_CONFIG_FILE", "declarative-config.yaml")
27+
.extraResources(ResourceMapping.of("declarative-config.yaml", "/declarative-config.yaml"))
28+
.build();
2929

3030
@ParameterizedTest
3131
@ValueSource(ints = {8, 11, 17})
3232
void springBootSmokeTest(int jdk) {
33-
startTarget(jdk);
33+
testing.start(jdk);
3434

35-
client().get("/greeting").aggregate().join();
35+
testing.client().get("/greeting").aggregate().join();
3636

3737
// There is one span (io.opentelemetry.opentelemetry-instrumentation-annotations-1.16 is
3838
// not used, because instrumentation_mode=none)

smoke-tests/src/test/java/io/opentelemetry/smoketest/JavaSmokeTest.java

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

smoke-tests/src/test/java/io/opentelemetry/smoketest/LogsSmokeTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
import io.opentelemetry.sdk.logs.data.LogRecordData;
1111
import java.util.Collection;
1212
import org.junit.jupiter.api.condition.DisabledIf;
13+
import org.junit.jupiter.api.extension.RegisterExtension;
1314
import org.junit.jupiter.params.ParameterizedTest;
1415
import org.junit.jupiter.params.provider.ValueSource;
1516

1617
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
17-
class LogsSmokeTest extends JavaSmokeTest {
18+
class LogsSmokeTest {
1819

19-
public LogsSmokeTest() {
20-
super(SmokeTestTarget.springBoot("20211213.1570880324"));
21-
}
20+
@RegisterExtension
21+
static final SmokeTestInstrumentationExtension testing =
22+
SmokeTestInstrumentationExtension.springBoot("20211213.1570880324").build();
2223

2324
@ParameterizedTest
2425
@ValueSource(ints = {8, 11, 17})
2526
void shouldExportLogs(int jdk) {
26-
startTarget(jdk);
27-
client().get("/greeting").aggregate().join();
27+
testing.start(jdk);
28+
testing.client().get("/greeting").aggregate().join();
2829
Collection<LogRecordData> logs = testing.logRecords();
2930

3031
assertThat(logs).isNotEmpty();

smoke-tests/src/test/java/io/opentelemetry/smoketest/QuarkusSmokeTest.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,31 @@
88
import io.opentelemetry.semconv.ServiceAttributes;
99
import io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes;
1010
import java.time.Duration;
11-
import java.util.jar.Attributes;
12-
import java.util.jar.JarFile;
1311
import org.junit.jupiter.api.condition.DisabledIf;
12+
import org.junit.jupiter.api.extension.RegisterExtension;
1413
import org.junit.jupiter.params.ParameterizedTest;
1514
import org.junit.jupiter.params.provider.ValueSource;
1615

1716
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
18-
class QuarkusSmokeTest extends JavaSmokeTest {
17+
class QuarkusSmokeTest {
1918

20-
public QuarkusSmokeTest() {
21-
super(
22-
SmokeTestTarget.builder(
23-
jdk ->
24-
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-quarkus:jdk"
25-
+ jdk
26-
+ "-20250915.17728045126")
27-
.waitStrategy(new TargetWaitStrategy.Log(Duration.ofMinutes(1), ".*Listening on.*"))
28-
.setServiceName(false));
29-
}
19+
@RegisterExtension
20+
static final SmokeTestInstrumentationExtension testing =
21+
SmokeTestInstrumentationExtension.builder(
22+
jdk ->
23+
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-quarkus:jdk"
24+
+ jdk
25+
+ "-20250915.17728045126")
26+
.waitStrategy(new TargetWaitStrategy.Log(Duration.ofMinutes(1), ".*Listening on.*"))
27+
.setServiceName(false)
28+
.build();
3029

3130
@ParameterizedTest
3231
@ValueSource(ints = {17, 21, 23}) // Quarkus 3.7+ requires Java 17+
3332
void quarkusSmokeTest(int jdk) throws Exception {
34-
startTarget(jdk);
35-
String currentAgentVersion;
36-
try (JarFile agentJar = new JarFile(agentPath)) {
37-
currentAgentVersion =
38-
agentJar
39-
.getManifest()
40-
.getMainAttributes()
41-
.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
42-
}
33+
testing.start(jdk);
4334

44-
client().get("/hello").aggregate().join();
35+
testing.client().get("/hello").aggregate().join();
4536

4637
testing.waitAndAssertTraces(
4738
trace ->
@@ -53,7 +44,7 @@ void quarkusSmokeTest(int jdk) throws Exception {
5344
resource
5445
.hasAttribute(
5546
TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION,
56-
currentAgentVersion)
47+
testing.getAgentImplementationVersion())
5748
.hasAttribute(ServiceAttributes.SERVICE_NAME, "quarkus");
5849
})));
5950
}

smoke-tests/src/test/java/io/opentelemetry/smoketest/SecurityManagerSmokeTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66
package io.opentelemetry.smoketest;
77

88
import org.junit.jupiter.api.condition.DisabledIf;
9+
import org.junit.jupiter.api.extension.RegisterExtension;
910
import org.junit.jupiter.params.ParameterizedTest;
1011
import org.junit.jupiter.params.provider.ValueSource;
1112

1213
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
13-
class SecurityManagerSmokeTest extends JavaSmokeTest {
14+
class SecurityManagerSmokeTest {
1415

15-
public SecurityManagerSmokeTest() {
16-
super(
17-
SmokeTestTarget.builder(
18-
jdk ->
19-
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-security-manager:jdk"
20-
+ jdk
21-
+ "-20250915.17728045123")
22-
.env("OTEL_JAVAAGENT_EXPERIMENTAL_SECURITY_MANAGER_SUPPORT_ENABLED", "true"));
23-
}
16+
@RegisterExtension
17+
static final SmokeTestInstrumentationExtension testing =
18+
SmokeTestInstrumentationExtension.builder(
19+
jdk ->
20+
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-security-manager:jdk"
21+
+ jdk
22+
+ "-20250915.17728045123")
23+
.env("OTEL_JAVAAGENT_EXPERIMENTAL_SECURITY_MANAGER_SUPPORT_ENABLED", "true")
24+
.build();
2425

2526
@ParameterizedTest
2627
@ValueSource(ints = {8, 11, 17, 21, 23})
2728
void securityManagerSmokeTest(int jdk) {
28-
startTarget(jdk);
29+
testing.start(jdk);
2930
testing.waitAndAssertTraces(
3031
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasName("test")));
3132
}

smoke-tests/src/test/java/io/opentelemetry/smoketest/SmokeTestOutput.java

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

0 commit comments

Comments
 (0)