-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathGrpcSmokeTest.java
More file actions
64 lines (56 loc) · 2.39 KB
/
Copy pathGrpcSmokeTest.java
File metadata and controls
64 lines (56 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.smoketest;
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_VERSION;
import static org.assertj.core.api.Assertions.assertThat;
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 java.time.Duration;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
class GrpcSmokeTest extends AbstractSmokeTest<Integer> {
@Override
protected void configure(SmokeTestOptions<Integer> options) {
options
.image(
jdk ->
String.format(
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-grpc:jdk%s-%s",
jdk, TestImageVersions.GRPC_VERSION))
.waitStrategy(new TargetWaitStrategy.Log(Duration.ofMinutes(1), ".*Server started.*"));
}
@ParameterizedTest
@ValueSource(ints = {8, 11, 17, 21, 25})
void grpcSmokeTest(int jdk) {
SmokeTestOutput output = start(jdk);
ManagedChannel channel = null;
try {
channel =
ManagedChannelBuilder.forAddress("localhost", getMappedPort(8080)).usePlaintext().build();
TraceServiceGrpc.TraceServiceBlockingStub stub = TraceServiceGrpc.newBlockingStub(channel);
stub.export(ExportTraceServiceRequest.getDefaultInstance());
testing.waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName("opentelemetry.proto.collector.trace.v1.TraceService/Export")
.hasResourceSatisfying(
resource ->
resource.hasAttribute(
TELEMETRY_DISTRO_VERSION, getAgentVersion())),
span -> span.hasName("TestService.withSpan")));
// Verify correct traceIds are logged via MDC instrumentation
assertThat(output.getLoggedTraceIds()).isEqualTo(getSpanTraceIds());
} finally {
if (channel != null) {
channel.shutdown();
}
}
}
}