1 /**********************************************************************
2 * Copyright (c) 2013, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 **********************************************************************/
14 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.model
.component
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertNotNull
;
18 import static org
.junit
.Assert
.assertTrue
;
23 import org
.eclipse
.core
.runtime
.FileLocator
;
24 import org
.eclipse
.core
.runtime
.Path
;
25 import org
.eclipse
.jdt
.annotation
.NonNull
;
26 import org
.eclipse
.remote
.core
.IRemoteConnection
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TargetNodeState
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceDomainType
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
31 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.CreateSessionDialogStub
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.DestroyConfirmDialogStub
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.EnableChannelDialogStub
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.GetEventInfoDialogStub
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.service
.TestRemoteSystemProxy
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
.TraceControlDialogFactory
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceChannelComponent
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
41 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
42 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.proxy
.TmfRemoteConnectionFactory
;
43 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
44 import org
.junit
.After
;
45 import org
.junit
.Before
;
46 import org
.junit
.Test
;
47 import org
.osgi
.framework
.FrameworkUtil
;
50 * The class {@link TraceControlUstSession2Test} contains UST
51 * session/channel/event handling test cases for LTTng 2.2.
53 public class TraceControlUstSession2Test
{
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
59 private static final String TEST_STREAM
= "CreateTreeTest2.cfg";
60 private static final String SCEN_SCEN_PER_UID_TEST
= "ScenPerUidTest";
61 private static final String SCEN_SCEN_PER_PID_TEST
= "ScenPerPidTest";
62 private static final String SCEN_SCEN_BUF_SIZE_TEST
= "ScenBufSizeTest";
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
68 private TraceControlTestFacility fFacility
;
69 private IRemoteConnection fHost
= TmfRemoteConnectionFactory
.getLocalConnection();
70 private @NonNull TestRemoteSystemProxy fProxy
= new TestRemoteSystemProxy(fHost
);
71 private String fTestFile
;
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
78 * Perform pre-test initialization.
81 * if the initialization fails for some reason
84 public void setUp() throws Exception
{
85 fFacility
= TraceControlTestFacility
.getInstance();
87 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
88 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
89 fTestFile
= testfile
.getAbsolutePath();
93 * Perform post-test clean-up.
96 public void tearDown() {
101 * Run the TraceControlComponent.
104 * This will fail the test
107 public void testTraceSessionTree() throws Exception
{
109 fProxy
.setTestFile(fTestFile
);
110 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
112 ITraceControlComponent root
= fFacility
.getControlView().getTraceControlRoot();
114 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, fProxy
);
117 fFacility
.waitForJobs();
119 fFacility
.executeCommand(node
, "connect");
120 WaitUtils
.waitUntil(new TargetNodeConnectedCondition(node
));
122 // Get provider groups
123 ITraceControlComponent
[] groups
= node
.getChildren();
124 assertNotNull(groups
);
125 assertEquals(2, groups
.length
);
127 // Initialize dialog implementations for command execution
128 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
129 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
130 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
132 // Initialize scenario
133 fProxy
.setScenario(SCEN_SCEN_PER_UID_TEST
);
135 // ------------------------------------------------------------------------
137 // ------------------------------------------------------------------------
138 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
140 // Verify that session was created
141 assertNotNull(session
);
142 assertEquals("mysession", session
.getName());
144 // ------------------------------------------------------------------------
145 // Enable default channel on created session above
146 // ------------------------------------------------------------------------
147 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
148 channelStub
.setDomain(TraceDomainType
.UST
);
149 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
150 info
.setName("mychannel");
151 info
.setOverwriteMode(false);
152 info
.setSubBufferSize(-1);
153 info
.setNumberOfSubBuffers(-1);
154 info
.setSwitchTimer(-1);
155 info
.setReadTimer(-1);
156 info
.setMaxNumberTraceFiles(-1);
157 info
.setMaxSizeTraceFiles(-1);
158 info
.setBufferType(BufferType
.BUFFER_PER_UID
);
159 channelStub
.setChannelInfo(info
);
161 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
163 fFacility
.executeCommand(session
, "enableChannelOnSession");
165 // Verify that UST domain was created
166 ITraceControlComponent
[] domains
= session
.getChildren();
167 assertNotNull(domains
);
168 assertEquals(1, domains
.length
);
170 assertEquals("UST global", domains
[0].getName());
171 assertEquals("Domain buffer Type", BufferType
.BUFFER_PER_UID
, ((TraceDomainComponent
)domains
[0]).getBufferType());
173 // Verify that channel was created with correct data
174 ITraceControlComponent
[] channels
= domains
[0].getChildren();
175 assertNotNull(channels
);
176 assertEquals(1, channels
.length
);
178 assertTrue(channels
[0] instanceof TraceChannelComponent
);
179 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
180 assertEquals("mychannel", channel
.getName());
182 // ------------------------------------------------------------------------
184 // ------------------------------------------------------------------------
185 fFacility
.destroySession(session
);
187 // Verify that no more session components exist
188 assertEquals(0, groups
[1].getChildren().length
);
190 // ------------------------------------------------------------------------
191 // Create session (per-pid buffers)
192 // ------------------------------------------------------------------------
194 // Initialize scenario
195 fProxy
.setScenario(SCEN_SCEN_PER_PID_TEST
);
197 session
= fFacility
.createSession(groups
[1]);
199 // Verify that session was created
200 assertNotNull(session
);
201 assertEquals("mysession", session
.getName());
203 // ------------------------------------------------------------------------
204 // Enable default channel on created session above
205 // ------------------------------------------------------------------------
206 info
= (ChannelInfo
)channelStub
.getChannelInfo();
207 info
.setName("mychannel");
208 info
.setBufferType(BufferType
.BUFFER_PER_PID
);
209 channelStub
.setChannelInfo(info
);
211 fFacility
.executeCommand(session
, "enableChannelOnSession");
213 // Verify that UST domain was created
214 domains
= session
.getChildren();
215 assertNotNull(domains
);
216 assertEquals(1, domains
.length
);
218 assertEquals("UST global", domains
[0].getName());
219 assertEquals("Domain buffer Type", BufferType
.BUFFER_PER_PID
, ((TraceDomainComponent
)domains
[0]).getBufferType());
221 // Verify that channel was created with correct data
222 channels
= domains
[0].getChildren();
223 assertNotNull(channels
);
224 assertEquals(1, channels
.length
);
226 assertTrue(channels
[0] instanceof TraceChannelComponent
);
227 channel
= (TraceChannelComponent
) channels
[0];
228 assertEquals("mychannel", channel
.getName());
230 // ------------------------------------------------------------------------
232 // ------------------------------------------------------------------------
233 fFacility
.destroySession(session
);
235 // Verify that no more session components exist
236 assertEquals(0, groups
[1].getChildren().length
);
238 // ------------------------------------------------------------------------
239 // Create session (configured file size and number of files)
240 // ------------------------------------------------------------------------
242 // Initialize scenario
243 fProxy
.setScenario(SCEN_SCEN_BUF_SIZE_TEST
);
245 session
= fFacility
.createSession(groups
[1]);
247 // Verify that session was created
248 assertNotNull(session
);
249 assertEquals("mysession", session
.getName());
251 // ------------------------------------------------------------------------
252 // Enable default channel on created session above
253 // ------------------------------------------------------------------------
254 info
= (ChannelInfo
)channelStub
.getChannelInfo();
255 info
.setName("mychannel");
256 info
.setMaxNumberTraceFiles(10);
257 info
.setMaxSizeTraceFiles(1024);
258 info
.setBufferType(BufferType
.BUFFER_TYPE_UNKNOWN
);
259 channelStub
.setChannelInfo(info
);
261 fFacility
.executeCommand(session
, "enableChannelOnSession");
263 // Verify that UST domain was created
264 domains
= session
.getChildren();
265 assertNotNull(domains
);
266 assertEquals(1, domains
.length
);
268 assertEquals("UST global", domains
[0].getName());
269 assertEquals("Domain buffer Type", BufferType
.BUFFER_PER_PID
, ((TraceDomainComponent
)domains
[0]).getBufferType());
271 // Verify that channel was created with correct data
272 channels
= domains
[0].getChildren();
273 assertNotNull(channels
);
274 assertEquals(1, channels
.length
);
276 assertTrue(channels
[0] instanceof TraceChannelComponent
);
277 channel
= (TraceChannelComponent
) channels
[0];
278 assertEquals("mychannel", channel
.getName());
280 // ------------------------------------------------------------------------
282 // ------------------------------------------------------------------------
283 fFacility
.destroySession(session
);
285 // Verify that no more session components exist
286 assertEquals(0, groups
[1].getChildren().length
);
288 //-------------------------------------------------------------------------
290 //-------------------------------------------------------------------------
291 fFacility
.executeCommand(node
, "disconnect");
292 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
294 //-------------------------------------------------------------------------
296 //-------------------------------------------------------------------------
298 fFacility
.executeCommand(node
, "delete");
299 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);