Skip to content

Commit

Permalink
updates integration tests and benchmarks to use log4j (#224)
Browse files Browse the repository at this point in the history
Similar to Brave, we don't want a large amount of clutter. To reduce a
lot of it, I moved anything that uses MockWebServer to an IT (because it
spams logs). I didn't move normal tests to log4j because we have a log
capturing test that would fail. If someone wants to take a pass later at
that, they could.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Dec 14, 2023
1 parent 70d7855 commit 8e86704
Show file tree
Hide file tree
Showing 27 changed files with 191 additions and 215 deletions.
3 changes: 3 additions & 0 deletions activemq-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<module.name>zipkin2.reporter.activemq</module.name>

<main.basedir>${project.basedir}/..</main.basedir>
<!-- Be conscious about a 6.x upgrade: 5.x and 6.x types are incompatible
as the former uses javax.jms and latter jakarta.jms. It could be
better to make an activemq-client6 module. -->
<activemq.version>5.18.3</activemq.version>

<!-- CI should run the "release" profile during tests to ensure no 1.8
Expand Down
8 changes: 8 additions & 0 deletions activemq-client/src/test/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
appenders=console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n
rootLogger.level=warn
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
13 changes: 0 additions & 13 deletions activemq-client/src/test/resources/logback.xml

This file was deleted.

8 changes: 8 additions & 0 deletions amqp-client/src/test/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
appenders=console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n
rootLogger.level=warn
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
13 changes: 0 additions & 13 deletions amqp-client/src/test/resources/logback.xml

This file was deleted.

26 changes: 23 additions & 3 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,30 @@
https://github.com/charithe/kafka-junit -->
<version>4.2.10</version>
</dependency>

<!-- Main code uses jul and tests log with log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route jul over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route log4j over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route slf4j over log4j2 during integration tests -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>

Expand Down
14 changes: 9 additions & 5 deletions benchmarks/src/main/java/zipkin2/reporter/SenderBenchmarks.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2023 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -34,7 +34,8 @@
import org.openjdk.jmh.annotations.Warmup;
import zipkin2.CheckResult;
import zipkin2.Span;
import zipkin2.codec.SpanBytesDecoder;
import zipkin2.TestObjects;
import zipkin2.codec.SpanBytesEncoder;

/**
* This benchmark reports spans as fast as possible. The sender clears the queue as fast as
Expand All @@ -59,15 +60,18 @@ public abstract class SenderBenchmarks {

public int messageMaxBytes;

static final byte[] clientSpanBytes = spanFromResource("/zipkin2-client.json");
static final Span clientSpan = SpanBytesDecoder.JSON_V2.decodeOne(clientSpanBytes);

static final Span clientSpan = TestObjects.CLIENT_SPAN;
static final byte[] clientSpanBytes = SpanBytesEncoder.JSON_V2.encode(clientSpan);
static final InMemoryReporterMetrics metrics = new InMemoryReporterMetrics();

@AuxCounters
@State(Scope.Thread)
public static class InMemoryReporterMetricsAsCounters {

static {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
}

public long spans() {
return metrics.spans() - metrics.spansDropped();
}
Expand Down
22 changes: 0 additions & 22 deletions benchmarks/src/main/resources/log4j.properties

This file was deleted.

15 changes: 15 additions & 0 deletions benchmarks/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appenders=console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n
rootLogger.level=warn
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
# uncomment to include kafka consumer configuration in test logs
#logger.kafka-clients.name=org.apache.kafka.clients
#logger.kafka-clients.level=info
logger.kafkaunit.name=com.github.charithe.kafka
logger.kafkaunit.level=off
logger.kafka.name=zipkin2.reporter.kafka
logger.kafka.level=debug
34 changes: 0 additions & 34 deletions benchmarks/src/main/resources/logback.xml

This file was deleted.

32 changes: 0 additions & 32 deletions benchmarks/src/main/resources/zipkin2-client.json

This file was deleted.

23 changes: 23 additions & 0 deletions kafka/src/test/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
appenders=console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n
rootLogger.level=warn
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
# uncomment to include kafka consumer configuration in test logs
#logger.kafka-clients.name=org.apache.kafka.clients
#logger.kafka-clients.level=info
logger.kafka.name=zipkin2.reporter.kafka
logger.kafka.level=debug

# hush the unit test runner
logger.BrokerMetadataCheckpoint.name=kafka.server.BrokerMetadataCheckpoint
logger.BrokerMetadataCheckpoint.level=off

# don't waste logs when ZK check fails
logger.ClientCnxn.name=org.apache.zookeeper.ClientCnxn
logger.ClientCnxn.level=off
logger.NetworkClient.name=org.apache.kafka.clients.NetworkClient
logger.NetworkClient.level=off
25 changes: 0 additions & 25 deletions kafka/src/test/resources/logback.xml

This file was deleted.

8 changes: 8 additions & 0 deletions libthrift/src/test/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
appenders=console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n
rootLogger.level=warn
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
13 changes: 0 additions & 13 deletions libthrift/src/test/resources/logback.xml

This file was deleted.

1 change: 1 addition & 0 deletions okhttp3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<artifactId>mockwebserver</artifactId>
<version>${old-okhttp.version}</version>
<repositoryType>MAIN</repositoryType>
<type>jar</type>
</DynamicDependency>
</dynamicDependencies>
</configuration>
Expand Down
34 changes: 31 additions & 3 deletions okhttp3/src/it/okhttp3_v3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,54 @@
<artifactId>zipkin-tests</artifactId>
<version>@zipkin.version@</version>
</dependency>

<!-- route jul over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>@log4j.version@</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>@log4j.version@</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>@project.build.testSourceDirectory@</sourceDirectory>
<testResources>
<testResource>
<directory>@project.basedir@/src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>@maven-compiler-plugin.version@</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/IT*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<!-- Use surefire to run the ITs until someone figures out how to get invoker to run
failsafe -->
<artifactId>maven-surefire-plugin</artifactId>
<version>@maven-surefire-plugin.version@</version>
<configuration>
<!-- Ensures root cause ends up in the console -->
<trimStackTrace>false</trimStackTrace>
<failIfNoTests>true</failIfNoTests>
<includes>
<include>**/IT*.java</include>
</includes>
<!-- Try to prevent flakes in CI -->
<reuseForks>false</reuseForks>
<!-- workaround to SUREFIRE-1831 -->
<useModulePath>false</useModulePath>
<systemPropertyVariables>
<java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Expand Down

This file was deleted.

Loading

0 comments on commit 8e86704

Please sign in to comment.