From d907777efaff088fd20d11e6d7cb2221f187a513 Mon Sep 17 00:00:00 2001 From: Raul Valdoleiros Date: Thu, 1 Jul 2021 20:25:31 +0100 Subject: [PATCH] Add integration test with native --- .../jaeger/test/QuarkusJaegerTracerTest.java | 6 +- .../quarkus/jaeger/runtime/JaegerConfig.java | 4 +- .../runtime/JaegerDeploymentRecorder.java | 4 +- .../smallrye-opentracing/pom.xml | 130 ++++++++++++++++++ .../it/rest/client/server/EchoService.java | 16 +++ .../src/main/resources/application.properties | 6 + .../it/rest/client/ZipkinIntegrationTest.java | 22 +++ .../rest/client/ZipkinIntegrationTestIT.java | 7 + 8 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 integration-tests/smallrye-opentracing/pom.xml create mode 100644 integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/rest/client/server/EchoService.java create mode 100644 integration-tests/smallrye-opentracing/src/main/resources/application.properties create mode 100644 integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTest.java create mode 100644 integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTestIT.java diff --git a/extensions/jaeger/deployment/src/test/java/io/quarkus/jaeger/test/QuarkusJaegerTracerTest.java b/extensions/jaeger/deployment/src/test/java/io/quarkus/jaeger/test/QuarkusJaegerTracerTest.java index acb636355bdd0c..9958ff5e924793 100644 --- a/extensions/jaeger/deployment/src/test/java/io/quarkus/jaeger/test/QuarkusJaegerTracerTest.java +++ b/extensions/jaeger/deployment/src/test/java/io/quarkus/jaeger/test/QuarkusJaegerTracerTest.java @@ -27,7 +27,8 @@ public void withzipkinCompatibilityMode() { Tracer mockedTracer = Mockito.mock(JaegerTracer.class); mockedStaticConfiguration.when(() -> Configuration.fromEnv()).thenReturn(mockedInstanceConfiguration); - mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())).thenReturn(mockedInstanceConfiguration); + mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())) + .thenReturn(mockedInstanceConfiguration); mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.getTracerBuilder()).thenReturn(mockedBuilder); mockedStaticConfiguration.when(() -> mockedBuilder.withScopeManager(Mockito.any())).thenReturn(mockedBuilder); mockedStaticConfiguration.when(() -> mockedBuilder.withReporter(Mockito.any())).thenReturn(mockedBuilder); @@ -54,7 +55,8 @@ public void withoutZipkinCompatibilityMode() { Tracer mockedTracer = Mockito.mock(JaegerTracer.class); mockedStaticConfiguration.when(() -> Configuration.fromEnv()).thenReturn(mockedInstanceConfiguration); - mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())).thenReturn(mockedInstanceConfiguration); + mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())) + .thenReturn(mockedInstanceConfiguration); mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.getTracerBuilder()).thenReturn(mockedBuilder); mockedStaticConfiguration.when(() -> mockedBuilder.withScopeManager(Mockito.any())).thenReturn(mockedBuilder); mockedStaticConfiguration.when(() -> mockedBuilder.withReporter(Mockito.any())).thenReturn(mockedBuilder); diff --git a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerConfig.java b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerConfig.java index d5ca8f2419fe19..972cf393f564b5 100644 --- a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerConfig.java +++ b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerConfig.java @@ -119,8 +119,8 @@ public class JaegerConfig { public Boolean logTraceContext; /** - * Whether the jaeger should run in zipkin compatibility mode + * Whether jaeger should run in zipkin compatibility mode */ @ConfigItem - public Optional zipkinCompatibilityMode; + public boolean zipkinCompatibilityMode = false; } diff --git a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java index 06df5e573cc713..0defaa6c9bded0 100644 --- a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java +++ b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java @@ -82,9 +82,7 @@ private void initTracerConfig(JaegerConfig jaeger) { initTracerProperty("JAEGER_PROPAGATION", jaeger.propagation, format -> format.toString()); initTracerProperty("JAEGER_SENDER_FACTORY", jaeger.senderFactory, sender -> sender); quarkusTracer.setLogTraceContext(jaeger.logTraceContext); - if (jaeger.zipkinCompatibilityMode.isPresent()) { - quarkusTracer.setZipkinCompatibilityMode(jaeger.zipkinCompatibilityMode.get()); - } + quarkusTracer.setZipkinCompatibilityMode(jaeger.zipkinCompatibilityMode); } private void initTracerProperty(String property, Optional value, Function accessor) { diff --git a/integration-tests/smallrye-opentracing/pom.xml b/integration-tests/smallrye-opentracing/pom.xml new file mode 100644 index 00000000000000..47494af2736a69 --- /dev/null +++ b/integration-tests/smallrye-opentracing/pom.xml @@ -0,0 +1,130 @@ + + + + quarkus-integration-tests-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + quarkus-integration-test-smallrye-opentracing + Quarkus - Integration Tests - Smallrye Opentracing + + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-smallrye-opentracing + + + + + io.quarkus + quarkus-rest-client + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + io.quarkus + quarkus-rest-client-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-resteasy-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-smallrye-opentracing-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + + + src/main/resources + true + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + native-image + + + native + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + + + + diff --git a/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/rest/client/server/EchoService.java b/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/rest/client/server/EchoService.java new file mode 100644 index 00000000000000..3818ccc09b75af --- /dev/null +++ b/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/rest/client/server/EchoService.java @@ -0,0 +1,16 @@ +package io.quarkus.it.rest.client.server; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/echo") +public class EchoService { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String echo() { + return "result"; + } +} \ No newline at end of file diff --git a/integration-tests/smallrye-opentracing/src/main/resources/application.properties b/integration-tests/smallrye-opentracing/src/main/resources/application.properties new file mode 100644 index 00000000000000..5c6adabf12960a --- /dev/null +++ b/integration-tests/smallrye-opentracing/src/main/resources/application.properties @@ -0,0 +1,6 @@ +quarkus.jaeger.service-name=encryptions +quarkus.jaeger.sampler-type=const +quarkus.jaeger.sampler-param=1 +quarkus.jaeger.propagation=b3 +quarkus.jaeger.zipkin-compatibility-mode=true +quarkus.jaeger.endpoint=http://localhost:8080 \ No newline at end of file diff --git a/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTest.java b/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTest.java new file mode 100644 index 00000000000000..d4cf435e25c701 --- /dev/null +++ b/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTest.java @@ -0,0 +1,22 @@ +package io.quarkus.it.rest.client; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ZipkinIntegrationTest { + + @Test + public void testZipkinIntegration() { + given() + .when().get("/echo") + .then() + .statusCode(200) + .body(containsString("result")); + + } +} diff --git a/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTestIT.java b/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTestIT.java new file mode 100644 index 00000000000000..cd89e385e63509 --- /dev/null +++ b/integration-tests/smallrye-opentracing/src/test/java/io/quarkus/it/rest/client/ZipkinIntegrationTestIT.java @@ -0,0 +1,7 @@ +package io.quarkus.it.rest.client; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class ZipkinIntegrationTestIT extends ZipkinIntegrationTest { +}