From: Jonathan Rajotte Julien Date: Wed, 20 Aug 2014 21:13:47 +0000 (-0400) Subject: tmf: lttngControl: mi: Component and CreateSession tests X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=7fa45c7fd86d7458d3963367dc5f6786ce043455;p=deliverable%2Ftracecompass.git tmf: lttngControl: mi: Component and CreateSession tests Change-Id: I34d0f08bebc08810c99e67a7002a67283bc96c56 Signed-off-by: Jonathan Rajotte Julien Reviewed-on: https://git.eclipse.org/r/32019 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Matthew Khouzam --- diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/AllTests.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/AllTests.java index 4000217747..5ae2c88ac0 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/AllTests.java @@ -23,6 +23,7 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ TraceControlComponentTest.class, TraceControlCreateSessionTests.class, + TraceControlCreateSessionMiTests.class, TraceControlKernelProviderTests.class, TraceControlKernelSessionTests.class, TraceControlPropertiesTest.class, diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlComponentTest.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlComponentTest.java index 785a19981c..74d4b1e439 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlComponentTest.java +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlComponentTest.java @@ -31,6 +31,8 @@ import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceC import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceControlRoot; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.ILttngControlService; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlService; +import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants; +import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlServiceMI; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; @@ -271,6 +273,12 @@ public class TraceControlComponentTest { assertNotNull(service); assertEquals(service, result); + service = new LTTngControlServiceMI(proxy.createCommandShell(), LTTngControlServiceMI.class.getResource(LTTngControlServiceConstants.MI_XSD_FILENAME)); + fixture.setControlService(service); + result = fixture.getControlService(); + assertNotNull(service); + assertEquals(service, result); + result = fixture.getChildren()[0].getControlService(); assertNotNull(service); assertEquals(service, result); diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionMiTests.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionMiTests.java new file mode 100644 index 0000000000..bb287f133a --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionMiTests.java @@ -0,0 +1,27 @@ +/********************************************************************** + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jonathan Rajotte - Support for machine interface LTTng 2.6 + **********************************************************************/ + +package org.eclipse.linuxtools.lttng2.control.ui.tests.model.component; + +/** + * Machine interface Kernel session manipulation handling test cases. + * LTTng 2.6 + */ +public class TraceControlCreateSessionMiTests extends TraceControlCreateSessionTests { + + private static final String TEST_STREAM = "CreateSessionTestMi.cfg"; + + @Override + protected String getTestStream() { + return TEST_STREAM; + } +} diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionTests.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionTests.java index 4ff93b0ad8..50611ca5a2 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionTests.java +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlCreateSessionTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2013 Ericsson + * Copyright (c) 2013, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,7 +8,9 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Jonathan Rajotte - Support for LTTng 2.6 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.control.ui.tests.model.component; import static org.junit.Assert.assertEquals; @@ -29,6 +31,7 @@ import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.TraceCont import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent; +import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.ILttngControlService; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemProfile; @@ -39,11 +42,9 @@ import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlKernelSessionTests contains Kernel session/channel/event - * handling test cases. + * The class {@link TraceControlKernelSessionTests} contains Kernel + * session/channel/event handling test cases. */ - -@SuppressWarnings("javadoc") public class TraceControlCreateSessionTests { // ------------------------------------------------------------------------ @@ -55,6 +56,8 @@ public class TraceControlCreateSessionTests { private static final String SCEN_SCENARIO_NETWORK_TEST = "CreateSessionNetwork"; private static final String SCEN_SCENARIO_NETWORK2_TEST = "CreateSessionNetwork2"; + private static final String SESSION = "mysession"; + // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ @@ -70,25 +73,29 @@ public class TraceControlCreateSessionTests { * Perform pre-test initialization. * * @throws Exception - * if the initialization fails for some reason - * + * if the initialization fails for some reason */ @Before public void setUp() throws Exception { fFacility = TraceControlTestFacility.getInstance(); fFacility.init(); fProxy = new TestRemoteSystemProxy(); - URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); + URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + getTestStream()), null); File testfile = new File(FileLocator.toFileURL(location).toURI()); fTestFile = testfile.getAbsolutePath(); } /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason + * Get the test stream file name to use for the test suite * + * @return the name of the test stream file + */ + protected String getTestStream() { + return TEST_STREAM; + } + + /** + * Perform post-test clean-up. */ @After public void tearDown() { @@ -97,6 +104,9 @@ public class TraceControlCreateSessionTests { /** * Run the TraceControlComponent. + * + * @throws Exception + * on internal error */ @Test public void testTraceSessionTree() throws Exception { @@ -107,7 +117,7 @@ public class TraceControlCreateSessionTests { ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); - ISystemProfile profile = registry.createSystemProfile("myProfile", true); + ISystemProfile profile = registry.createSystemProfile("myProfile", true); IHost host = registry.createLocalHost(profile, "myProfile", "user"); TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy); @@ -125,6 +135,8 @@ public class TraceControlCreateSessionTests { // Verify that node is connected assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState()); + ILttngControlService controleService = node.getControlService(); + // Get provider groups ITraceControlComponent[] groups = node.getChildren(); assertNotNull(groups); @@ -147,8 +159,13 @@ public class TraceControlCreateSessionTests { // Verify that session was created assertNotNull(session); - assertEquals("mysession", session.getName()); - assertEquals("file:///tmp", session.getSessionPath()); + assertEquals(getSessionName(), session.getName()); + if (controleService.isVersionSupported("2.6.0")) { + assertEquals("/tmp", session.getSessionPath()); + } else { + assertEquals("file:///tmp", session.getSessionPath()); + } + assertTrue(!session.isStreamedTrace()); assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); sessionDialogStub.setNetworkUrl(null); @@ -173,8 +190,12 @@ public class TraceControlCreateSessionTests { // Verify that session was created assertNotNull(session); - assertEquals("mysession", session.getName()); - assertEquals("tcp://172.0.0.1:5342 [data: 5343]", session.getSessionPath()); + assertEquals(getSessionName(), session.getName()); + if (controleService.isVersionSupported("2.6.0")) { + assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session.getSessionPath()); + } else { + assertEquals("tcp://172.0.0.1:5342 [data: 5343]", session.getSessionPath()); + } assertTrue(session.isStreamedTrace()); assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); sessionDialogStub.setControlUrl(null); @@ -199,8 +220,12 @@ public class TraceControlCreateSessionTests { // Verify that session was created assertNotNull(session); - assertEquals("mysession", session.getName()); - assertEquals("net://172.0.0.1:1234 [data: 2345]", session.getSessionPath()); + assertEquals(getSessionName(), session.getName()); + if (controleService.isVersionSupported("2.6.0")) { + assertEquals("tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345]", session.getSessionPath()); + } else { + assertEquals("net://172.0.0.1:1234 [data: 2345]", session.getSessionPath()); + } assertTrue(session.isStreamedTrace()); assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); sessionDialogStub.setNetworkUrl(null); @@ -223,8 +248,12 @@ public class TraceControlCreateSessionTests { // Verify that session was created assertNotNull(session); - assertEquals("mysession", session.getName()); - assertEquals("net://[ffff::eeee:dddd:cccc:0]:5342/mysession-20130221-144451 [data: 5343]", session.getSessionPath()); + assertEquals(getSessionName(), session.getName()); + if (controleService.isVersionSupported("2.6.0")) { + assertEquals("tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343]", session.getSessionPath()); + } else { + assertEquals("net://[ffff::eeee:dddd:cccc:0]:5342/mysession-20130221-144451 [data: 5343]", session.getSessionPath()); + } assertTrue(session.isStreamedTrace()); assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); sessionDialogStub.setNetworkUrl(null); @@ -234,19 +263,22 @@ public class TraceControlCreateSessionTests { // Verify that no more session components exist assertEquals(0, groups[1].getChildren().length); - - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Disconnect node - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- fFacility.executeCommand(node, "disconnect"); assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Delete node - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- fFacility.executeCommand(node, "delete"); - assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length); + assertEquals(0, fFacility.getControlView().getTraceControlRoot().getChildren().length); + } + + private static String getSessionName() { + return SESSION; } } diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateSessionTestMi.cfg b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateSessionTestMi.cfg new file mode 100644 index 0000000000..b841a5c8b1 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateSessionTestMi.cfg @@ -0,0 +1,528 @@ +#################################################################### +# Copyright (c) 2014 Ericsson +# +# All rights reserved. This program and the accompanying materials are +# made available under the terms of the Eclipse Public License v1.0 which +# accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Jonathan Rajotte - Initial API and implementation +#################################################################### +#################################################################### +# Scenario: Initialize +#################################################################### + +Initialize + +lttng --mi xml version + + +0 + + + + + version + + + 2.6.0 + 2 + 6 + + 0 + TestMI + Lorem ipsum + http://lttng.org + lttng is free software and under the GPL license and part LGPL + + + + + + +lttng --mi xml list + + +0 + + + + + list + + + + + + + +lttng --mi xml list -k + + +0 + + + + + list + + + + KERNEL + PER_PID + + + sched_kthread_stop + TRACEPOINT + true + false + TRACE_EMERG + ALL + false + + + sched_kthread_stop_ret + TRACEPOINT + true + false + TRACE_EMERG + ALL + false + + + sched_wakeup_new + TRACEPOINT + true + false + TRACE_EMERG + ALL + false + + + + + + + + + +lttng --mi xml list -u -f + + +0 + + + + + list + + + + UST + PER_PID + + + 9379 + /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello + + + ust_tests_hello:tptest_sighandler + TRACEPOINT + true + false + TRACE_DEBUG_MODULE + ALL + false + + + + ust_tests_hello:tptest + TRACEPOINT + true + false + TRACE_INFO + ALL + false + + + doublefield + FLOAT + 0 + + + floatfield + FLOAT + 0 + + + stringfield + STRING + 0 + + + + + + + 4852 + /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello + + + ust_tests_hello:tptest_sighandler + TRACEPOINT + true + false + TRACE_WARNING + ALL + false + + + + ust_tests_hello:tptest + TRACEPOINT + true + false + TRACE_DEBUG_FUNCTION + ALL + false + + + doublefield + FLOAT + 0 + + + floatfield + FLOAT + 0 + + + stringfield + STRING + 0 + + + + + + + + + + + + + +#################################################################### +# Scenario: Test "lttng create with LTTng 2.1 options +#################################################################### +################################################################## + +CreateSessionFileProto + +lttng --mi xml create mysession -U file:///tmp + + +0 + + + + + create + + + mysession + /tmp + false + 0 + 0 + + + true + + + + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + /tmp + false + 0 + 0 + + + + + + + + +lttng --mi xml destroy mysession + + +0 + + + + + destroy + + + + mysession + /tmp + false + 0 + 0 + + + + true + + + + +################################################################## + +CreateSessionControlData + +lttng --mi xml create mysession -C tcp://172.0.0.1 -D tcp://172.0.0.1:5343 + + +0 + + + + + create + + + mysession + tcp4://172.0.0.1:5342/ [data: 5343] + false + 0 + 0 + + + true + + + + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + tcp4://172.0.0.1:5342/ [data: 5343] + false + 0 + 0 + + + + + + + + +lttng --mi xml destroy mysession + + +0 + + + + + destroy + + + + mysession + tcp4://172.0.0.1:5342/ [data: 5343] + false + 0 + 0 + + + + true + + + + +################################################################## + +CreateSessionNetwork + +lttng --mi xml create mysession -U net://172.0.0.1:1234:2345 + + +0 + + + + + create + + + mysession + tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345] + false + 0 + 0 + + + true + + + + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345] + false + 0 + 0 + + + + + + + + +lttng --mi xml destroy mysession + + +0 + + + + + destroy + + + + mysession + tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345] + false + 0 + 0 + + + + true + + + + + +################################################################## + +CreateSessionNetwork2 + +lttng --mi xml create mysession -U net6://[ffff::eeee:dddd:cccc:0] + + +0 + + + + + create + + + mysession + tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343] + false + 0 + 0 + + + true + + + + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343] + false + 0 + 0 + + + + + + + + +lttng --mi xml destroy mysession + + +0 + + + + + destroy + + + + mysession + tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343] + false + 0 + 0 + + + + true + + + + \ No newline at end of file