Skip to content

Commit

Permalink
W-15772721: Review Failing test (#13529)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsgonz authored May 29, 2024
1 parent 4ae95db commit 16132e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.mule.runtime.metrics.exporter.impl.utils.TestOpenTelemetryMeterExporterFactory;
import org.mule.runtime.metrics.exporter.impl.utils.TestServerRule;
import org.mule.runtime.metrics.impl.meter.DefaultMeter;
import org.mule.tck.junit4.rule.DynamicPort;
import org.mule.tck.probe.JUnitProbe;
import org.mule.tck.probe.PollingProber;

Expand All @@ -48,15 +49,14 @@
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.PullPolicy;
import org.testcontainers.utility.DockerImageName;

@Ignore("W-15586397")
public class OpenTelemetryMeterExporterConfigTestCase {

private static final int TIMEOUT_MILLIS = 30000;
Expand All @@ -82,14 +82,16 @@ public class OpenTelemetryMeterExporterConfigTestCase {
private LongCounter longCounter;
private GenericContainer<?> collector;

public static final String RECEIVER_PORT = "receiverPort";

@ClassRule
public static SelfSignedCertificateRule serverTls = new SelfSignedCertificateRule();

@ClassRule
public static SelfSignedCertificateRule clientTls = new SelfSignedCertificateRule();

@ClassRule
public static final TestServerRule server = new TestServerRule();
@Rule
public final TestServerRule server = new TestServerRule(new DynamicPort(RECEIVER_PORT));

@Before
public void before() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import static io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest.parseFrom;

import org.mule.tck.junit4.rule.DynamicPort;

import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -27,6 +29,12 @@

public class TestServerRule extends ServerRule {

private final DynamicPort port;

public TestServerRule(DynamicPort port) {
this.port = port;
}

private static final String GRPC_ENDPOINT_PATH = "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export";

private List<TestExportedMeter> metrics = new ArrayList<>();
Expand All @@ -48,7 +56,7 @@ protected void configure(ServerBuilder sb) {
}
});

sb.http(0);
sb.http(port.getNumber());
}

public void reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.mule.runtime.tracer.exporter.config.api.SpanExporterConfiguration;
import org.mule.runtime.tracer.exporter.impl.optel.config.OpenTelemetryAutoConfigurableSpanExporterConfiguration;
import org.mule.runtime.tracer.exporter.impl.optel.resources.SpanExporterConfiguratorException;
import org.mule.tck.junit4.rule.DynamicPort;
import org.mule.tck.probe.JUnitLambdaProbe;
import org.mule.tck.probe.PollingProber;

Expand Down Expand Up @@ -69,7 +70,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -78,14 +79,15 @@

@Feature(PROFILING)
@Story(OPEN_TELEMETRY_EXPORTER)
@Ignore("W-15586397")
public class OpenTelemetryExporterConfigTestCase {

public static final String TEST_SERVICE_NAME = "test-service-name";

private static final DockerImageName COLLECTOR_IMAGE =
DockerImageName.parse("otel/opentelemetry-collector:0.99.0");

public static final String RECEIVER_PORT = "receiverPort";

private static final Integer COLLECTOR_OTLP_GRPC_PORT = 4317;
private static final Integer COLLECTOR_OTLP_HTTP_PORT = 4318;
private static final Integer COLLECTOR_OTLP_GRPC_MTLS_PORT = 5317;
Expand All @@ -105,8 +107,8 @@ public class OpenTelemetryExporterConfigTestCase {
@ClassRule
public static SelfSignedCertificateRule clientTls = new SelfSignedCertificateRule();

@ClassRule
public static final GrpcServerRule server = new GrpcServerRule();
@Rule
public final GrpcServerRule server = new GrpcServerRule(new DynamicPort(RECEIVER_PORT));

@Before
public void before() {
Expand Down Expand Up @@ -285,6 +287,11 @@ public String getStringValue(String key) {
private static class GrpcServerRule extends ServerRule {

private final List<ExportTraceServiceRequest> traceRequests = new ArrayList<>();
private final DynamicPort port;

public GrpcServerRule(DynamicPort port) {
this.port = port;
}

@Override
protected void configure(ServerBuilder sb) throws Exception {
Expand All @@ -305,7 +312,7 @@ protected void configure(ServerBuilder sb) throws Exception {
}
});

sb.http(0);
sb.http(port.getNumber());
}

public void reset() {
Expand Down

0 comments on commit 16132e4

Please sign in to comment.