/**********************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 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
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory;
import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
private static final String SCEN_CALIBRATE_HANDLING = "CalibrateHandling";
private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1";
private static final String SCEN_CREATE_SESSION_VERBOSE_2_1 = "CreateSessionLttngVerbose2.1";
+ private static final String SCEN_CREATE_SNAPSHOT_SESSION = "CreateSessionSnapshot";
+ private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION = "CreateSessionStreamedSnapshot";
+ private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS = "CreateSessionSnapshotErrors";
// ------------------------------------------------------------------------
// Test data
try {
fShell.setScenario(SCEN_CREATE_SESSION1);
- ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
+ ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession2", info.getName());
assertNotNull(info.getSessionPath());
fShell.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT);
// First line has no shell prompt before the output
- ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
+ ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession2", info.getName());
assertNotNull(info.getSessionPath());
fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
try {
- fService.createSession("alreadyExist", null, new NullProgressMonitor());
+ fService.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- fService.createSession("wrongName", null, new NullProgressMonitor());
+ fService.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
+ ISessionInfo sessionInfo = new SessionInfo("withPath");
+ sessionInfo.setSessionPath("/home/user/hallo");
+ fService.createSession(sessionInfo, new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
+ ISessionInfo info = fService.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
assertNotNull(info);
assertEquals("session with spaces", info.getName());
assertNotNull(info.getSessionPath());
}
try {
- ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+ ISessionInfo sessionInfo = new SessionInfo("pathWithSpaces");
+ sessionInfo.setSessionPath("/home/user/hallo user/here");
+ ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("pathWithSpaces", info.getName());
assertNotNull(info.getSessionPath());
try {
((LTTngControlService)fService).setVersion("2.2.0");
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String kernelChannel0 = "mychannel0";
String kernelChannel1 = "mychannel1";
list.add(kernelChannel0);
try {
((LTTngControlService)fService).setVersion("2.2.0");
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String USTChannel = "ustChannel";
list.add(USTChannel);
fShell.setScenario(SCEN_CHANNEL_HANDLING);
try {
((LTTngControlService)fService).setVersion("2.2.0");
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String USTChannel = "ustChannel";
list.add(USTChannel);
fShell.setScenario(SCEN_CHANNEL_HANDLING);
try {
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String kernelChannel0 = "mychannel0";
String kernelChannel1 = "mychannel1";
list.add(kernelChannel0);
try {
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String kernelChannel0 = "mychannel0";
String kernelChannel1 = "mychannel1";
list.add(kernelChannel0);
try {
// 1) session name, channel = null, 3 event names, kernel
String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String eventName0 = "block_rq_remap";
String eventName1 = "block_bio_remap";
String eventName2 = "softirq_entry";
String sessionName = "mysession2";
String channelName = "mychannel";
String eventName = "ust_tests_hello:tptest_sighandler";
- List<String> contexts = new ArrayList<String>();
+ List<String> contexts = new ArrayList<>();
contexts.add("prio");
contexts.add("pid");
assertEquals(12, availContexts.size());
// A very "hard-coded" way to verify but it works ...
- Set<String> expectedContexts = new HashSet<String>();
+ Set<String> expectedContexts = new HashSet<>();
expectedContexts.add("pid");
expectedContexts.add("procname");
expectedContexts.add("prio");
String sessionName = "mysession2";
String channelName = "mychannel";
String eventName = "ust_tests_hello:tptest_sighandler";
- List<String> contexts = new ArrayList<String>();
+ List<String> contexts = new ArrayList<>();
contexts.add("prio");
contexts.add("pid");
fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING);
try {
fShell.setScenario(SCEN_CREATE_SESSION_2_1);
- ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+ ISessionInfo sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setNetworkUrl("net://172.0.0.1");
+ sessionInfo.setStreamedTrace(true);
+ ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("net://172.0.0.1", info.getSessionPath());
assertTrue(info.isStreamedTrace());
fService.destroySession("mysession", new NullProgressMonitor());
- info = fService.createSession("mysession", "file:///tmp", null, null, new NullProgressMonitor());
+ sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setNetworkUrl("file:///tmp");
+ info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("file:///tmp", info.getSessionPath());
assertTrue(!info.isStreamedTrace());
fService.destroySession("mysession", new NullProgressMonitor());
- info = fService.createSession("mysession", "file:///tmp", null, null, new NullProgressMonitor());
+ sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setNetworkUrl("file:///tmp");
+ info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("file:///tmp", info.getSessionPath());
assertTrue(!info.isStreamedTrace());
fService.destroySession("mysession", new NullProgressMonitor());
- info = fService.createSession("mysession", null, "tcp://172.0.0.1", "tcp://172.0.0.1:5343", new NullProgressMonitor());
+ sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setControlUrl("tcp://172.0.0.1");
+ sessionInfo.setDataUrl("tcp://172.0.0.1:5343");
+ info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("", info.getSessionPath()); // the complete network path is not available at this point
assertTrue(info.isStreamedTrace());
fService.destroySession("mysession", new NullProgressMonitor());
- info = fService.createSession("mysession", "net://172.0.0.1:1234:2345", null, null, new NullProgressMonitor());
+ sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setNetworkUrl("net://172.0.0.1:1234:2345");
+ info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath());
// verbose
enableVerbose();
- info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+ sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setNetworkUrl("net://172.0.0.1");
+ info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("net://172.0.0.1", info.getSessionPath());
fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1);
enableVerbose();
- ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+ ISessionInfo sessionInfo = new SessionInfo("mysession");
+ sessionInfo.setStreamedTrace(true);
+ sessionInfo.setNetworkUrl("net://172.0.0.1");
+ ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession", info.getName());
assertEquals("net://172.0.0.1", info.getSessionPath());
}
}
+ @Test
+ public void testCreateSnapshotSession() {
+ try {
+ fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION);
+ ISessionInfo params = new SessionInfo("mysession");
+ params.setSnapshot(true);
+ ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor());
+ assertNotNull(sessionInfo);
+ assertEquals("mysession", sessionInfo.getName());
+ assertTrue(sessionInfo.isSnapshotSession());
+ assertEquals("", sessionInfo.getSessionPath());
+ assertTrue(!sessionInfo.isStreamedTrace());
+
+ assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState());
+
+ String[] names = fService.getSessionNames(new NullProgressMonitor());
+ assertEquals(names[0], "mysession");
+
+ ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor());
+ assertNotNull(snapshotInfo);
+ assertEquals("snapshot-1", snapshotInfo.getName());
+ assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath());
+ assertEquals(1, snapshotInfo.getId());
+ assertTrue(!snapshotInfo.isStreamedSnapshot());
+
+ // we need to set the snapshotInfo to so that the session path is set correctly
+ sessionInfo.setSnapshotInfo(snapshotInfo);
+ assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath());
+
+ fService.recordSnapshot("mysession", new NullProgressMonitor());
+
+ fService.destroySession("mysession", new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testCreateStreamedSnapshotSession() {
+ try {
+ fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION);
+
+ ISessionInfo params = new SessionInfo("mysession");
+ params.setNetworkUrl("net://172.0.0.1");
+ ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor());
+ assertNotNull(sessionInfo);
+ assertEquals("mysession", sessionInfo.getName());
+ assertTrue(sessionInfo.isSnapshotSession());
+
+ assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState());
+ assertTrue(sessionInfo.isStreamedTrace());
+
+ String[] names = fService.getSessionNames(new NullProgressMonitor());
+ assertEquals(names[0], "mysession");
+
+
+ ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo();
+ assertNotNull(sessionInfo);
+ assertEquals("snapshot-2", snapshotInfo.getName());
+ assertEquals("net4://172.0.0.1:5342/", snapshotInfo.getSnapshotPath());
+ assertEquals(2, snapshotInfo.getId());
+ assertTrue(snapshotInfo.isStreamedSnapshot());
+
+ // we need to set the snapshotInfo to so that the session path is set correctly
+ sessionInfo.setSnapshotInfo(snapshotInfo);
+ assertEquals("net4://172.0.0.1:5342/", sessionInfo.getSessionPath());
+
+ fService.recordSnapshot("mysession", new NullProgressMonitor());
+
+ fService.destroySession("mysession", new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+
+ @Test
+ public void testCreateSnapshotSessionErrors() {
+ try {
+ fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS);
+
+ String[] names = fService.getSessionNames(new NullProgressMonitor());
+ assertEquals(names[0], "mysession");
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+
+ try {
+ fService.getSnapshotInfo("blabla", new NullProgressMonitor());
+ fail("getSnapshoInfo() didn't fail");
+ } catch (ExecutionException e) {
+ // successful
+ }
+
+ try {
+ fService.recordSnapshot("blabla", new NullProgressMonitor());
+ fail("getSnapshoInfo() didn't fail");
+ } catch (ExecutionException e) {
+ // successful
+ }
+
+ try {
+ fService.recordSnapshot("mysession", new NullProgressMonitor());
+ fail("getSnapshoInfo() didn't fail");
+ } catch (ExecutionException e) {
+ // successful
+ }
+ }
+
private static void enableVerbose() {
// verbose
ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false);