Provides a way to enable/disable the docker integration tests via a gradle property (#1115)
* Provides a way to disable the docker integration tests via a gradle property. * switch the property to be the opposite * add a new make target and let CI use it. * Update gradle.properties Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update exporters/jaeger/src/test/java/io/opentelemetry/exporters/jaeger/JaegerIntegrationTest.java Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update exporters/jaeger/src/test/java/io/opentelemetry/exporters/jaeger/JaegerIntegrationTest.java Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * simplify the test flow Co-authored-by: Armin Ruech <armin.ruech@gmail.com>
This commit is contained in:
parent
36661f1a06
commit
c32c776a70
|
|
@ -5,7 +5,7 @@ init_task: &init_task
|
|||
command: make init-git-submodules
|
||||
build_task: &build_task
|
||||
name: Build
|
||||
command: make test
|
||||
command: make test-with-docker
|
||||
compile_benchmark_task: &compile_benchmark_task
|
||||
name: Compile JMH
|
||||
command: make benchmark
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ Continuous integration builds the project, runs the tests, and runs multiple
|
|||
types of static analysis.
|
||||
|
||||
1. Note: Currently, to run the full suite of tests, you'll need to be running a docker daemon.
|
||||
The tests that require docker are disabled by default. If you wish to run them,
|
||||
you can enable the docker tests by setting a gradle property of
|
||||
``"enable.docker.tests"`` to true. See the gradle.properties file in the root of the project
|
||||
for more details.
|
||||
|
||||
2. From the root project directory, initialize repository dependencies
|
||||
|
||||
|
|
|
|||
4
Makefile
4
Makefile
|
|
@ -4,6 +4,10 @@
|
|||
test:
|
||||
./gradlew clean assemble check --stacktrace
|
||||
|
||||
.PHONY: test-with-docker
|
||||
test-with-docker:
|
||||
./gradlew -Penable.docker.tests=true clean assemble check --stacktrace
|
||||
|
||||
.PHONY: benchmark
|
||||
benchmark:
|
||||
./gradlew compileJmhJava
|
||||
|
|
|
|||
|
|
@ -177,6 +177,10 @@ subprojects {
|
|||
// see: https://github.com/grpc/grpc-java/issues/3633
|
||||
compile("javax.annotation:javax.annotation-api:1.3.2")
|
||||
}
|
||||
|
||||
test {
|
||||
systemProperties project.properties.subMap(["enable.docker.tests"])
|
||||
}
|
||||
}
|
||||
|
||||
javadoc.options {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import io.grpc.ManagedChannelBuilder;
|
|||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import io.restassured.http.ContentType;
|
||||
|
|
@ -30,8 +31,9 @@ import io.restassured.response.Response;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.Before;
|
||||
import org.junit.Assume;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -49,35 +51,43 @@ public class JaegerIntegrationTest {
|
|||
private static final String JAEGER_URL = "http://localhost";
|
||||
private final Tracer tracer =
|
||||
OpenTelemetry.getTracerProvider().get(getClass().getCanonicalName());
|
||||
private JaegerGrpcSpanExporter jaegerExporter;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@ClassRule
|
||||
public static GenericContainer jaeger =
|
||||
new GenericContainer("jaegertracing/all-in-one:" + JAEGER_VERSION)
|
||||
.withExposedPorts(COLLECTOR_PORT, QUERY_PORT)
|
||||
.waitingFor(new HttpWaitStrategy().forPath("/"));
|
||||
@Nullable
|
||||
public static GenericContainer jaegerContainer = null;
|
||||
|
||||
@Before
|
||||
public void setupJaegerExporter() {
|
||||
static {
|
||||
// make sure that the user has enabled the docker-based tests
|
||||
if (Boolean.getBoolean("enable.docker.tests")) {
|
||||
jaegerContainer =
|
||||
new GenericContainer<>("jaegertracing/all-in-one:" + JAEGER_VERSION)
|
||||
.withExposedPorts(COLLECTOR_PORT, QUERY_PORT)
|
||||
.waitingFor(new HttpWaitStrategy().forPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJaegerIntegration() {
|
||||
Assume.assumeNotNull(jaegerContainer);
|
||||
setupJaegerExporter();
|
||||
imitateWork();
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS).until(assertJaegerHaveTrace());
|
||||
}
|
||||
|
||||
private static void setupJaegerExporter() {
|
||||
ManagedChannel jaegerChannel =
|
||||
ManagedChannelBuilder.forAddress("127.0.0.1", jaeger.getMappedPort(COLLECTOR_PORT))
|
||||
ManagedChannelBuilder.forAddress("127.0.0.1", jaegerContainer.getMappedPort(COLLECTOR_PORT))
|
||||
.usePlaintext()
|
||||
.build();
|
||||
this.jaegerExporter =
|
||||
SpanExporter jaegerExporter =
|
||||
JaegerGrpcSpanExporter.newBuilder()
|
||||
.setServiceName(SERVICE_NAME)
|
||||
.setChannel(jaegerChannel)
|
||||
.setDeadlineMs(30000)
|
||||
.build();
|
||||
OpenTelemetrySdk.getTracerProvider()
|
||||
.addSpanProcessor(SimpleSpansProcessor.newBuilder(this.jaegerExporter).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJaegerIntegration() {
|
||||
imitateWork();
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS).until(assertJaegerHaveTrace());
|
||||
.addSpanProcessor(SimpleSpansProcessor.newBuilder(jaegerExporter).build());
|
||||
}
|
||||
|
||||
private void imitateWork() {
|
||||
|
|
@ -99,7 +109,7 @@ public class JaegerIntegrationTest {
|
|||
String url =
|
||||
String.format(
|
||||
"%s/api/traces?service=%s",
|
||||
String.format(JAEGER_URL + ":%d", jaeger.getMappedPort(QUERY_PORT)),
|
||||
String.format(JAEGER_URL + ":%d", jaegerContainer.getMappedPort(QUERY_PORT)),
|
||||
SERVICE_NAME);
|
||||
Response response =
|
||||
given()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
org.gradle.parallel=true
|
||||
org.gradle.workers.max=4
|
||||
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
### Override this property to 'true' to enable the end-to-end tests that use docker.
|
||||
### This can be done via -Penable.docker.tests=true on the command line, or by
|
||||
### setting this property to true in the gradle.properties in your home directory.
|
||||
enable.docker.tests=false
|
||||
|
|
|
|||
Loading…
Reference in New Issue