-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
217 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
79 changes: 73 additions & 6 deletions
79
...sion/src/test/java/com/digma/otel/javaagent/extension/smoketest/GrpcIntegrationTests.java
This file contains 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 |
---|---|---|
@@ -1,20 +1,87 @@ | ||
package com.digma.otel.javaagent.extension.smoketest; | ||
|
||
import com.digma.otel.javaagent.extension.AgentExtensionVersion; | ||
import io.grpc.ManagedChannel; | ||
import io.grpc.ManagedChannelBuilder; | ||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; | ||
import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.containers.wait.strategy.WaitStrategy; | ||
|
||
public class GrpcIntegrationTests extends AllJdksParameterizedTest{ | ||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.Collection; | ||
import java.util.jar.Attributes; | ||
import java.util.jar.JarFile; | ||
|
||
//todo : complete , | ||
// see https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5df8a5a0a0e90fc7a867f8f013bd050f132a090b/smoke-tests | ||
public class GrpcIntegrationTests extends AllJdksParameterizedTest{ | ||
|
||
@Override | ||
protected String getTargetImage(int jdk) { | ||
//todo: find the tag | ||
return "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-grpc:jdk"; | ||
return "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-grpc:jdk" | ||
+ jdk | ||
+ "-20230228.4289437270"; | ||
} | ||
|
||
@Override | ||
protected WaitStrategy getTargetWaitStrategy() { | ||
return null; | ||
return Wait.forLogMessage(".*Server started.*", 1) | ||
.withStartupTimeout(Duration.ofMinutes(1)); | ||
} | ||
|
||
@TestAllJdks | ||
public void extensionsAreLoadedFromJar(int jdk) throws IOException, InterruptedException { | ||
startTarget("/opentelemetry-extensions.jar", jdk); | ||
|
||
testAndVerify(); | ||
|
||
stopTarget(); | ||
} | ||
|
||
|
||
@TestAllJdks | ||
public void extensionsAreLoadedFromFolder(int jdk) throws IOException, InterruptedException { | ||
startTarget("/", jdk); | ||
|
||
testAndVerify(); | ||
|
||
stopTarget(); | ||
} | ||
|
||
@TestAllJdks | ||
public void extensionsAreLoadedFromJavaagent(int jdk) throws IOException, InterruptedException { | ||
startTargetWithExtendedAgent(jdk); | ||
|
||
testAndVerify(); | ||
|
||
stopTarget(); | ||
} | ||
|
||
|
||
|
||
|
||
private void testAndVerify() throws IOException, InterruptedException { | ||
|
||
ManagedChannel managedChannel = ManagedChannelBuilder.forAddress("localhost",target.getMappedPort(8080)) | ||
.usePlaintext() | ||
.build(); | ||
TraceServiceGrpc.TraceServiceBlockingStub stub = TraceServiceGrpc.newBlockingStub(managedChannel); | ||
stub.export(ExportTraceServiceRequest.getDefaultInstance()); | ||
|
||
String currentAgentVersion = (String) new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION); | ||
|
||
Collection<ExportTraceServiceRequest> traces = waitForTraces(); | ||
|
||
|
||
Assertions.assertEquals(1, countSpansByName(traces, "opentelemetry.proto.collector.trace.v1.TraceService/Export")); | ||
Assertions.assertEquals(1, countSpansByName(traces, "TestService.withSpan")); | ||
|
||
Assertions.assertEquals(1, countSpansByAttributeValue(traces, "code.function", "export")); | ||
Assertions.assertEquals(2, countSpansByAttributeValue(traces, "code.namespace", "io.opentelemetry.smoketest.grpc.TestService")); | ||
|
||
Assertions.assertEquals(2, countResourcesByValue(traces, "digma.agent.version", AgentExtensionVersion.VERSION)); | ||
Assertions.assertNotEquals( | ||
0, countResourcesByValue(traces, "telemetry.distro.version", currentAgentVersion)); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.