[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
----------------------
*/
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;
}
/**
public String flag() {
return flag;
}
+
+ public String rangeOperator() {
+ return rangeOperator;
+ }
+
+ public int levelAllValue() {
+ return levelAllValue;
+ }
}
// ------------------------------------------------------------------------
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
*
@Test
public void testOneRule() {
Set<EventRule> rules = Collections.singleton(
- EventRuleFactory.createRule(EVENT_NAME_A));
+ getEventRuleFactory().createRule(EVENT_NAME_A));
session.enableEvent(EVENT_NAME_A, null, false, null);
@Test
public void testManyRules() {
Set<EventRule> 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);
@Test
public void testManyRulesDisableSome() {
Set<EventRule> 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);
LogLevelSelector lls3 = new LogLevelSelector(getLogLevelStrings().infoInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
Set<EventRule> 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);
String filterB = "filterB";
Set<EventRule> 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);
@Test
public void testDetachingListener() {
Set<EventRule> 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);
fcn.registerListener(listener3);
Set<EventRule> 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);
fcn.unregisterListener(listener2);
Set<EventRule> 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);
TestFilterListener listener2 = new TestFilterListener();
Set<EventRule> 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<EventRule> 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);
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;
session = null;
}
+ protected EventRuleFactory getEventRuleFactory() {
+ if (eventRuleFactory == null) {
+ eventRuleFactory = new EventRuleFactory(getDomain());
+ }
+ return eventRuleFactory;
+ }
+
// ------------------------------------------------------------------------
// Test methods
// ------------------------------------------------------------------------
*/
private void checkOngoingConditions() {
Set<EventRule> 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());
import java.util.StringJoiner;
+import org.lttng.tools.ILttngSession;
import org.lttng.ust.agent.session.EventRule;
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.
* 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));
}
* 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))
* 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));
*
* @return The corresponding event rule
*/
- public static EventRule createRuleAllEvents() {
+ public EventRule createRuleAllEvents() {
return new EventRule(EVENT_NAME_ALL, LOG_LEVEL_UNSPECIFIED, "");
}
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("==");
sb.append(" " + logLevelSelector.getLogLevel());
return sb.toString();
}
-
}
}
};
+ /**
+ * 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;
+ }
+ };
}
private static LttngTcpSessiondClient client;
private static Thread clientThread;
+ private static EventRuleFactory eventRuleFactory = new EventRuleFactory(SESSION_DOMAIN);
+
private ILttngSession session;
// ------------------------------------------------------------------------
session.enableEvent(EVENT_NAME_A, null, false, null);
List<EventRule> expectedCommands = Collections.singletonList(
- EventRuleFactory.createRule(EVENT_NAME_A));
+ eventRuleFactory.createRule(EVENT_NAME_A));
List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.enableAllEvents();
List<EventRule> expectedCommands = Collections.singletonList(
- EventRuleFactory.createRuleAllEvents());
+ eventRuleFactory.createRuleAllEvents());
List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.disableEvents(EVENT_NAME_A);
List<EventRule> expectedEnableCommands = Collections.singletonList(
- EventRuleFactory.createRule(EVENT_NAME_A));
+ eventRuleFactory.createRule(EVENT_NAME_A));
List<String> expectedDisableCommands = Collections.singletonList(EVENT_NAME_A);
assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
session.disableAllEvents();
List<EventRule> 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.
session.enableAllEvents();
session.disableAllEvents();
- List<EventRule> expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents());
+ List<EventRule> expectedEnableCommands = Arrays.asList(eventRuleFactory.createRuleAllEvents());
List<String> expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL);
assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
session2.enableEvent(EVENT_NAME_B, null, false, null);
} // close(), aka destroy the session, sending "disable event" messages
- List<EventRule> expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B));
+ List<EventRule> expectedEnabledCommands = Arrays.asList(eventRuleFactory.createRule(EVENT_NAME_A), eventRuleFactory.createRule(EVENT_NAME_B));
List<String> expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands());
session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
List<EventRule> expectedCommands = Collections.singletonList(
- EventRuleFactory.createRule(EVENT_NAME_A, lls));
+ eventRuleFactory.createRule(EVENT_NAME_A, lls));
List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
List<EventRule> expectedCommands = Collections.singletonList(
- EventRuleFactory.createRule(EVENT_NAME_A, lls));
+ eventRuleFactory.createRule(EVENT_NAME_A, lls));
List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
List<EventRule> 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<EventRule> actualCommands = clientListener.getEnabledEventCommands();
session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
List<EventRule> 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<EventRule> actualCommands = clientListener.getEnabledEventCommands();
session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
List<EventRule> 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<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.enableEvent(EVENT_NAME_A, null, false, filter2);
List<EventRule> 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<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter);
List<EventRule> 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<EventRule> actualCommands = clientListener.getEnabledEventCommands();
assertEquals(expectedCommands, actualCommands);
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;
* test different types of log handlers.
*/
@ExtendWith(TestPrintExtension.class)
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
public abstract class JulHandlerBenchmarkBase {
// ------------------------------------------------------------------------
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 {
/**
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;
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 */
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 {
/**
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;
* 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;
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;
/**
* 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;
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;
* 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 {
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;
* 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 {
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;
/**
* 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;
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;
/**
* Implementation of {@link AppContextOrderingITBase} for the JUL API.
*/
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulAppContextOrderingIT extends AppContextOrderingITBase {
private Logger logger;
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;
/**
* 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;
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;
*/
@ExtendWith(TestPrintExtension.class)
@SuppressWarnings("deprecation")
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulLegacyApiIT {
private static final Domain DOMAIN = Domain.JUL;
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;
*/
@SuppressWarnings("deprecation")
//@RunWith(Parameterized.class)
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase {
private LTTngAgent agent;
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;
/**
* 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;
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;
*
* @author Alexandre Montplaisir
*/
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
private Logger parentLogger;
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;
/**
* 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;
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;
*
* @author Alexandre Montplaisir
*/
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulFilterListenerIT extends FilterListenerITBase {
/**
protected ILogLevelStrings getLogLevelStrings() {
return ILogLevelStrings.JUL_LOGLEVEL_STRINGS;
}
-
}
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;
/**
* Implementation of {@link FilterListenerOrderingITBase} for the JUL API.
*/
+@Tag("agent:jul")
+@Tag("domain:jul")
public class JulFilterListenerOrderingIT extends FilterListenerOrderingITBase {
private Logger logger;
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;
/**
* 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;
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;
/**
* Implementation of {@link AppContextOrderingITBase} for the log4j API.
*/
+@Tag("agent:log4j")
+@Tag("domain:log4j")
public class Log4jAppContextOrderingIT extends AppContextOrderingITBase {
private Logger logger;
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;
/**
* 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;
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;
*/
@ExtendWith(TestPrintExtension.class)
@SuppressWarnings("deprecation")
+@Tag("agent:log4j")
+@Tag("domain:log4j")
public class Log4jLegacyApiIT {
private static final Domain DOMAIN = Domain.LOG4J;
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;
/**
* 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;
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;
/**
* 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;
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;
*
* @author Alexandre Montplaisir
*/
+@Tag("agent:log4j")
+@Tag("domain:log4j")
public class Log4jFilterListenerIT extends FilterListenerITBase {
/**
protected ILogLevelStrings getLogLevelStrings() {
return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS;
}
-
}
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;
/**
* Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
*/
+@Tag("agent:log4j")
+@Tag("domain:log4j")
public class Log4jFilterListenerOrderingIT extends FilterListenerOrderingITBase {
private Logger logger;
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/lttng-ust-java-tests-common"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/lttng-ust-java-tests-common"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
- <scope>test</scope>
+ <!-- Special case here, we ship abstract test classes in the jar, so we
+ need the JUnit dependency all the time. -->
+ <scope>compile</scope>
</dependency>
</dependencies>
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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 */
+ }
+}
--- /dev/null
+/*
+ * 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<String> 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<String> expectedEvents = Arrays.asList(LOGGER_NAME_1);
+ List<String> 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<String> expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3);
+ List<String> actualEvents = session.listEvents();
+
+ Collections.sort(expectedEvents);
+ Collections.sort(actualEvents);
+
+ assertEquals(expectedEvents, actualEvents);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+}
--- /dev/null
+/*
+ * 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.utils;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+
+/**
+ * Log4j 2.x test context utilities.
+ */
+public class Log4j2TestContext {
+
+ private final URI configFileUri;
+
+ private LoggerContext loggerContext;
+
+ /**
+ * @param configFile path to the log4j configuration file.
+ */
+ public Log4j2TestContext(String configFile) {
+
+ URL resource = getClass().getClassLoader().getResource(configFile);
+
+ if (resource == null) {
+ throw new IllegalArgumentException("Config file not found: " + configFile);
+ }
+
+ try {
+ this.configFileUri = resource.toURI();
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Config file invalid URI: " + resource);
+ }
+ }
+
+ /**
+ * @return the log4j2 logger context.
+ */
+ public synchronized LoggerContext getLoggerContext() {
+ return loggerContext;
+ }
+
+ /**
+ * Initialize the log4j2 context before running a test.
+ */
+ public synchronized void beforeTest() {
+ loggerContext = (LoggerContext) LogManager.getContext(
+ ClassLoader.getSystemClassLoader(), false, configFileUri);
+ }
+
+ /**
+ * Dispose of the log4j2 context after running a test.
+ */
+ public synchronized void afterTest() {
+ loggerContext.stop();
+ }
+}
--- /dev/null
+/*
+ * 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.utils;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.lttng.tools.ILttngSession.Domain;
+import org.lttng.tools.LttngToolsHelper;
+import org.lttng.ust.agent.log4j2.LttngLogAppender;
+
+
+/**
+ * Utility methods for log4j 2.x tests
+ */
+public final class Log4j2TestUtils {
+
+ private 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(Domain domain) {
+ /* Make sure we can find the JNI library and lttng-tools */
+ checkForLog4jLibrary(domain);
+ assertTrue(LttngUtils.checkForLttngTools(domain), "lttng-tools is not working properly.");
+
+ LttngToolsHelper.destroyAllSessions();
+ }
+
+ /**
+ * Teardown method common to most log4j tests. To be called in a @AfterClass.
+ */
+ public static void testClassCleanup() {
+ LttngToolsHelper.deleteAllTraces();
+ }
+
+ /**
+ * Check the the Log4j native library is available, effectively allowing
+ * LTTng Log4j appenders to be used.
+ */
+ private static void checkForLog4jLibrary(Domain domain) {
+ try {
+ LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", domain.toString(), null, null);
+ testAppender.close();
+ } catch (SecurityException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Send 10 dummy events through the provided logger
+ *
+ * @param logger
+ * The logger to use to send events
+ */
+ public static void send10Events(Logger logger) {
+ // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
+ logger.debug("Debug message. Lost among so many.");
+ logger.debug("Debug message with a throwable", new IOException());
+ logger.error("Error messsage. This might be bad.");
+ logger.error("Error message with a throwable", new IOException());
+ logger.fatal("A fatal message. You are already dead.");
+ logger.info("A info message. Lol, who cares.");
+ logger.trace("A trace message. No, no *that* trace");
+ logger.warn("A warn message. Yellow underline.");
+ logger.log(Level.DEBUG, "A debug message using .log()");
+ logger.log(Level.ERROR, "A error message using .log()");
+ }
+}
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;
}
}
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;
}
}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
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;
}
}
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<String> 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<String> expectedEvents = Arrays.asList(LOGGER_NAME_1);
- List<String> 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<String> expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3);
- List<String> 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;
}
}
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;
}
}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
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;
}
-
}
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;
}
}
+++ /dev/null
-/*
- * 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.utils;
-
-import java.net.URI;
-import java.net.URL;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-
-/**
- * Log4j 2.x test context utilities.
- */
-public class Log4j2TestContext {
-
- private final URI configFileUri;
-
- private LoggerContext loggerContext;
-
- /**
- * @param configFile path to the log4j configuration file.
- */
- public Log4j2TestContext(String configFile) {
-
- URL resource = getClass().getClassLoader().getResource(configFile);
-
- if (resource == null) {
- throw new IllegalArgumentException("Config file not found: " + configFile);
- }
-
- try {
- this.configFileUri = resource.toURI();
- } catch (Exception e) {
- throw new IllegalArgumentException("Config file invalid URI: " + resource);
- }
- }
-
- /**
- * @return the log4j2 logger context.
- */
- public synchronized LoggerContext getLoggerContext() {
- return loggerContext;
- }
-
- /**
- * Initialize the log4j2 context before running a test.
- */
- public synchronized void beforeTest() {
- loggerContext = (LoggerContext) LogManager.getContext(
- ClassLoader.getSystemClassLoader(), false, configFileUri);
- }
-
- /**
- * Dispose of the log4j2 context after running a test.
- */
- public synchronized void afterTest() {
- loggerContext.stop();
- }
-}
+++ /dev/null
-/*
- * 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.utils;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.log4j2.LttngLogAppender;
-
-
-/**
- * Utility methods for log4j 2.x tests
- */
-public final class Log4j2TestUtils {
-
- private Log4j2TestUtils() {
- }
-
- /**
- * Setup method common to most log4j tests. To be called in a @BeforeClass.
- */
- public static void testClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- checkForLog4jLibrary();
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J), "lttng-tools is not working properly.");
-
- LttngToolsHelper.destroyAllSessions();
- }
-
- /**
- * Teardown method common to most log4j tests. To be called in a @AfterClass.
- */
- public static void testClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
- }
-
- /**
- * Check the the Log4j native library is available, effectively allowing
- * LTTng Log4j appenders to be used.
- */
- private static void checkForLog4jLibrary() {
- try {
- LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", null, null);
- testAppender.close();
- } catch (SecurityException | IOException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Send 10 dummy events through the provided logger
- *
- * @param logger
- * The logger to use to send events
- */
- public static void send10Events(Logger logger) {
- // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
- logger.debug("Debug message. Lost among so many.");
- logger.debug("Debug message with a throwable", new IOException());
- logger.error("Error messsage. This might be bad.");
- logger.error("Error message with a throwable", new IOException());
- logger.fatal("A fatal message. You are already dead.");
- logger.info("A info message. Lol, who cares.");
- logger.trace("A trace message. No, no *that* trace");
- logger.warn("A warn message. Yellow underline.");
- logger.log(Level.DEBUG, "A debug message using .log()");
- logger.log(Level.ERROR, "A error message using .log()");
- }
-}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersAllAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J2"/>
+ <Lttng name="Lttng2" domain="LOG4J2"/>
+ <Lttng name="Lttng3" domain="LOG4J2"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng1"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng2"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng3"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersNoneAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J2"/>
+ <Lttng name="Lttng2" domain="LOG4J2"/>
+ <Lttng name="Lttng3" domain="LOG4J2"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersSomeAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J2"/>
+ <Lttng name="Lttng2" domain="LOG4J2"/>
+ <Lttng name="Lttng3" domain="LOG4J2"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng1"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersAllAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J"/>
+ <Lttng name="Lttng2" domain="LOG4J"/>
+ <Lttng name="Lttng3" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng1"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng2"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng3"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersNoneAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J"/>
+ <Lttng name="Lttng2" domain="LOG4J"/>
+ <Lttng name="Lttng3" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersSomeAttached" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng1" domain="LOG4J"/>
+ <Lttng name="Lttng2" domain="LOG4J"/>
+ <Lttng name="Lttng3" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.lttng.somecomponent">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng1"/>
+ </Logger>
+ <Logger name="org.lttng.mycomponent">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.lttng.myothercomponent-àéç">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
- <Lttng name="Lttng"/>
+ <Lttng name="Lttng" domain="LOG4J2"/>
</Appenders>
<Loggers>
<Logger name="EventName">
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
- <Lttng name="Lttng"/>
+ <Lttng name="Lttng" domain="LOG4J2"/>
</Appenders>
<Loggers>
<Logger name="EventName">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatAppContextIT" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="EventName">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatAppContextOrderingIT" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="EventName">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatListEventsIT" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="LttngA" domain="LOG4J"/>
+ <Lttng name="LttngB" domain="LOG4J"/>
+ <Lttng name="LttngC" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="EventA">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngA"/>
+ </Logger>
+ <Logger name="EventAB">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngB"/>
+ </Logger>
+ <Logger name="EventABC">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngC"/>
+ </Logger>
+ <Logger name="EventABCDÉ">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatFilterListenerOrderingIT" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="Lttng" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="EventA">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng"/>
+ </Logger>
+ <Logger name="EventB">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="Lttng"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatMultiSessionIT" status="debug">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ <Lttng name="LttngA" domain="LOG4J"/>
+ <Lttng name="LttngB" domain="LOG4J"/>
+ <Lttng name="LttngC" domain="LOG4J"/>
+ <Lttng name="LttngD" domain="LOG4J"/>
+ </Appenders>
+ <Loggers>
+ <Logger name="EventA">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngA"/>
+ </Logger>
+ <Logger name="EventAB">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngB"/>
+ </Logger>
+ <Logger name="EventABC">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngC"/>
+ </Logger>
+ <Logger name="EventABCDÉ">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="LttngD"/>
+ </Logger>
+ <Root level="all"/>
+ </Loggers>
+</Configuration>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
- <Lttng name="LttngA"/>
- <Lttng name="LttngB"/>
- <Lttng name="LttngC"/>
+ <Lttng name="LttngA" domain="LOG4J2"/>
+ <Lttng name="LttngB" domain="LOG4J2"/>
+ <Lttng name="LttngC" domain="LOG4J2"/>
</Appenders>
<Loggers>
<Logger name="EventA">
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
- <Lttng name="Lttng"/>
+ <Lttng name="Lttng" domain="LOG4J2"/>
</Appenders>
<Loggers>
<Logger name="EventA">
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
- <Lttng name="LttngA"/>
- <Lttng name="LttngB"/>
- <Lttng name="LttngC"/>
- <Lttng name="LttngD"/>
+ <Lttng name="LttngA" domain="LOG4J2"/>
+ <Lttng name="LttngB" domain="LOG4J2"/>
+ <Lttng name="LttngC" domain="LOG4J2"/>
+ <Lttng name="LttngD" domain="LOG4J2"/>
</Appenders>
<Loggers>
<Logger name="EventA">
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersAllAttached" status="debug">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- <Lttng name="Lttng1"/>
- <Lttng name="Lttng2"/>
- <Lttng name="Lttng3"/>
- </Appenders>
- <Loggers>
- <Logger name="org.lttng.somecomponent">
- <AppenderRef ref="Console"/>
- <AppenderRef ref="Lttng1"/>
- </Logger>
- <Logger name="org.lttng.mycomponent">
- <AppenderRef ref="Console"/>
- <AppenderRef ref="Lttng2"/>
- </Logger>
- <Logger name="org.lttng.myothercomponent-àéç">
- <AppenderRef ref="Console"/>
- <AppenderRef ref="Lttng3"/>
- </Logger>
- <Root level="all"/>
- </Loggers>
-</Configuration>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersNoneAttached" status="debug">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- <Lttng name="Lttng1"/>
- <Lttng name="Lttng2"/>
- <Lttng name="Lttng3"/>
- </Appenders>
- <Loggers>
- <Logger name="org.lttng.somecomponent">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.lttng.mycomponent">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.lttng.myothercomponent-àéç">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="all"/>
- </Loggers>
-</Configuration>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersSomeAttached" status="debug">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- <Lttng name="Lttng1"/>
- <Lttng name="Lttng2"/>
- <Lttng name="Lttng3"/>
- </Appenders>
- <Loggers>
- <Logger name="org.lttng.somecomponent">
- <AppenderRef ref="Console"/>
- <AppenderRef ref="Lttng1"/>
- </Logger>
- <Logger name="org.lttng.mycomponent">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.lttng.myothercomponent-àéç">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="all"/>
- </Loggers>
-</Configuration>
</configuration>
</plugin>
+ <!-- Set Surefire to the same version as Failsafe even if we don't use
+ it. Otherwise, Maven will invoke a random default version and if
+ we specify a user property used by both plugins on the command
+ line things could go wrong. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M5</version>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<groupId>org.lttng.ust</groupId>
<artifactId>lttng-ust-java-tests-common</artifactId>
<version>1.1.0-SNAPSHOT</version>
- <scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>