Fix and re-enable integration tests at compilation time
MODIFY
dd-java-agent-ittests/pom.xml
dd-java-agent-ittests/pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.20</version>
+ <version>2.19</version>
<configuration>
<!-- TODO fixit, Due to a Java Heap error, skiping test-->
- <skipTests>true</skipTests>
+ <skipTests>false</skipTests>
<includes>
<include>*Test.java</include>
</includes>
- <forkCount>3</forkCount>
- <reuseForks>false</reuseForks>
- <argLine>-Xmx1g -Xms1g -XX:MaxPermSize=512m -Dorg.jboss.byteman.verbose=true
+<!-- <forkCount>1</forkCount> -->
+<!-- <reuseForks>false</reuseForks> -->
+ <argLine>
-javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar
</argLine>
- <workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory>
+<!-- <workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory> -->
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <excludes>
- <!-- <exclude>ch.qos.logback:*</exclude> -->
- <!-- <exclude>org.slf4j:*</exclude> -->
- </excludes>
- </artifactSet>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>otarules.btm</resource>
- </transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <manifestEntries>
- <Agent-Class>io.opentracing.contrib.agent.AnnotationsTracingAgent</Agent-Class>
- <Premain-Class>io.opentracing.contrib.agent.AnnotationsTracingAgent
- </Premain-Class>
- <Can-Redefine-Classes>true</Can-Redefine-Classes>
- <Can-Retransform-Classes>true</Can-Retransform-Classes>
- <Boot-Class-Path>./${project.artifactId}.jar</Boot-Class-Path>
- </manifestEntries>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>

ADD
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/AAgentIntegration.java
+package com.datadoghq.trace.instrument;
+
+import org.junit.Before;
+
+import io.opentracing.mock.MockTracer;
+import io.opentracing.util.GlobalTracer;
+
+public class AAgentIntegration {
+
+ protected static MockTracer tracer = new MockTracer();
+
+ @Before
+ public void beforeTest() throws Exception {
+ try{
+ GlobalTracer.register(tracer);
+ }catch(Exception e){
+ //DO NOTHING IF ALREADY REGISTERED
+ }
+ tracer.reset();
+ }
+
+}

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/ApacheHTTPClientTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/ApacheHTTPClientTest.java
@@ -9,20 +9,9 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
-import org.junit.Before;
import org.junit.Test;
-import io.opentracing.mock.MockTracer;
-import io.opentracing.util.GlobalTracer;
-
-public class ApacheHTTPClientTest {
-
- protected MockTracer tracer = new MockTracer();
-
- @Before
- public void beforeTest() throws Exception {
- GlobalTracer.register(tracer);
- }
+public class ApacheHTTPClientTest extends AAgentIntegration{
@Test
public void test() throws Exception{

MODIFY
dd-java-agent-ittests/src/test/java/io/opentracing/contrib/agent/TraceAnnotationsManagerTest.java
dd-java-agent-ittests/src/test/java/io/opentracing/contrib/agent/TraceAnnotationsManagerTest.java
@@ -5,16 +5,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.Test;
-import io.opentracing.mock.MockTracer;
-import io.opentracing.util.GlobalTracer;
+import com.datadoghq.trace.instrument.AAgentIntegration;
-public class TraceAnnotationsManagerTest {
-
- protected MockTracer tracer = new MockTracer();
+public class TraceAnnotationsManagerTest extends AAgentIntegration{
@Before
public void beforeTest() throws Exception {
- GlobalTracer.register(tracer);
+ super.beforeTest();
TraceAnnotationsManager.loadAnnotationsRules(ClassLoader.getSystemClassLoader());
}

Fix and re-enable integration tests at compilation time