Skip to content

Commit

Permalink
Add integration test with native
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-valdoleiros-gowithflow-io committed Jul 1, 2021
1 parent 808d902 commit d907777
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> zipkinCompatibilityMode;
public boolean zipkinCompatibilityMode = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> void initTracerProperty(String property, Optional<T> value, Function<T, String> accessor) {
Expand Down
130 changes: 130 additions & 0 deletions integration-tests/smallrye-opentracing/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>quarkus-integration-test-smallrye-opentracing</artifactId>
<name>Quarkus - Integration Tests - Smallrye Opentracing</name>

<dependencies>
<!-- Server dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-opentracing</artifactId>
</dependency>

<!-- Client dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-opentracing-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.it.rest.client;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class ZipkinIntegrationTestIT extends ZipkinIntegrationTest {
}

0 comments on commit d907777

Please sign in to comment.