-
Notifications
You must be signed in to change notification settings - Fork 3
Add benchmark for JUL agent without source information #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tahini
wants to merge
2
commits into
lttng:master
Choose a base branch
from
tahini:jul_no_source
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...st/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledNoSourceBenchmark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2017 École Polytechnique de Montréal | ||
* | ||
* 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.benchmarks.jul.handler.lttng; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.lttng.tools.ILttngSession; | ||
import org.lttng.tools.ILttngSession.Domain; | ||
import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; | ||
import org.lttng.ust.agent.jul.LttngLogHandler; | ||
|
||
/** | ||
* Test the LTTng-JUL handler, with it actually sending events to the tracer, | ||
* but without saving the source method and class information | ||
* | ||
* @author Geneviève Bastien | ||
*/ | ||
public class LttngJulHandlerTracingEnabledNoSourceBenchmark extends JulHandlerBenchmarkBase { | ||
|
||
private ILttngSession session; | ||
|
||
/** | ||
* Test setup | ||
* | ||
* @throws IOException | ||
*/ | ||
@Before | ||
public void testSetup() throws IOException { | ||
LttngLogHandler hndl = new LttngLogHandler(); | ||
hndl.setLogSource(false); | ||
handler = hndl; | ||
|
||
session = ILttngSession.createSession(null, Domain.JUL); | ||
assertTrue(session.enableAllEvents()); | ||
assertTrue(session.start()); | ||
} | ||
|
||
/** | ||
* Test cleanup | ||
*/ | ||
@After | ||
public void testTeardown() { | ||
assertTrue(session.stop()); | ||
session.close(); | ||
} | ||
} |
178 changes: 178 additions & 0 deletions
178
...tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulHandlerLogSourceIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
/* | ||
* Copyright (C) 2017, École Polytechnique de Montréal, Geneviève Bastien <[email protected]> | ||
* | ||
* 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.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.logging.Handler; | ||
import java.util.logging.Level; | ||
import java.util.logging.LogManager; | ||
import java.util.logging.Logger; | ||
|
||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import org.lttng.tools.ILttngSession; | ||
import org.lttng.tools.ILttngSession.Domain; | ||
import org.lttng.ust.agent.jul.LttngLogHandler; | ||
import org.lttng.ust.agent.utils.JulTestUtils; | ||
|
||
/** | ||
* Test the {@link LttngLogHandler} log output with source log enabled or not | ||
* | ||
* @author Geneviève Bastien | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class JulHandlerLogSourceIT { | ||
|
||
private static final Domain DOMAIN = Domain.JUL; | ||
|
||
private static final String LOGGER_NAME = "org.lttng.test"; | ||
|
||
private ILttngSession session; | ||
|
||
private Logger logger; | ||
|
||
private final Boolean logSource; | ||
private final String expectedString; | ||
|
||
// ------------------------------------------------------------------------ | ||
// Test parameter definition | ||
// ------------------------------------------------------------------------ | ||
|
||
/** | ||
* Get the test parameters, with / without source logging as well as the | ||
* string that should be present in the events as a result of the event | ||
* logging. | ||
* | ||
* @return The test parameters | ||
*/ | ||
@Parameters(name = "{index}: logSource={0}") | ||
public static Iterable<Object[]> testCases() { | ||
return Arrays.asList(new Object[][] { | ||
{ Boolean.TRUE, "class_name = \"org.lttng.ust.agent.utils.JulTestUtils\", method_name = \"send10EventsTo\"" }, | ||
{ Boolean.FALSE, "class_name = \"\", method_name = \"\"" }, | ||
}); | ||
} | ||
|
||
/** | ||
* Test constructor | ||
* | ||
* @param logSource | ||
* Should source information be logged with the event | ||
* @param expectedString | ||
* A string that should be present in the event | ||
*/ | ||
public JulHandlerLogSourceIT(boolean logSource, | ||
String expectedString) { | ||
this.logSource = logSource; | ||
this.expectedString = expectedString; | ||
} | ||
|
||
/** | ||
* Class setup | ||
*/ | ||
@BeforeClass | ||
public static void julClassSetup() { | ||
JulTestUtils.testClassSetup(); | ||
} | ||
|
||
/** | ||
* Class cleanup | ||
*/ | ||
@AfterClass | ||
public static void julClassCleanup() { | ||
JulTestUtils.testClassCleanup(); | ||
} | ||
|
||
/** | ||
* Test setup | ||
* | ||
* @throws IOException | ||
* Exceptions thrown by handler | ||
* @throws SecurityException | ||
* Exceptions thrown by handler | ||
*/ | ||
@Before | ||
public void setup() throws SecurityException, IOException { | ||
/* Clear the JUL logger configuration */ | ||
LogManager.getLogManager().reset(); | ||
System.gc(); | ||
|
||
/* Initialize the logger */ | ||
logger = Logger.getLogger(LOGGER_NAME); | ||
logger.setLevel(Level.ALL); | ||
|
||
/* Initialize the handler */ | ||
LttngLogHandler handler = new LttngLogHandler(); | ||
handler.setLogSource(logSource); | ||
logger.addHandler(handler); | ||
|
||
/* Create the lttng session */ | ||
session = ILttngSession.createSession(null, DOMAIN); | ||
} | ||
|
||
/** | ||
* Test cleanup | ||
*/ | ||
@After | ||
public void tearDown() { | ||
session.close(); | ||
Handler handler = logger.getHandlers()[0]; | ||
logger.removeHandler(handler); | ||
handler.close(); | ||
|
||
logger = null; | ||
} | ||
|
||
/** | ||
* Test tracing some events and see if the output contains the expected string | ||
*/ | ||
@Test | ||
public void testHandlerOutput() { | ||
assertTrue(session.enableAllEvents()); | ||
assertTrue(session.start()); | ||
|
||
JulTestUtils.send10EventsTo(logger); | ||
|
||
assertTrue(session.stop()); | ||
|
||
List<String> output = session.view(); | ||
assertNotNull(output); | ||
assertFalse(output.isEmpty()); | ||
|
||
assertEquals(10, output.size()); | ||
for (String str : output) { | ||
assertTrue("Validating event string : " + str, str.contains(expectedString)); | ||
} | ||
} | ||
|
||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, that's what this public method was for!
Hmm, could it be done through a
System.getProperty()
, or through a custom constructor?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember that after discussion, we noticed it's common for handler classes to also offer setters for properties like this, so we can stay consistent with that.