Skip to content

Commit

Permalink
Refactor log4j-gctests (#2163)
Browse files Browse the repository at this point in the history
  • Loading branch information
vy committed Jan 10, 2024
1 parent b8fb8c8 commit 245da43
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 323 deletions.

This file was deleted.

74 changes: 74 additions & 0 deletions log4j-gc-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to you 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
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>${revision}</version>
<relativePath>../log4j-parent</relativePath>
</parent>

<artifactId>log4j-gc-test</artifactId>
<packaging>jar</packaging>
<name>Apache Log4j garbage collector tests</name>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.install.skip>true</maven.install.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
<scope>test</scope>
</dependency>
<!-- Required for AsyncLoggers -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.java-allocation-instrumenter</groupId>
<artifactId>java-allocation-instrumenter</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@

import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
import org.apache.logging.log4j.core.impl.Log4jPropertyKey;
import org.apache.logging.log4j.core.test.categories.GarbageFree;
import org.apache.logging.log4j.spi.LoggingSystemProperty;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Verifies steady state logging is GC-free.
*
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
*/
@Tag("allocation")
@Tag("functional")
@Category(GarbageFree.class)
public class GcFreeAsynchronousLoggingTest {
public class GcFreeAsyncLoggingTest {

@Test
public void testNoAllocationDuringSteadyStateLogging() throws Throwable {
Expand All @@ -49,6 +46,6 @@ public static void main(final String[] args) throws Exception {
System.setProperty(
Log4jPropertyKey.CONTEXT_SELECTOR_CLASS_NAME.getSystemKey(),
AsyncLoggerContextSelector.class.getName());
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsynchronousLoggingTest.class);
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsyncLoggingTest.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
/**
* Utility methods for the GC-free logging tests.
*/
public enum GcFreeLoggingTestUtil {
enum GcFreeLoggingTestUtil {
;

public static void executeLogging(final String configurationFile, final Class<?> testClass) throws Exception {
static void executeLogging(final String configurationFile, final Class<?> testClass) throws Exception {

System.setProperty(Log4jPropertyKey.GC_ENABLE_DIRECT_ENCODERS.getSystemKey(), "true");
System.setProperty(LoggingSystemProperty.IS_WEBAPP.getSystemKey(), "false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
*/
package org.apache.logging.log4j.gctests;

import org.apache.logging.log4j.core.test.categories.GarbageFree;
import org.apache.logging.log4j.spi.LoggingSystemProperty;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Verifies steady state mixed synchronous and asynchronous logging is GC-free.
*
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
*/
@Tag("allocation")
@Tag("functional")
@Category(GarbageFree.class)
public class GcFreeMixedSyncAsyncLoggingTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
*/
package org.apache.logging.log4j.gctests;

import org.apache.logging.log4j.core.test.categories.GarbageFree;
import org.apache.logging.log4j.spi.LoggingSystemProperty;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Verifies steady state synchronous logging is GC-free.
*
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
*/
@Tag("allocation")
@Tag("functional")
@Category(GarbageFree.class)
public class GcFreeSynchronousLoggingTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Verifies steady state logging with JSON Template Layout is GC-free.
*
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
*/
@Tag("allocation")
@Tag("functional")
public class JsonTemplateLayoutGcFreeTest {
Expand Down
Loading

0 comments on commit 245da43

Please sign in to comment.