Skip to content
Permalink
Browse files
Migrate accumulo-testing to log4j2. (#146)
Migrate accumulo-testing to use log4j2 (via slf4j)

Co-authored-by: Jeffrey Manno <jeffreymanno15@gmail.com>
Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
  • Loading branch information
3 people committed Sep 20, 2021
1 parent d415164 commit 50e4c021e7db4df546138d43d778f0adee4bf7a5
Showing 10 changed files with 124 additions and 50 deletions.
@@ -28,7 +28,7 @@ ENV HADOOP_RUNTIME_JAR /opt/at/hadoop-client-runtime.jar
ENV TEST_JAR_PATH /opt/at/accumulo-testing-shaded.jar
ENV ACCUMULO_CLIENT_PROPS /opt/at/conf/accumulo-client.properties
ENV TEST_PROPS /opt/at/conf/accumulo-testing.properties
ENV TEST_LOG4J /opt/at/conf/log4j.properties
ENV TEST_LOG4J /opt/at/conf/log4j2.properties

RUN mkdir /opt/at
RUN mkdir /opt/at/bin
@@ -92,5 +92,5 @@ case "$1" in
fi
;;
*)
java $JAVA_OPTS -Dlog4j.configuration="file:$TEST_LOG4J" "$ci_main" "${@:2}" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS"
java $JAVA_OPTS -Dlog4j.configurationFile="file:$TEST_LOG4J" "$ci_main" "${@:2}" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS"
esac
@@ -61,4 +61,4 @@ esac

export CLASSPATH="$TEST_JAR_PATH:$HADOOP_API_JAR:$HADOOP_RUNTIME_JAR:$CLASSPATH"

java $JAVA_OPTS -Dlog4j.configuration="file:$TEST_LOG4J" "$ci_main" "${@:2}" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS"
java $JAVA_OPTS -Dlog4j.configurationFile="file:$TEST_LOG4J" "$ci_main" "${@:2}" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS"
@@ -48,4 +48,4 @@ case "$1" in
esac

export CLASSPATH="$TEST_JAR_PATH:$HADOOP_API_JAR:$HADOOP_RUNTIME_JAR:$CLASSPATH"
java $JAVA_OPTS -DINSTRUMENTATIONKEY="$INSTRUMENTATIONKEY" -Dlog4j.configuration="file:$TEST_LOG4J" "$ci_main" "${@:2}" "-c" "$ACCUMULO_CLIENT_PROPS"
java $JAVA_OPTS -DINSTRUMENTATIONKEY="$INSTRUMENTATIONKEY" -Dlog4j.configurationFile="file:$TEST_LOG4J" "$ci_main" "${@:2}" "-c" "$ACCUMULO_CLIENT_PROPS"
@@ -46,9 +46,9 @@ function build_shade_jar() {
fi
}

log4j_config="$at_home/conf/log4j.properties"
log4j_config="$at_home/conf/log4j2.properties"
if [ ! -f "$log4j_config" ]; then
echo "Could not find logj4.properties in $at_home/conf"
echo "Could not find log4j2.properties in $at_home/conf"
exit 1
fi

@@ -71,7 +71,7 @@ case "$1" in
fi
# don't start unless we can find the class provided
found=false
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do
if [[ "$test_class" == "$3" ]]; then
found=true
fi
@@ -83,30 +83,30 @@ case "$1" in
fi
mkdir -p "$2"
start_cluster
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do
if [[ -z $3 || $test_class == *$3* ]]; then
echo "Running test $test_class"
pt_tmp=$(mktemp -d -t accumulo_pt_XXXXXXX)
setup_accumulo
get_config_file accumulo.properties "$pt_tmp"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.MergeSiteConfig "$test_class" "$pt_tmp"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.MergeSiteConfig "$test_class" "$pt_tmp"
put_config_file "$pt_tmp/accumulo.properties"
put_server_code "$at_home/target/accumulo-testing-$at_version.jar"
start_accumulo
get_config_file accumulo-client.properties "$pt_tmp"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.PerfTestRunner "$pt_tmp/accumulo-client.properties" "$test_class" "$(get_version 'ACCUMULO')" "$2"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.PerfTestRunner "$pt_tmp/accumulo-client.properties" "$test_class" "$(get_version 'ACCUMULO')" "$2"
fi
done
stop_cluster
;;
compare)
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.Compare "$2" "$3"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.Compare "$2" "$3"
;;
csv)
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.Csv "${@:2}"
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.Csv "${@:2}"
;;
list)
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests
CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests
;;
*)
echo "Unknown command : $1"
@@ -41,4 +41,4 @@ if [ -z "$1" ]; then
exit 1
fi

java $JAVA_OPTS -Dlog4j.configuration="file:$TEST_LOG4J" "$randomwalk_main" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS" "$1"
java $JAVA_OPTS -Dlog4j.configurationFile="file:$TEST_LOG4J" "$randomwalk_main" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS" "$1"
@@ -50,9 +50,9 @@ if [ ! -f "$TEST_PROPS" ]; then
echo "Please create and edit accumulo-testing.properties in $conf_dir"
exit 1
fi
export TEST_LOG4J="${conf_dir}/log4j.properties"
export TEST_LOG4J="${conf_dir}/log4j2.properties"
if [ ! -f "$TEST_LOG4J" ]; then
echo "Could not find logj4.properties in $conf_dir"
echo "Could not find log4j2.properties in $conf_dir"
exit 1
fi

This file was deleted.

@@ -0,0 +1,56 @@
#
# 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.
#

name = AccumuloTestingDefaultLoggingProperties
status = info
dest = err

appenders = console
appender.console.type = Console
appender.console.name = STDERR
appender.console.target = SYSTEM_ERR
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{ISO8601} [%c{3}] %-5p: %m%n

loggers = accumulotesting, accumulo, hadooptest, hadoopmapred, hadooputil, zookeepertest, curatortest
logger.accumulotesting.name = org.apache.accumulo.testing
logger.accumulotesting.level = DEBUG

logger.accumulo.name = org.apache.accumulo
logger.accumulo.level = WARN

logger.hadooptest.name = org.apache.hadoop
logger.hadooptest.level = WARN
logger.hadoopmapred.name = org.apache.hadoop.mapreduce
logger.hadoopmapred.level = ERROR
logger.hadooputil.name = org.apache.hadoop.util
logger.hadooputil.level = ERROR

logger.zookeepertest.name = org.apache.zookeeper
logger.zookeepertest.level = ERROR

logger.curatortest.name = org.apache.curator.test
logger.curatortest.level = ERROR

rootLogger.level = info
rootLogger.appenderRefs = stderr
rootLogger.appenderRef.stderr.ref = STDERR



59 pom.xml
@@ -29,12 +29,14 @@
<description>Testing tools for Apache Accumulo</description>
<properties>
<accumulo.version>2.1.0-SNAPSHOT</accumulo.version>
<disruptor.version>3.4.4</disruptor.version>
<eclipseFormatterStyle>${project.basedir}/contrib/Eclipse-Accumulo-Codestyle.xml</eclipseFormatterStyle>
<hadoop.version>3.2.0</hadoop.version>
<log4j2.version>2.4</log4j2.version>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<slf4j.version>1.7.25</slf4j.version>
<slf4j.version>1.7.30</slf4j.version>
<spotbugs.version>3.1.7</spotbugs.version>
<zookeeper.version>3.4.14</zookeeper.version>
</properties>
@@ -44,6 +46,19 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${log4j2.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
@@ -59,6 +74,11 @@
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@@ -95,13 +115,12 @@
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
@@ -121,6 +140,12 @@
<artifactId>accumulo-test</artifactId>
<version>${accumulo.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
@@ -140,6 +165,17 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/Log4j2Plugins.dat</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
@@ -342,6 +378,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.github.edwgiz</groupId>
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>testing-shade-jar</id>
@@ -357,8 +400,7 @@
<excludes>
<exclude>org.apache.accumulo:accumulo-native</exclude>
<exclude>org.apache.hadoop:*</exclude>
<exclude>org.apache.logging.log4j:log4j-api:jar:</exclude>
<exclude>org.apache.logging.log4j:log4j-1.2-api:jar:</exclude>
<exclude>log4j:*</exclude>
</excludes>
</artifactSet>
<filters>
@@ -374,6 +416,9 @@
<transformers>
<!-- Hadoop uses service loader to find filesystem impls, without this may not find them -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<!-- New transformer. Provides workaround for 2 bugs. Read README.md for
more information at: https://github.com/edwgiz/maven-shaded-log4j-transformer -->
<transformer implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer" />
</transformers>
</configuration>
</execution>

0 comments on commit 50e4c02

Please sign in to comment.