From: Bernd Hufmann Date: Tue, 10 Feb 2015 14:19:14 +0000 (-0500) Subject: [LTTng control] fix snapshot session for non-live sessions (Bug 459552) X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=e5237dc5e0be1afdd60e3b9212cd0bd71dd31452;p=deliverable%2Ftracecompass.git [LTTng control] fix snapshot session for non-live sessions (Bug 459552) Change-Id: Ida1601dea6718394a32b7633695c4194c17d25d1 Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/41524 Reviewed-by: Hudson CI Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java b/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java index bd96f92be7..84c0c774ca 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java +++ b/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.lttng2.control.ui.tests.service; 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 static org.junit.Assert.fail; @@ -83,6 +84,7 @@ public class LTTngControlServiceTest { private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE = "GetSessionNameNotExistVerbose"; protected static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut"; private static final String SCEN_GET_SESSION1 = "GetSession1"; + private static final String SCEN_GET_SESSION_WITH_LIVE = "GetSessionWithLiveInterval"; private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1"; private static final String SCEN_LIST_WITH_NO_KERNEL1 = "ListWithNoKernel1"; private static final String SCEN_LIST_WITH_NO_KERNEL2 = "ListWithNoKernel2"; @@ -474,6 +476,43 @@ public class LTTngControlServiceTest { } } + @Test + public void testGetSessionWithLive() { + try { + fShell.setScenario(SCEN_GET_SESSION_WITH_LIVE); + + // Verify Session (snapshot session, non-live) + ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); + assertNotNull(session); + assertEquals("mysession", session.getName()); + assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); + assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); + assertFalse(session.isLive()); + + // Verify Session (regular session, non-live) + session = fService.getSession("mysession1", new NullProgressMonitor()); + assertNotNull(session); + assertEquals("mysession1", session.getName()); + assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session.getSessionPath()); + assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); + assertFalse(session.isLive()); + + // Verify Session (regular session, live) + session = fService.getSession("mysession2", new NullProgressMonitor()); + assertNotNull(session); + assertEquals("mysession2", session.getName()); + assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session.getSessionPath()); + assertEquals("net://127.0.0.1", session.getLiveUrl()); + assertEquals(Integer.valueOf(5344), session.getLivePort()); + assertEquals(1000000, session.getLiveDelay()); + assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); + assertTrue(session.isLive()); + + } catch (ExecutionException e) { + fail(e.toString()); + } + } + /** * @return */ diff --git a/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg b/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg index 4677f4e053..cbc53033c9 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg +++ b/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg @@ -8,6 +8,7 @@ # # Contributors: # Jonathan Rajotte - Initial API and implementation +# Bernd Hufmann - Added new test cases #################################################################### #################################################################### # Scenario: Test lttng not installed @@ -457,6 +458,123 @@ lttng --mi xml list mysession1 +#################################################################### +# Scenario: Test lttng list (with live time interval) +#################################################################### + +GetSessionWithLiveInterval + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + /home/user/lttng-traces/mysession-20120129-084256 + false + 1 + 4294967295 + + + + + + + +#------------------------------------------------------------------------------ + +lttng --mi xml snapshot list-output -s mysession + + +0 + + + + + snapshot + + + list-output + + + mysession + + + 1 + snapshot-1 + /home/user/lttng-traces/mysession-20120129-084256 + + 0 + + + + + + + true + + +#------------------------------------------------------------------------------ + +lttng --mi xml list mysession1 + + +0 + + + + + list + + + + mysession1 + /home/user/lttng-traces/mysession1-20120129-084256 + true + 0 + 0 + + + + + + +#------------------------------------------------------------------------------ + +lttng --mi xml list mysession2 + + +0 + + + + + list + + + + mysession2 + tcp4://172.0.0.1:5342/ [data: 5343] + false + 0 + 1000000 + + + + + + + + + + #################################################################### # Scenario: Test "lttng list -k" with sample output #################################################################### diff --git a/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg b/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg index 0c3f7c92d9..316d0de81a 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg +++ b/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg @@ -332,6 +332,61 @@ Tracing session mysession1: [inactive] +#################################################################### +# Scenario: Test lttng list (with live time interval) +#################################################################### + +GetSessionWithLiveInterval + +lttng list mysession + + +0 + + +Tracing session mysession: [inactive snapshot] + Trace path: + Live timer interval (usec): 4294967295 + + +#------------------------------------------------------------------------------ + +lttng snapshot list-output -s mysession + + +0 + + +Snapshot output list for session mysession + [1] snapshot-1: /home/user/lttng-traces/mysession-20120129-084256 (max-size: 0) + +#------------------------------------------------------------------------------ + +lttng list mysession1 + + +0 + + +Tracing session mysession1: [active] + Trace path: /home/user/lttng-traces/mysession1-20120129-084256 + Live timer interval (usec): 0 + + +#------------------------------------------------------------------------------ + +lttng list mysession2 + + +0 + + +Tracing session mysession2: [inactive] + Trace path: tcp4://172.0.0.1:5342/ [data: 5343] + Live timer interval (usec): 1000000 + + + #################################################################### # Scenario: Test "lttng list -k" with sample output diff --git a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java index 413be739c1..5e97440424 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java +++ b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java @@ -287,7 +287,7 @@ public class LTTngControlService implements ILttngControlService { matcher = LTTngControlServiceConstants.LIST_LIVE_TIMER_INTERVAL_PATTERN.matcher(line); if (matcher.matches()) { long liveDelay = Long.parseLong(matcher.group(1)); - if (liveDelay > 0) { + if ((liveDelay > 0) && (liveDelay <= LTTngControlServiceConstants.MAX_LIVE_TIMER_INTERVAL)) { sessionInfo.setLive(true); sessionInfo.setLiveUrl(SessionInfo.DEFAULT_LIVE_NETWORK_URL); sessionInfo.setLivePort(SessionInfo.DEFAULT_LIVE_PORT); diff --git a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java index e55286ec24..1a57dd5c7d 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java +++ b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java @@ -274,6 +274,11 @@ public interface LTTngControlServiceConstants { */ String OPTION_MAX_TRACE_FILES = "-W"; //$NON-NLS-1$ + /** + * Maximum live timer interval value + */ + Long MAX_LIVE_TIMER_INTERVAL = 0xFFFFFFFEL; + // ------------------------------------------------------------------------ // Parsing constants // ------------------------------------------------------------------------ diff --git a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java index 69d50b9738..72e639407d 100644 --- a/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java +++ b/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java @@ -8,6 +8,7 @@ * * Contributors: * Jonathan Rajotte - Initial support for machine interface lttng 2.6 + * Bernd Hufmann - Fix check for live session **********************************************************************/ package org.eclipse.tracecompass.internal.lttng2.control.ui.views.service; @@ -273,7 +274,7 @@ public class LTTngControlServiceMI extends LTTngControlService { break; case MIStrings.LIVE_TIMER_INTERVAL: long liveDelay = Long.parseLong(rawInfo.getTextContent()); - if (liveDelay > 0) { + if ((liveDelay > 0 && (liveDelay <= LTTngControlServiceConstants.MAX_LIVE_TIMER_INTERVAL))) { sessionInfo.setLive(true); sessionInfo.setLiveUrl(SessionInfo.DEFAULT_LIVE_NETWORK_URL); sessionInfo.setLivePort(SessionInfo.DEFAULT_LIVE_PORT);