From 9db2c69aaa0ba078f044266dae8e0b92a6e98357 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 2 Feb 2022 22:53:52 +0000 Subject: [PATCH] Add 'log4j2' domain tests to the Log4j 2.x agent The Log4j 2.x agent now supports registering with 2 different tracing domains, the existing 'log4j' domain and the new 'log4j2' domain. The following tags were added to filter the tests when running the test suite : - agent:jul - agent:log4j - agent:log4j2 - domain:jul - domain:log4j - domain:log4j2 - benchmark For example, we can exclude all the log4j2 agent tests when testing a version of LTTng that doesn't implement it : mvn clean verify -Dgroups='!agent:log4j2' Or to run only the log4j domain tests on all agents that include them : mvn clean verify -Dgroups='domain:log4j' Signed-off-by: Michael Jeanson --- README.md | 14 ++ .../java/org/lttng/tools/ILttngSession.java | 19 ++- .../filter/FilterListenerITBase.java | 51 +++--- .../filter/FilterListenerOrderingITBase.java | 13 +- .../ust/agent/utils/EventRuleFactory.java | 30 ++-- .../ust/agent/utils/ILogLevelStrings.java | 25 +++ .../agent/integration/client/TcpClientIT.java | 48 +++--- .../jul/handler/JulHandlerBenchmarkBase.java | 4 + .../builtin/DummyHandlerBenchmark.java | 4 + .../handler/builtin/FileHandlerBenchmark.java | 4 + .../handler/builtin/NoHandlerBenchmark.java | 4 + .../handler/builtin/NoLoggerBenchmark.java | 4 + ...tngJulHandlerTracingDisabledBenchmark.java | 4 + ...ttngJulHandlerTracingEnabledBenchmark.java | 4 + ...tngJulHandlerTracingDisabledBenchmark.java | 4 + ...ttngJulHandlerTracingEnabledBenchmark.java | 4 + .../integration/context/JulAppContextIT.java | 3 + .../context/JulAppContextOrderingIT.java | 3 + .../events/JulEnabledEventsIT.java | 3 + .../integration/events/JulLegacyApiIT.java | 3 + .../JulLegacyApiLoggerHierarchyListIT.java | 3 + .../integration/events/JulListEventsIT.java | 3 + .../events/JulLoggerHierarchyListIT.java | 3 + .../integration/events/JulMultiSessionIT.java | 3 + .../filter/JulFilterListenerIT.java | 4 +- .../filter/JulFilterListenerOrderingIT.java | 3 + .../context/Log4jAppContextIT.java | 3 + .../context/Log4jAppContextOrderingIT.java | 3 + .../events/Log4jEnabledEventsIT.java | 3 + .../integration/events/Log4jLegacyApiIT.java | 3 + .../integration/events/Log4jListEventsIT.java | 3 + .../events/Log4jMultiSessionIT.java | 3 + .../filter/Log4jFilterListenerIT.java | 4 +- .../filter/Log4jFilterListenerOrderingIT.java | 3 + lttng-ust-java-tests-log4j2/.classpath | 2 +- lttng-ust-java-tests-log4j2/pom.xml | 4 +- .../context/Log4j2AppContextITBase.java | 96 +++++++++++ .../Log4j2AppContextOrderingITBase.java | 84 ++++++++++ .../events/Log4j2EnabledEventsITBase.java | 129 +++++++++++++++ .../events/Log4j2ListEventsITBase.java | 156 ++++++++++++++++++ .../events/Log4j2MultiSessionITBase.java | 118 +++++++++++++ .../filter/Log4j2FilterListenerITBase.java | 58 +++++++ .../Log4j2FilterListenerOrderingITBase.java | 62 +++++++ .../ust/agent/utils/Log4j2TestContext.java | 0 .../ust/agent/utils/Log4j2TestUtils.java | 13 +- .../context/Log4j2AppContextIT.java | 77 +-------- .../context/Log4j2AppContextOrderingIT.java | 63 +------ .../context/Log4j2CompatAppContextIT.java | 36 ++++ .../Log4j2CompatAppContextOrderingIT.java | 36 ++++ .../events/Log4j2CompatEnabledEventsIT.java | 36 ++++ .../events/Log4j2CompatListEventsIT.java | 36 ++++ .../events/Log4j2CompatMultiSessionIT.java | 36 ++++ .../events/Log4j2EnabledEventsIT.java | 112 +------------ .../events/Log4j2ListEventsIT.java | 127 +------------- .../events/Log4j2MultiSessionIT.java | 100 +---------- .../filter/Log4j2CompatFilterListenerIT.java | 42 +++++ .../Log4j2CompatFilterListenerOrderingIT.java | 36 ++++ .../filter/Log4j2FilterListenerIT.java | 41 +---- .../Log4j2FilterListenerOrderingIT.java | 41 +---- ...og4j2.LOG4J2testManyLoggersAllAttached.xml | 26 +++ ...g4j2.LOG4J2testManyLoggersNoneAttached.xml | 23 +++ ...g4j2.LOG4J2testManyLoggersSomeAttached.xml | 24 +++ ...og4j2.LOG4JtestManyLoggersAllAttached.xml} | 6 +- ...g4j2.LOG4JtestManyLoggersNoneAttached.xml} | 6 +- ...g4j2.LOG4JtestManyLoggersSomeAttached.xml} | 6 +- .../resources/log4j2.Log4j2AppContextIT.xml | 2 +- .../log4j2.Log4j2AppContextOrderingIT.xml | 2 +- .../log4j2.Log4j2CompatAppContextIT.xml | 16 ++ ...og4j2.Log4j2CompatAppContextOrderingIT.xml | 16 ++ .../log4j2.Log4j2CompatEnabledEventsIT.xml | 29 ++++ ...2.Log4j2CompatFilterListenerOrderingIT.xml | 20 +++ .../log4j2.Log4j2CompatMultiSessionIT.xml | 31 ++++ .../log4j2.Log4j2EnabledEventsIT.xml | 6 +- .../log4j2.Log4j2FilterListenerOrderingIT.xml | 2 +- .../resources/log4j2.Log4j2MultiSessionIT.xml | 8 +- pom.xml | 11 +- 76 files changed, 1463 insertions(+), 604 deletions(-) create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java create mode 100644 lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java rename lttng-ust-java-tests-log4j2/src/{test => main}/java/org/lttng/ust/agent/utils/Log4j2TestContext.java (100%) rename lttng-ust-java-tests-log4j2/src/{test => main}/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java (87%) create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml rename lttng-ust-java-tests-log4j2/src/test/resources/{log4j2.testManyLoggersAllAttached.xml => log4j2.LOG4JtestManyLoggersAllAttached.xml} (85%) rename lttng-ust-java-tests-log4j2/src/test/resources/{log4j2.testManyLoggersNoneAttached.xml => log4j2.LOG4JtestManyLoggersNoneAttached.xml} (83%) rename lttng-ust-java-tests-log4j2/src/test/resources/{log4j2.testManyLoggersSomeAttached.xml => log4j2.LOG4JtestManyLoggersSomeAttached.xml} (84%) create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml create mode 100644 lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml diff --git a/README.md b/README.md index 6d1f5fa..cf1c566 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,20 @@ the first test set that is empty. See [2] for more info. [1] http://maven.apache.org/surefire/maven-failsafe-plugin/index.html [2] http://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html +Running tests by tags +--------------------- + +Tests can also be filtered by Junit tags or tag expressions [1], for example to +run only the Log4 1.x agent tests: + + mvn clean verify -Dgroups='agent:log4j' + +Or to exclude the tests of the Log4j2 domain: + + mvn clean verify -Dgroups='!domain:log4j2' + +[1] https://junit.org/junit5/docs/current/user-guide/#running-tests-tags + Debugging a test ---------------------- diff --git a/lttng-tools-java/src/main/java/org/lttng/tools/ILttngSession.java b/lttng-tools-java/src/main/java/org/lttng/tools/ILttngSession.java index 414e3fb..faecc0c 100644 --- a/lttng-tools-java/src/main/java/org/lttng/tools/ILttngSession.java +++ b/lttng-tools-java/src/main/java/org/lttng/tools/ILttngSession.java @@ -32,13 +32,18 @@ public interface ILttngSession extends AutoCloseable { */ enum Domain { /** The JUL (java.util.logging) domain */ - JUL("-j"), /** The log4j (org.apache.log4j) domain */ - LOG4J("-l"); + JUL("--jul", ">=", Integer.MIN_VALUE), /** The log4j (org.apache.log4j) domain */ + LOG4J("--log4j", ">=", Integer.MIN_VALUE), + LOG4J2("--log4j2", "<=", Integer.MAX_VALUE); private final String flag; + private final String rangeOperator; + private final int levelAllValue; - private Domain(String flag) { + private Domain(String flag, String rangeOperator, int levelAllValue) { this.flag = flag; + this.rangeOperator = rangeOperator; + this.levelAllValue = levelAllValue; } /** @@ -48,6 +53,14 @@ public interface ILttngSession extends AutoCloseable { public String flag() { return flag; } + + public String rangeOperator() { + return rangeOperator; + } + + public int levelAllValue() { + return levelAllValue; + } } // ------------------------------------------------------------------------ diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java index 7712b46..c3b5475 100644 --- a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java @@ -58,10 +58,19 @@ public abstract class FilterListenerITBase { private TestFilterListener listener; private ILttngHandler handler; + protected EventRuleFactory eventRuleFactory; + protected abstract ILttngSession.Domain getSessionDomain(); protected abstract ILttngHandler getLogHandler() throws SecurityException, IOException; protected abstract ILogLevelStrings getLogLevelStrings(); + protected EventRuleFactory getEventRuleFactory() { + if (eventRuleFactory == null) { + eventRuleFactory = new EventRuleFactory(getSessionDomain()); + } + return eventRuleFactory; + } + /** * Test setup * @@ -104,7 +113,7 @@ public abstract class FilterListenerITBase { @Test public void testOneRule() { Set rules = Collections.singleton( - EventRuleFactory.createRule(EVENT_NAME_A)); + getEventRuleFactory().createRule(EVENT_NAME_A)); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -118,9 +127,9 @@ public abstract class FilterListenerITBase { @Test public void testManyRules() { Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B), - EventRuleFactory.createRule(EVENT_NAME_C)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B), + getEventRuleFactory().createRule(EVENT_NAME_C)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -137,7 +146,7 @@ public abstract class FilterListenerITBase { @Test public void testManyRulesDisableSome() { Set rules = Collections.singleton( - EventRuleFactory.createRule(EVENT_NAME_A)); + getEventRuleFactory().createRule(EVENT_NAME_A)); session.enableEvent(EVENT_NAME_A, null, false, null); session.enableEvent(EVENT_NAME_B, null, false, null); @@ -179,9 +188,9 @@ public abstract class FilterListenerITBase { LogLevelSelector lls3 = new LogLevelSelector(getLogLevelStrings().infoInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2), - EventRuleFactory.createRule(EVENT_NAME_A, lls3)) + getEventRuleFactory().createRule(EVENT_NAME_A, lls1), + getEventRuleFactory().createRule(EVENT_NAME_A, lls2), + getEventRuleFactory().createRule(EVENT_NAME_A, lls3)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); @@ -201,9 +210,9 @@ public abstract class FilterListenerITBase { String filterB = "filterB"; Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterA), - EventRuleFactory.createRule(EVENT_NAME_C, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterB)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B, getEventRuleFactory().LOG_LEVEL_UNSPECIFIED, filterA), + getEventRuleFactory().createRule(EVENT_NAME_C, getEventRuleFactory().LOG_LEVEL_UNSPECIFIED, filterB)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -221,8 +230,8 @@ public abstract class FilterListenerITBase { @Test public void testDetachingListener() { Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -247,8 +256,8 @@ public abstract class FilterListenerITBase { fcn.registerListener(listener3); Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -284,8 +293,8 @@ public abstract class FilterListenerITBase { fcn.unregisterListener(listener2); Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); @@ -311,12 +320,12 @@ public abstract class FilterListenerITBase { TestFilterListener listener2 = new TestFilterListener(); Set rules1 = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B)) .collect(Collectors.toSet()); Set rules2 = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_C)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_C)) .collect(Collectors.toSet()); session.enableEvent(EVENT_NAME_A, null, false, null); diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java index 4e344e0..fd70702 100644 --- a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java @@ -74,6 +74,8 @@ public abstract class FilterListenerOrderingITBase { protected static final String EVENT_NAME_A = "EventA"; private static final String EVENT_NAME_B = "EventB"; + protected EventRuleFactory eventRuleFactory; + private ILttngSession session; private TestFilterListener listener; @@ -116,6 +118,13 @@ public abstract class FilterListenerOrderingITBase { session = null; } + protected EventRuleFactory getEventRuleFactory() { + if (eventRuleFactory == null) { + eventRuleFactory = new EventRuleFactory(getDomain()); + } + return eventRuleFactory; + } + // ------------------------------------------------------------------------ // Test methods // ------------------------------------------------------------------------ @@ -126,8 +135,8 @@ public abstract class FilterListenerOrderingITBase { */ private void checkOngoingConditions() { Set exptectedRules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) + getEventRuleFactory().createRule(EVENT_NAME_A), + getEventRuleFactory().createRule(EVENT_NAME_B)) .collect(Collectors.toSet()); assertEquals(2, listener.getNbNotifications()); diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java index fd1a46b..2b99e32 100644 --- a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java @@ -20,6 +20,7 @@ package org.lttng.ust.agent.utils; import java.util.StringJoiner; +import org.lttng.tools.ILttngSession; import org.lttng.ust.agent.session.EventRule; import org.lttng.ust.agent.session.LogLevelSelector; @@ -29,15 +30,25 @@ import org.lttng.ust.agent.session.LogLevelSelector; * * @author Alexandre Montplaisir */ -public final class EventRuleFactory { +public class EventRuleFactory { /** Name of the "all" (-a) event */ public static final String EVENT_NAME_ALL = "*"; /** Log level set by default when it is not specified */ - public static final LogLevelSelector LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(Integer.MIN_VALUE, 0); + public final LogLevelSelector LOG_LEVEL_UNSPECIFIED; - private EventRuleFactory() {} + private final ILttngSession.Domain domain; + + /** + * Constructor. + * + * @param domain + */ + public EventRuleFactory(ILttngSession.Domain domain) { + this.domain = domain; + LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(domain.levelAllValue(), 0); + } /** * Construct an event by only passing the event name on the command-line. @@ -46,7 +57,7 @@ public final class EventRuleFactory { * The event name * @return The corresponding event rule */ - public static EventRule createRule(String eventName) { + public EventRule createRule(String eventName) { return new EventRule(eventName, LOG_LEVEL_UNSPECIFIED, filterStringFromEventName(eventName)); } @@ -59,7 +70,7 @@ public final class EventRuleFactory { * The log level * @return The corresponding event rule */ - public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector) { + public EventRule createRule(String eventName, LogLevelSelector logLevelSelector) { StringJoiner sj = new StringJoiner(") && (", "(", ")"); String filterStr = sj.add(filterStringFromEventName(eventName)) .add(filterStringFromLogLevel(logLevelSelector)) @@ -79,7 +90,7 @@ public final class EventRuleFactory { * The filter string passed on the command-line * @return The corresponding event rule */ - public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) { + public EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) { StringJoiner sj1 = new StringJoiner(") && (", "(", ")"); sj1.add(extraFilter); sj1.add(filterStringFromEventName(eventName)); @@ -104,7 +115,7 @@ public final class EventRuleFactory { * * @return The corresponding event rule */ - public static EventRule createRuleAllEvents() { + public EventRule createRuleAllEvents() { return new EventRule(EVENT_NAME_ALL, LOG_LEVEL_UNSPECIFIED, ""); } @@ -112,13 +123,13 @@ public final class EventRuleFactory { return "logger_name == \"" + eventName + "\""; } - private static String filterStringFromLogLevel(LogLevelSelector logLevelSelector) { + private String filterStringFromLogLevel(LogLevelSelector logLevelSelector) { StringBuilder sb = new StringBuilder(); sb.append("int_loglevel "); switch (logLevelSelector.getLogLevelType()) { case LTTNG_EVENT_LOGLEVEL_RANGE: - sb.append(">="); + sb.append(domain.rangeOperator()); break; case LTTNG_EVENT_LOGLEVEL_SINGLE: sb.append("=="); @@ -131,5 +142,4 @@ public final class EventRuleFactory { sb.append(" " + logLevelSelector.getLogLevel()); return sb.toString(); } - } diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java index e46a718..e5ba5ec 100644 --- a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java @@ -98,4 +98,29 @@ public interface ILogLevelStrings { } }; + /** + * Values for log4j 2.x + */ + ILogLevelStrings LOG4J2_LOGLEVEL_STRINGS = new ILogLevelStrings() { + + @Override + public String warningName() { + return "warn"; + } + + @Override + public int warningInt() { + return 300; + } + + @Override + public String infoName() { + return "info"; + } + + @Override + public int infoInt() { + return 400; + } + }; } diff --git a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java index 0c0af7d..6313a6f 100644 --- a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java +++ b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java @@ -77,6 +77,8 @@ public class TcpClientIT { private static LttngTcpSessiondClient client; private static Thread clientThread; + private static EventRuleFactory eventRuleFactory = new EventRuleFactory(SESSION_DOMAIN); + private ILttngSession session; // ------------------------------------------------------------------------ @@ -179,7 +181,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, null, false, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); + eventRuleFactory.createRule(EVENT_NAME_A)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -193,7 +195,7 @@ public class TcpClientIT { session.enableAllEvents(); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRuleAllEvents()); + eventRuleFactory.createRuleAllEvents()); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -208,7 +210,7 @@ public class TcpClientIT { session.disableEvents(EVENT_NAME_A); List expectedEnableCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); + eventRuleFactory.createRule(EVENT_NAME_A)); List expectedDisableCommands = Collections.singletonList(EVENT_NAME_A); assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); @@ -226,9 +228,9 @@ public class TcpClientIT { session.disableAllEvents(); List expectedEnableCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B), - EventRuleFactory.createRule(EVENT_NAME_C)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_B), + eventRuleFactory.createRule(EVENT_NAME_C)); /* * A "disable-event -a" will send one command for each enabled event. * The order may be different though. @@ -248,7 +250,7 @@ public class TcpClientIT { session.enableAllEvents(); session.disableAllEvents(); - List expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents()); + List expectedEnableCommands = Arrays.asList(eventRuleFactory.createRuleAllEvents()); List expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL); assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); @@ -267,7 +269,7 @@ public class TcpClientIT { session2.enableEvent(EVENT_NAME_B, null, false, null); } // close(), aka destroy the session, sending "disable event" messages - List expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B)); + List expectedEnabledCommands = Arrays.asList(eventRuleFactory.createRule(EVENT_NAME_A), eventRuleFactory.createRule(EVENT_NAME_B)); List expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B); assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands()); @@ -284,7 +286,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); + eventRuleFactory.createRule(EVENT_NAME_A, lls)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -300,7 +302,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); + eventRuleFactory.createRule(EVENT_NAME_A, lls)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -318,8 +320,8 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2) ); List actualCommands = clientListener.getEnabledEventCommands(); @@ -338,8 +340,8 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2) ); List actualCommands = clientListener.getEnabledEventCommands(); @@ -361,8 +363,8 @@ public class TcpClientIT { session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2)); + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -382,9 +384,9 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, null, false, filter2); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -405,10 +407,10 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, lls), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), - EventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_A, lls), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), + eventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java index 45324a2..eccf1b3 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java @@ -26,6 +26,7 @@ import java.util.logging.Logger; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.lttng.ust.agent.utils.TestPrintExtension; @@ -35,6 +36,9 @@ import org.lttng.ust.agent.utils.TestPrintExtension; * test different types of log handlers. */ @ExtendWith(TestPrintExtension.class) +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public abstract class JulHandlerBenchmarkBase { // ------------------------------------------------------------------------ diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java index c3b8953..23bec90 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java @@ -22,12 +22,16 @@ import java.util.logging.Handler; import java.util.logging.LogRecord; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; /** * Test suite of using a "dummy" handler, which means a handler that does * exactly nothing. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase { /** diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java index 5437754..b6159b2 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java @@ -26,11 +26,15 @@ import java.util.logging.SimpleFormatter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; /** * Test class using a {@link FileHandler}, which a {@link SimpleFormatter}. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class FileHandlerBenchmark extends JulHandlerBenchmarkBase { private Path outputFile; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java index 09457d2..1fc5e9c 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java @@ -18,12 +18,16 @@ package org.lttng.ust.agent.benchmarks.jul.handler.builtin; +import org.junit.jupiter.api.Tag; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; /** * Benchmark that will attach no {@link java.util.logging.Handler} to the * {@link java.util.logging.Logger} object. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class NoHandlerBenchmark extends JulHandlerBenchmarkBase { /* Do not setup any handler */ diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java index fc16618..5b3da0b 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java @@ -20,12 +20,16 @@ package org.lttng.ust.agent.benchmarks.jul.handler.builtin; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; /** * Benchmark that will avoid creating a Logger entirely, to benchmark just the * bare worker. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class NoLoggerBenchmark extends JulHandlerBenchmarkBase { /** diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java index df7eca3..e5af33a 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java @@ -24,6 +24,7 @@ import java.io.IOException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; @@ -33,6 +34,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler; * Benchmark the LTTng-JUL handler, but with tracing disabled in the tracing * session. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { private ILttngSession session; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java index bdddeda..ee3af1b 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java @@ -24,6 +24,7 @@ import java.io.IOException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; @@ -32,6 +33,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler; /** * Test the LTTng-JUL handler, with it actually sending events to the tracer. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { private ILttngSession session; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java index 17c67e0..d6bf472 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.LTTngAgent; @@ -31,6 +32,9 @@ import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is * disabled in the tracing session. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") @SuppressWarnings("deprecation") public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java index a9985c4..70a19cf 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java @@ -25,6 +25,7 @@ import java.lang.reflect.Field; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.LTTngAgent; @@ -35,6 +36,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler; * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is * enabled in the tracing session. */ +@Tag("agent:jul") +@Tag("domain:jul") +@Tag("benchmark") @SuppressWarnings("deprecation") public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java index b5735f2..5ad024d 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * Enabled app contexts test for the LTTng-UST JUL log handler. */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulAppContextIT extends AppContextITBase { private static final Domain DOMAIN = Domain.JUL; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java index 1b488a4..69a1e7e 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * Implementation of {@link AppContextOrderingITBase} for the JUL API. */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulAppContextOrderingIT extends AppContextOrderingITBase { private Logger logger; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java index 02c1c74..a34f8a1 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * Enabled events test for the LTTng-UST JUL log handler. */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulEnabledEventsIT extends EnabledEventsITBase { private static final Domain DOMAIN = Domain.JUL; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java index 7b993f3..9a21701 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java @@ -35,6 +35,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.lttng.tools.ILttngSession; @@ -49,6 +50,8 @@ import org.lttng.ust.agent.utils.TestPrintExtension; */ @ExtendWith(TestPrintExtension.class) @SuppressWarnings("deprecation") +@Tag("agent:jul") +@Tag("domain:jul") public class JulLegacyApiIT { private static final Domain DOMAIN = Domain.JUL; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java index ed8a08d..4caec7b 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.lttng.tools.ILttngSession.Domain; @@ -45,6 +46,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; */ @SuppressWarnings("deprecation") //@RunWith(Parameterized.class) +@Tag("agent:jul") +@Tag("domain:jul") public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase { private LTTngAgent agent; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java index f3e2b1f..b493b02 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * Test suite for the list events command for the JUL domain */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulListEventsIT extends ListEventsITBase { private Logger[] loggers; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java index 0d588bf..9769798 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -36,6 +37,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; * * @author Alexandre Montplaisir */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase { private Logger parentLogger; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java index 633f8f0..d377b15 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * JUL tests for multiple concurrent tracing sessions */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulMultiSessionIT extends MultiSessionITBase { private static final Domain DOMAIN = Domain.JUL; diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java index 04f04ec..9b3eeea 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java @@ -22,6 +22,7 @@ import java.io.IOException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.ust.agent.ILttngHandler; import org.lttng.ust.agent.jul.LttngLogHandler; @@ -33,6 +34,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; * * @author Alexandre Montplaisir */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulFilterListenerIT extends FilterListenerITBase { /** @@ -65,5 +68,4 @@ public class JulFilterListenerIT extends FilterListenerITBase { protected ILogLevelStrings getLogLevelStrings() { return ILogLevelStrings.JUL_LOGLEVEL_STRINGS; } - } diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java index 5964c97..b82c12c 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java @@ -27,6 +27,7 @@ import java.util.logging.Logger; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.utils.JulTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils; /** * Implementation of {@link FilterListenerOrderingITBase} for the JUL API. */ +@Tag("agent:jul") +@Tag("domain:jul") public class JulFilterListenerOrderingIT extends FilterListenerOrderingITBase { private Logger logger; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java index c7670ea..7c84702 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; import org.lttng.ust.agent.utils.Log4jTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Enabled app contexts test for the LTTng-UST JUL log handler. */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jAppContextIT extends AppContextITBase { private static final Domain DOMAIN = Domain.LOG4J; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java index 02e0cea..cb3055a 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java @@ -28,6 +28,7 @@ import org.apache.log4j.Logger; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; import org.lttng.ust.agent.utils.Log4jTestUtils; @@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Implementation of {@link AppContextOrderingITBase} for the log4j API. */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jAppContextOrderingIT extends AppContextOrderingITBase { private Logger logger; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java index 579d43c..0d293a6 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; @@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Enabled events test for the LTTng-UST Log4j log handler. */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jEnabledEventsIT extends EnabledEventsITBase { private static final Domain DOMAIN = Domain.LOG4J; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java index a82857c..9cece27 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java @@ -33,6 +33,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.lttng.tools.ILttngSession; @@ -48,6 +49,8 @@ import org.lttng.ust.agent.utils.TestPrintExtension; */ @ExtendWith(TestPrintExtension.class) @SuppressWarnings("deprecation") +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jLegacyApiIT { private static final Domain DOMAIN = Domain.LOG4J; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java index 241e47c..90fa963 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.ust.agent.log4j.LttngLogAppender; import org.lttng.ust.agent.utils.Log4jTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Test suite for the list events command for the log4j domain */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jListEventsIT extends ListEventsITBase { private Logger[] loggers; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java index 5040506..3b0943f 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; import org.lttng.ust.agent.utils.Log4jTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Log4j tests for multiple concurrent tracing sessions */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jMultiSessionIT extends MultiSessionITBase { private static final Domain DOMAIN = Domain.LOG4J; diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java index cc55f40..d4e5aa6 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java @@ -22,6 +22,7 @@ import java.io.IOException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; import org.lttng.ust.agent.ILttngHandler; import org.lttng.ust.agent.log4j.LttngLogAppender; @@ -33,6 +34,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; * * @author Alexandre Montplaisir */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jFilterListenerIT extends FilterListenerITBase { /** @@ -65,5 +68,4 @@ public class Log4jFilterListenerIT extends FilterListenerITBase { protected ILogLevelStrings getLogLevelStrings() { return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS; } - } diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java index 5b3d1d4..7e92c97 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java @@ -27,6 +27,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; import org.lttng.ust.agent.utils.Log4jTestUtils; @@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils; /** * Implementation of {@link FilterListenerOrderingITBase} for the log4j API. */ +@Tag("agent:log4j") +@Tag("domain:log4j") public class Log4jFilterListenerOrderingIT extends FilterListenerOrderingITBase { private Logger logger; diff --git a/lttng-ust-java-tests-log4j2/.classpath b/lttng-ust-java-tests-log4j2/.classpath index 8f6300a..3b348b7 100644 --- a/lttng-ust-java-tests-log4j2/.classpath +++ b/lttng-ust-java-tests-log4j2/.classpath @@ -1,5 +1,6 @@ + @@ -12,7 +13,6 @@ - diff --git a/lttng-ust-java-tests-log4j2/pom.xml b/lttng-ust-java-tests-log4j2/pom.xml index 1eb7d27..03fb51e 100644 --- a/lttng-ust-java-tests-log4j2/pom.xml +++ b/lttng-ust-java-tests-log4j2/pom.xml @@ -61,7 +61,9 @@ org.junit.jupiter junit-jupiter - test + + compile diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java new file mode 100644 index 0000000..8731b75 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.context; + +import java.io.IOException; + +import org.apache.logging.log4j.core.Logger; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler. + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2AppContextITBase extends AppContextITBase { + + private Log4j2TestContext testContext; + private Logger logger; + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @SuppressWarnings("resource") + @BeforeEach + public void log4j2Setup() throws SecurityException, IOException { + testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml"); + + testContext.beforeTest(); + + logger = testContext.getLoggerContext().getLogger(EVENT_NAME); + + logHandler = (ILttngHandler) logger.getAppenders().get("Lttng"); + } + + /** + * Test teardown + */ + @AfterEach + public void log4j2Teardown() { + testContext.afterTest(); + logger = null; + } + + @Override + protected boolean closeHandlers() + { + return false; + } + + @Override + protected void sendEventsToLoggers() { + Log4j2TestUtils.send10Events(logger); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java new file mode 100644 index 0000000..f53efac --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.context; + + +import org.apache.logging.log4j.core.Logger; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Implementation of {@link AppContextOrderingITBase} for the log4j API. + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2AppContextOrderingITBase extends AppContextOrderingITBase { + + private Log4j2TestContext testContext; + private Logger logger; + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + /** + * Test teardown + */ + @AfterEach + public void log4j2Teardown() { + logger = null; + logHandler = null; + + testContext.afterTest(); + } + + @SuppressWarnings("resource") + @Override + protected void registerAgent() { + testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml"); + + testContext.beforeTest(); + + logger = testContext.getLoggerContext().getLogger(EVENT_NAME); + + logHandler = (ILttngHandler) logger.getAppenders().get("Lttng"); + } + + @Override + protected void sendEventsToLoggers() { + Log4j2TestUtils.send10Events(logger); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java new file mode 100644 index 0000000..7d21a77 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import java.io.IOException; + +import org.apache.logging.log4j.core.Logger; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Enabled events test for the LTTng-UST Log4j 2.x log handler. + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2EnabledEventsITBase extends EnabledEventsITBase { + + private static final String APPENDER_NAME_A = "LttngA"; + private static final String APPENDER_NAME_B = "LttngB"; + private static final String APPENDER_NAME_C = "LttngC"; + + private Log4j2TestContext testContext; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @SuppressWarnings("resource") + @BeforeEach + public void log4j2Setup() throws SecurityException, IOException { + + testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml"); + + testContext.beforeTest(); + + loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A); + loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B); + loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C); + loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D); + + handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A); + handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B); + handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C); + } + + /** + * Test teardown + */ + @AfterEach + public void log4j2Teardown() { + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + + testContext.afterTest(); + } + + @Override + protected boolean closeHandlers() + { + return false; + } + + @Override + protected void sendEventsToLoggers() { + Log4j2TestUtils.send10Events(loggerA); + Log4j2TestUtils.send10Events(loggerB); + Log4j2TestUtils.send10Events(loggerC); + Log4j2TestUtils.send10Events(loggerD); + } + + @Override + protected void sendLocalizedEvent(String rawString, Object[] params) { + throw new UnsupportedOperationException(); + } + + @Override + @Test + public void testLocalizedMessage() { + /* Does not apply to log4j 1.2.x */ + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java new file mode 100644 index 0000000..3d1130f --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.extension.ExtendWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; +import org.lttng.ust.agent.utils.TestPrintExtension; + +/** + * Test suite for the list events command for the log4j domain + */ +@TestInstance(Lifecycle.PER_CLASS) +@ExtendWith(TestPrintExtension.class) +public abstract class Log4j2ListEventsITBase { + + protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent"; + protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent"; + protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent-àéç"; + + @SuppressWarnings("unused") + private Logger logger1; + @SuppressWarnings("unused") + private Logger logger2; + @SuppressWarnings("unused") + private Logger logger3; + + private ILttngSession session; + private Log4j2TestContext testContext; + + protected abstract Domain getDomain(); + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + /** + * Create a new session before each test. + * + * @param testInfo + * current test information + */ + @SuppressWarnings("resource") + @BeforeEach + public void testSetup(TestInfo testInfo) { + session = ILttngSession.createSession("Log4j2ListEventsIT", getDomain()); + + testContext = new Log4j2TestContext( + "log4j2." + getDomain() + testInfo.getDisplayName().replaceAll("[()]", "") + ".xml"); + + testContext.beforeTest(); + + logger1 = testContext.getLoggerContext().getLogger(LOGGER_NAME_1); + logger2 = testContext.getLoggerContext().getLogger(LOGGER_NAME_2); + logger3 = testContext.getLoggerContext().getLogger(LOGGER_NAME_3); + } + + /** + * Close the current session after each test. + */ + @AfterEach + public void testTeardown() { + session.close(); + testContext.afterTest(); + } + + /** + * Test with many loggers existing, but none of them having a LTTng handler + * attached. + */ + @Test + public void testManyLoggersNoneAttached() { + + /* Don't attach anything */ + List actualEvents = session.listEvents(); + assertTrue(actualEvents.isEmpty()); + } + + /** + * Test with many loggers existing, but only a subset of them has a LTTng + * handler attached. + */ + @Test + public void testManyLoggersSomeAttached() { + + List expectedEvents = Arrays.asList(LOGGER_NAME_1); + List actualEvents = session.listEvents(); + + Collections.sort(expectedEvents); + Collections.sort(actualEvents); + + assertEquals(expectedEvents, actualEvents); + } + + /** + * Test with many loggers existing, and all of them having a LTTng handler + * attached. + */ + @Test + public void testManyLoggersAllAttached() { + + List expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3); + List actualEvents = session.listEvents(); + + Collections.sort(expectedEvents); + Collections.sort(actualEvents); + + assertEquals(expectedEvents, actualEvents); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java new file mode 100644 index 0000000..3147d22 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import java.io.IOException; + +import org.apache.logging.log4j.core.Logger; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Log4j tests for multiple concurrent tracing sessions + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2MultiSessionITBase extends MultiSessionITBase { + + protected static final String APPENDER_NAME_A = "LttngA"; + protected static final String APPENDER_NAME_B = "LttngB"; + protected static final String APPENDER_NAME_C = "LttngC"; + protected static final String APPENDER_NAME_D = "LttngD"; + + private Log4j2TestContext testContext; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @SuppressWarnings("resource") + @BeforeEach + public void log4j2Setup() throws SecurityException, IOException { + + testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml"); + + testContext.beforeTest(); + + loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A); + loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B); + loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C); + loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D); + + handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A); + handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B); + handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C); + handlerD = (ILttngHandler) loggerD.getAppenders().get(APPENDER_NAME_D); + } + + /** + * Test teardown + */ + @AfterEach + public void log4j2Teardown() { + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + + testContext.afterTest(); + } + + @Override + protected boolean closeHandlers() { + return false; + } + + @Override + protected void sendEventsToLoggers() { + Log4j2TestUtils.send10Events(loggerA); + Log4j2TestUtils.send10Events(loggerB); + Log4j2TestUtils.send10Events(loggerC); + Log4j2TestUtils.send10Events(loggerD); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java new file mode 100644 index 0000000..834b957 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import java.io.IOException; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.log4j2.LttngLogAppender; + +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Filter notifications tests using the log4j logging API. + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2FilterListenerITBase extends FilterListenerITBase { + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getSessionDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + @Override + protected ILttngHandler getLogHandler() throws SecurityException, IOException { + return LttngLogAppender.createAppender(this.getClass().getSimpleName(), getSessionDomain().toString(), null, null); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java new file mode 100644 index 0000000..caa2dbf --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.lttng.ust.agent.utils.Log4j2TestContext; +import org.lttng.ust.agent.utils.Log4j2TestUtils; + +/** + * Implementation of {@link FilterListenerOrderingITBase} for the log4j API. + */ +@TestInstance(Lifecycle.PER_CLASS) +public abstract class Log4j2FilterListenerOrderingITBase extends FilterListenerOrderingITBase { + + private Log4j2TestContext testContext; + + /** + * Class setup + */ + @BeforeAll + public void log4j2ClassSetup() { + Log4j2TestUtils.testClassSetup(getDomain()); + } + + /** + * Class cleanup + */ + @AfterAll + public static void log4j2ClassCleanup() { + Log4j2TestUtils.testClassCleanup(); + } + + @Override + protected void registerAgent() { + testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml"); + testContext.beforeTest(); + } + + @Override + protected void deregisterAgent() { + testContext.afterTest(); + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestContext.java similarity index 100% rename from lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java rename to lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestContext.java diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java similarity index 87% rename from lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java rename to lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java index 33eed8e..68e7ff4 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java +++ b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java @@ -40,11 +40,12 @@ public final class Log4j2TestUtils { /** * Setup method common to most log4j tests. To be called in a @BeforeClass. + * @param domain the tracing domain to operate on */ - public static void testClassSetup() { + public static void testClassSetup(Domain domain) { /* Make sure we can find the JNI library and lttng-tools */ - checkForLog4jLibrary(); - assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J), "lttng-tools is not working properly."); + checkForLog4jLibrary(domain); + assertTrue(LttngUtils.checkForLttngTools(domain), "lttng-tools is not working properly."); LttngToolsHelper.destroyAllSessions(); } @@ -60,11 +61,11 @@ public final class Log4j2TestUtils { * Check the the Log4j native library is available, effectively allowing * LTTng Log4j appenders to be used. */ - private static void checkForLog4jLibrary() { + private static void checkForLog4jLibrary(Domain domain) { try { - LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", null, null); + LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", domain.toString(), null, null); testAppender.close(); - } catch (SecurityException | IOException e) { + } catch (SecurityException e) { fail(e.getMessage()); } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java index 7a00b4b..f215aa4 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java @@ -18,84 +18,19 @@ package org.lttng.ust.agent.integration.context; -import java.io.IOException; - -import org.apache.logging.log4j.core.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler. */ -public class Log4j2AppContextIT extends AppContextITBase { - - private static final Domain DOMAIN = Domain.LOG4J; - - private Log4j2TestContext testContext; - private Logger logger; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @SuppressWarnings("resource") - @BeforeEach - public void log4j2Setup() throws SecurityException, IOException { - testContext = new Log4j2TestContext("log4j2.Log4j2AppContextIT.xml"); - - testContext.beforeTest(); - - logger = testContext.getLoggerContext().getLogger(EVENT_NAME); - - logHandler = (ILttngHandler) logger.getAppenders().get("Lttng"); - } - - /** - * Test teardown - */ - @AfterEach - public void log4j2Teardown() { - testContext.afterTest(); - logger = null; - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2AppContextIT extends Log4j2AppContextITBase { @Override protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected boolean closeHandlers() - { - return false; - } - - @Override - protected void sendEventsToLoggers() { - Log4j2TestUtils.send10Events(logger); + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java index a015f13..2843ad6 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java @@ -18,70 +18,19 @@ package org.lttng.ust.agent.integration.context; - -import org.apache.logging.log4j.core.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** * Implementation of {@link AppContextOrderingITBase} for the log4j API. */ -public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase { - - private Log4j2TestContext testContext; - private Logger logger; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } - - /** - * Test teardown - */ - @AfterEach - public void log4j2Teardown() { - logger = null; - logHandler = null; - - testContext.afterTest(); - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2AppContextOrderingIT extends Log4j2AppContextOrderingITBase { @Override protected Domain getDomain() { - return Domain.LOG4J; - } - - @SuppressWarnings("resource") - @Override - protected void registerAgent() { - testContext = new Log4j2TestContext("log4j2.Log4j2AppContextOrderingIT.xml"); - - testContext.beforeTest(); - - logger = testContext.getLoggerContext().getLogger(EVENT_NAME); - - logHandler = (ILttngHandler) logger.getAppenders().get("Lttng"); - } - - @Override - protected void sendEventsToLoggers() { - Log4j2TestUtils.send10Events(logger); + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java new file mode 100644 index 0000000..9de5a65 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.context; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler. + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatAppContextIT extends Log4j2AppContextITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java new file mode 100644 index 0000000..b558b35 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.context; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Implementation of {@link AppContextOrderingITBase} for the log4j API. + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatAppContextOrderingIT extends Log4j2AppContextOrderingITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java new file mode 100644 index 0000000..8fa3c8a --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Enabled events test for the LTTng-UST Log4j 2.x log handler. + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatEnabledEventsIT extends Log4j2EnabledEventsITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java new file mode 100644 index 0000000..8d845d7 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Test suite for the list events command for the log4j domain + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatListEventsIT extends Log4j2ListEventsITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java new file mode 100644 index 0000000..a28d935 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Log4j tests for multiple concurrent tracing sessions + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatMultiSessionIT extends Log4j2MultiSessionITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java index 1bbf4e4..de0d3a6 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java @@ -18,117 +18,19 @@ package org.lttng.ust.agent.integration.events; -import java.io.IOException; - -import org.apache.logging.log4j.core.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** - * Enabled events test for the LTTng-UST Log4j log handler. + * Enabled events test for the LTTng-UST Log4j 2.x log handler. */ -public class Log4j2EnabledEventsIT extends EnabledEventsITBase { - - private static final String APPENDER_NAME_A = "LttngA"; - private static final String APPENDER_NAME_B = "LttngB"; - private static final String APPENDER_NAME_C = "LttngC"; - - private static final Domain DOMAIN = Domain.LOG4J; - - private Log4j2TestContext testContext; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @SuppressWarnings("resource") - @BeforeEach - public void log4j2Setup() throws SecurityException, IOException { - - testContext = new Log4j2TestContext("log4j2.Log4j2EnabledEventsIT.xml"); - - testContext.beforeTest(); - - loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A); - loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B); - loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C); - loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D); - - handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A); - handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B); - handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C); - } - - /** - * Test teardown - */ - @AfterEach - public void log4j2Teardown() { - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - - testContext.afterTest(); - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2EnabledEventsIT extends Log4j2EnabledEventsITBase { @Override protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected boolean closeHandlers() - { - return false; - } - - @Override - protected void sendEventsToLoggers() { - Log4j2TestUtils.send10Events(loggerA); - Log4j2TestUtils.send10Events(loggerB); - Log4j2TestUtils.send10Events(loggerC); - Log4j2TestUtils.send10Events(loggerD); - } - - @Override - protected void sendLocalizedEvent(String rawString, Object[] params) { - throw new UnsupportedOperationException(); - } - - @Override - @Test - public void testLocalizedMessage() { - /* Does not apply to log4j 1.2.x */ + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java index 04676b6..6d0c18e 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java @@ -18,130 +18,19 @@ package org.lttng.ust.agent.integration.events; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.lttng.tools.ILttngSession; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; -import org.lttng.ust.agent.utils.TestPrintExtension; /** * Test suite for the list events command for the log4j domain */ -@ExtendWith(TestPrintExtension.class) -public class Log4j2ListEventsIT { - - protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent"; - protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent"; - protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent-àéç"; - - @SuppressWarnings("unused") - private Logger logger1; - @SuppressWarnings("unused") - private Logger logger2; - @SuppressWarnings("unused") - private Logger logger3; - - private ILttngSession session; - private Log4j2TestContext testContext; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } - - /** - * Create a new session before each test. - * @param testInfo current test information - */ - @SuppressWarnings("resource") - @BeforeEach - public void testSetup(TestInfo testInfo) { - session = ILttngSession.createSession("Log4j2ListEventsIT", ILttngSession.Domain.LOG4J); - - testContext = new Log4j2TestContext("log4j2." + testInfo.getDisplayName().replaceAll("[()]", "") + ".xml"); - - testContext.beforeTest(); - - logger1 = testContext.getLoggerContext().getLogger(LOGGER_NAME_1); - logger2 = testContext.getLoggerContext().getLogger(LOGGER_NAME_2); - logger3 = testContext.getLoggerContext().getLogger(LOGGER_NAME_3); - } - - /** - * Close the current session after each test. - */ - @AfterEach - public void testTeardown() { - session.close(); - testContext.afterTest(); - } - - /** - * Test with many loggers existing, but none of them having a LTTng handler - * attached. - */ - @Test - public void testManyLoggersNoneAttached() { - - /* Don't attach anything */ - List actualEvents = session.listEvents(); - assertTrue(actualEvents.isEmpty()); - } - - /** - * Test with many loggers existing, but only a subset of them has a LTTng - * handler attached. - */ - @Test - public void testManyLoggersSomeAttached() { - - List expectedEvents = Arrays.asList(LOGGER_NAME_1); - List actualEvents = session.listEvents(); - - Collections.sort(expectedEvents); - Collections.sort(actualEvents); - - assertEquals(expectedEvents, actualEvents); - } - - /** - * Test with many loggers existing, and all of them having a LTTng handler - * attached. - */ - @Test - public void testManyLoggersAllAttached() { - - List expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3); - List actualEvents = session.listEvents(); - - Collections.sort(expectedEvents); - Collections.sort(actualEvents); +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2ListEventsIT extends Log4j2ListEventsITBase { - assertEquals(expectedEvents, actualEvents); + @Override + protected Domain getDomain() { + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java index 36eb435..1d2c998 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java @@ -18,107 +18,19 @@ package org.lttng.ust.agent.integration.events; -import java.io.IOException; - -import org.apache.logging.log4j.core.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** * Log4j tests for multiple concurrent tracing sessions */ -public class Log4j2MultiSessionIT extends MultiSessionITBase { - - private static final String APPENDER_NAME_A = "LttngA"; - private static final String APPENDER_NAME_B = "LttngB"; - private static final String APPENDER_NAME_C = "LttngC"; - private static final String APPENDER_NAME_D = "LttngD"; - - private static final Domain DOMAIN = Domain.LOG4J; - - private Log4j2TestContext testContext; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @SuppressWarnings("resource") - @BeforeEach - public void log4j2Setup() throws SecurityException, IOException { - - testContext = new Log4j2TestContext("log4j2.Log4j2MultiSessionIT.xml"); - - testContext.beforeTest(); - - loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A); - loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B); - loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C); - loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D); - - handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A); - handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B); - handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C); - handlerD = (ILttngHandler) loggerD.getAppenders().get(APPENDER_NAME_D); - } - - /** - * Test teardown - */ - @AfterEach - public void log4j2Teardown() { - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - - testContext.afterTest(); - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2MultiSessionIT extends Log4j2MultiSessionITBase { @Override protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected boolean closeHandlers() - { - return false; - } - - @Override - protected void sendEventsToLoggers() { - Log4j2TestUtils.send10Events(loggerA); - Log4j2TestUtils.send10Events(loggerB); - Log4j2TestUtils.send10Events(loggerC); - Log4j2TestUtils.send10Events(loggerD); + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java new file mode 100644 index 0000000..9f0c903 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession; +import org.lttng.ust.agent.utils.ILogLevelStrings; + + +/** + * Filter notifications tests using the log4j logging API. + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatFilterListenerIT extends Log4j2FilterListenerITBase { + + @Override + protected ILttngSession.Domain getSessionDomain() { + return ILttngSession.Domain.LOG4J; + } + + @Override + protected ILogLevelStrings getLogLevelStrings() { + return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java new file mode 100644 index 0000000..2849f4e --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022, EfficiOS Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import org.junit.jupiter.api.Tag; +import org.lttng.tools.ILttngSession.Domain; + + +/** + * Implementation of {@link FilterListenerOrderingITBase} for the log4j API. + */ +@Tag("agent:log4j2") +@Tag("domain:log4j") +public class Log4j2CompatFilterListenerOrderingIT extends Log4j2FilterListenerOrderingITBase { + + @Override + protected Domain getDomain() { + return Domain.LOG4J; + } +} diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java index 7e2beb7..ecc1ba2 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java @@ -18,52 +18,25 @@ package org.lttng.ust.agent.integration.filter; -import java.io.IOException; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.log4j2.LttngLogAppender; import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** * Filter notifications tests using the log4j logging API. - * - * @author Alexandre Montplaisir */ -public class Log4j2FilterListenerIT extends FilterListenerITBase { - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2FilterListenerIT extends Log4j2FilterListenerITBase { @Override protected ILttngSession.Domain getSessionDomain() { - return ILttngSession.Domain.LOG4J; - } - - @Override - protected ILttngHandler getLogHandler() throws SecurityException, IOException { - return LttngLogAppender.createAppender("Log4j2FilterListenerIT", null, null); + return ILttngSession.Domain.LOG4J2; } @Override protected ILogLevelStrings getLogLevelStrings() { - return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS; + return ILogLevelStrings.LOG4J2_LOGLEVEL_STRINGS; } - } diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java index 03e8f9e..7a60bb2 100644 --- a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java +++ b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java @@ -18,48 +18,19 @@ package org.lttng.ust.agent.integration.filter; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.utils.Log4j2TestContext; -import org.lttng.ust.agent.utils.Log4j2TestUtils; + /** * Implementation of {@link FilterListenerOrderingITBase} for the log4j API. */ -public class Log4j2FilterListenerOrderingIT extends FilterListenerOrderingITBase { - - private Log4j2TestContext testContext; - - /** - * Class setup - */ - @BeforeAll - public static void log4j2ClassSetup() { - Log4j2TestUtils.testClassSetup(); - } - - /** - * Class cleanup - */ - @AfterAll - public static void log4j2ClassCleanup() { - Log4j2TestUtils.testClassCleanup(); - } +@Tag("agent:log4j2") +@Tag("domain:log4j2") +public class Log4j2FilterListenerOrderingIT extends Log4j2FilterListenerOrderingITBase { @Override protected Domain getDomain() { - return Domain.LOG4J; - } - - @Override - protected void registerAgent() { - testContext = new Log4j2TestContext("log4j2.Log4j2FilterListenerOrderingIT.xml"); - testContext.beforeTest(); - } - - @Override - protected void deregisterAgent() { - testContext.afterTest(); + return Domain.LOG4J2; } } diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml new file mode 100644 index 0000000..3cf465f --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml new file mode 100644 index 0000000..3275ec9 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml new file mode 100644 index 0000000..350e7a0 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml similarity index 85% rename from lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml rename to lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml index 979a1e2..0a6714e 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml similarity index 83% rename from lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml rename to lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml index ffbbd03..0e69868 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml similarity index 84% rename from lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml rename to lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml index de5e9cd..cc93c0c 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextIT.xml index 11016e1..0f1f0b6 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextIT.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextIT.xml @@ -4,7 +4,7 @@ - + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextOrderingIT.xml index 6c812c5..1509542 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextOrderingIT.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextOrderingIT.xml @@ -4,7 +4,7 @@ - + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml new file mode 100644 index 0000000..bdc4d27 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml new file mode 100644 index 0000000..79dd3f3 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml new file mode 100644 index 0000000..56a0aaf --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml new file mode 100644 index 0000000..aa95f59 --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml new file mode 100644 index 0000000..4c5f86d --- /dev/null +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2EnabledEventsIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2EnabledEventsIT.xml index a55444c..ab2e7d8 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2EnabledEventsIT.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2EnabledEventsIT.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2FilterListenerOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2FilterListenerOrderingIT.xml index 54f5ce0..46dba21 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2FilterListenerOrderingIT.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2FilterListenerOrderingIT.xml @@ -4,7 +4,7 @@ - + diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2MultiSessionIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2MultiSessionIT.xml index 22e5be1..c4ab05d 100644 --- a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2MultiSessionIT.xml +++ b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2MultiSessionIT.xml @@ -4,10 +4,10 @@ - - - - + + + + diff --git a/pom.xml b/pom.xml index 68c634a..97aa28c 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,16 @@ + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + org.apache.maven.plugins maven-failsafe-plugin @@ -165,7 +175,6 @@ org.lttng.ust lttng-ust-java-tests-common 1.1.0-SNAPSHOT - test -- 2.34.1