This is an automated email from the ASF dual-hosted git repository. vy pushed a commit to branch release-2.x in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit b01b549078b18bf58c54a3b6d0c8e72864c1d5a7 Author: Volkan Yazici <[email protected]> AuthorDate: Wed Feb 17 14:56:17 2021 +0100 Cut down test time by moving recycler-specific test schemes from Surefire executions to JUnit parameters. --- log4j-layout-template-json/pom.xml | 95 ++-------------------- .../JsonTemplateLayoutConcurrentEncodeTest.java | 27 ++++-- 2 files changed, 26 insertions(+), 96 deletions(-) diff --git a/log4j-layout-template-json/pom.xml b/log4j-layout-template-json/pom.xml index 2a435e3..b6cdfcc 100644 --- a/log4j-layout-template-json/pom.xml +++ b/log4j-layout-template-json/pom.xml @@ -61,12 +61,15 @@ </dependency> <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> </dependency> + <dependency> <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-engine</artifactId> + <artifactId>junit-jupiter-params</artifactId> + <scope>test</scope> </dependency> <dependency> @@ -177,9 +180,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> - <!-- Disabling the default execution and only using it to provide - the shared settings between individual executions. --> - <skip>true</skip> <!-- Enforcing a non-UTF-8 encoding to check that the layout indeed handles everything in UTF-8 without implicitly relying on the system defaults. --> @@ -190,89 +190,6 @@ <junit.jupiter.execution.parallel.mode.default>concurrent</junit.jupiter.execution.parallel.mode.default> </systemPropertyVariables> </configuration> - <executions> - <execution> - <id>default</id> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${skipTests}</skip> - <excludes> - <exclude>**/JsonTemplateLayoutConcurrentEncodeTest.java</exclude> - <exclude>**/JsonTemplateLayoutTest.java</exclude> - </excludes> - </configuration> - </execution> - <!-- Dummy recycler execution --> - <execution> - <id>recycler-dummy</id> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${skipTests}</skip> - <systemPropertyVariables> - <log4j2.layout.jsonTemplate.recyclerFactory>dummy</log4j2.layout.jsonTemplate.recyclerFactory> - </systemPropertyVariables> - <includes> - <include>**/JsonTemplateLayoutConcurrentEncodeTest.java</include> - <include>**/JsonTemplateLayoutTest.java</include> - </includes> - </configuration> - </execution> - <!-- Thread-Local recycler execution --> - <execution> - <id>recycler-tl</id> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${skipTests}</skip> - <systemPropertyVariables> - <log4j2.layout.jsonTemplate.recyclerFactory>threadLocal</log4j2.layout.jsonTemplate.recyclerFactory> - </systemPropertyVariables> - <includes> - <include>**/JsonTemplateLayoutConcurrentEncodeTest.java</include> - <include>**/JsonTemplateLayoutTest.java</include> - </includes> - </configuration> - </execution> - <!-- ArrayBlockingQueue recycler execution --> - <execution> - <id>recycler-abq</id> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${skipTests}</skip> - <systemPropertyVariables> - <log4j2.layout.jsonTemplate.recyclerFactory>queue:supplier=java.util.concurrent.ArrayBlockingQueue.new</log4j2.layout.jsonTemplate.recyclerFactory> - </systemPropertyVariables> - <includes> - <include>**/JsonTemplateLayoutConcurrentEncodeTest.java</include> - <include>**/JsonTemplateLayoutTest.java</include> - </includes> - </configuration> - </execution> - <!-- MpmcArrayQueue recycler execution --> - <execution> - <id>recycler-mpmc</id> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${skipTests}</skip> - <systemPropertyVariables> - <log4j2.layout.jsonTemplate.recyclerFactory>queue:supplier=org.jctools.queues.MpmcArrayQueue.new</log4j2.layout.jsonTemplate.recyclerFactory> - </systemPropertyVariables> - <includes> - <include>**/JsonTemplateLayoutConcurrentEncodeTest.java</include> - <include>**/JsonTemplateLayoutTest.java</include> - </includes> - </configuration> - </execution> - </executions> </plugin> <!-- Disable ITs, which are Docker-dependent, by default. --> diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutConcurrentEncodeTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutConcurrentEncodeTest.java index 9cb32e3..d62e63c 100644 --- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutConcurrentEncodeTest.java +++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutConcurrentEncodeTest.java @@ -20,8 +20,11 @@ import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.DefaultConfiguration; import org.apache.logging.log4j.core.layout.ByteBufferDestination; +import org.apache.logging.log4j.layout.template.json.util.RecyclerFactories; +import org.apache.logging.log4j.layout.template.json.util.RecyclerFactory; import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import java.nio.ByteBuffer; import java.util.List; @@ -117,16 +120,25 @@ class JsonTemplateLayoutConcurrentEncodeTest { return logEvents; } - @Test - void test_concurrent_encode() { + @ParameterizedTest + @ValueSource(strings = { + "dummy", + "threadLocal", + "queue:supplier=java.util.concurrent.ArrayBlockingQueue.new", + "queue:supplier=org.jctools.queues.MpmcArrayQueue.new" + }) + void test_concurrent_encode(final String recyclerFactorySpec) { + final RecyclerFactory recyclerFactory = RecyclerFactories.ofSpec(recyclerFactorySpec); final AtomicReference<Exception> encodeFailureRef = new AtomicReference<>(null); - produce(encodeFailureRef); + produce(recyclerFactory, encodeFailureRef); Assertions.assertThat(encodeFailureRef.get()).isNull(); } - private void produce(final AtomicReference<Exception> encodeFailureRef) { + private void produce( + final RecyclerFactory recyclerFactory, + final AtomicReference<Exception> encodeFailureRef) { final int threadCount = 10; - final JsonTemplateLayout layout = createLayout(); + final JsonTemplateLayout layout = createLayout(recyclerFactory); final ByteBufferDestination destination = new ConcurrentAccessDetectingByteBufferDestination(); final AtomicLong encodeCounter = new AtomicLong(0); @@ -150,7 +162,7 @@ class JsonTemplateLayoutConcurrentEncodeTest { }); } - private static JsonTemplateLayout createLayout() { + private static JsonTemplateLayout createLayout(final RecyclerFactory recyclerFactory) { final Configuration config = new DefaultConfiguration(); return JsonTemplateLayout .newBuilder() @@ -158,6 +170,7 @@ class JsonTemplateLayoutConcurrentEncodeTest { .setEventTemplate("{\"message\": \"${json:message}\"}") .setStackTraceEnabled(false) .setLocationInfoEnabled(false) + .setRecyclerFactory(recyclerFactory) .build(); }
