Bug 448058: Replace RSE by org.eclipse.remote
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / model / component / TraceControlUstSessionTests2.java
1 /**********************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 **********************************************************************/
13
14 package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
15
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.assertNotNull;
18 import static org.junit.Assert.assertTrue;
19
20 import java.io.File;
21 import java.net.URL;
22
23 import org.eclipse.core.runtime.FileLocator;
24 import org.eclipse.core.runtime.Path;
25 import org.eclipse.remote.core.IRemoteConnection;
26 import org.eclipse.remote.core.IRemoteConnectionManager;
27 import org.eclipse.remote.core.RemoteServices;
28 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
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.junit.After;
43 import org.junit.Before;
44 import org.junit.Test;
45 import org.osgi.framework.FrameworkUtil;
46
47 /**
48 * The class <code>TraceControlUstSessionTests</code> contains UST
49 * session/channel/event handling test cases for LTTng 2.2.
50 */
51 public class TraceControlUstSessionTests2 {
52
53 // ------------------------------------------------------------------------
54 // Constants
55 // ------------------------------------------------------------------------
56
57 private static final String TEST_STREAM = "CreateTreeTest2.cfg";
58 private static final String SCEN_SCEN_PER_UID_TEST = "ScenPerUidTest";
59 private static final String SCEN_SCEN_PER_PID_TEST = "ScenPerPidTest";
60 private static final String SCEN_SCEN_BUF_SIZE_TEST = "ScenBufSizeTest";
61
62 // ------------------------------------------------------------------------
63 // Test data
64 // ------------------------------------------------------------------------
65
66 private TraceControlTestFacility fFacility;
67 private TestRemoteSystemProxy fProxy;
68 private String fTestFile;
69
70 // ------------------------------------------------------------------------
71 // Housekeeping
72 // ------------------------------------------------------------------------
73
74 /**
75 * Perform pre-test initialization.
76 *
77 * @throws Exception
78 * if the initialization fails for some reason
79 */
80 @Before
81 public void setUp() throws Exception {
82 fFacility = TraceControlTestFacility.getInstance();
83 fFacility.init();
84 fProxy = new TestRemoteSystemProxy();
85 URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
86 File testfile = new File(FileLocator.toFileURL(location).toURI());
87 fTestFile = testfile.getAbsolutePath();
88 }
89
90 /**
91 * Perform post-test clean-up.
92 */
93 @After
94 public void tearDown() {
95 fFacility.waitForJobs();
96 fFacility.dispose();
97 }
98
99 /**
100 * Run the TraceControlComponent.
101 *
102 * @throws Exception
103 * This will fail the test
104 */
105 @Test
106 public void testTraceSessionTree() throws Exception {
107
108 fProxy.setTestFile(fTestFile);
109 fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST);
110
111 ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
112
113 IRemoteConnectionManager cm = RemoteServices.getLocalServices().getConnectionManager();
114 IRemoteConnection host = cm.getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME);
115 TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
116
117 root.addChild(node);
118 fFacility.waitForJobs();
119
120 fFacility.executeCommand(node, "connect");
121 int i = 0;
122 while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) {
123 i++;
124 fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
125 }
126
127 // Get provider groups
128 ITraceControlComponent[] groups = node.getChildren();
129 assertNotNull(groups);
130 assertEquals(2, groups.length);
131
132 // Initialize dialog implementations for command execution
133 TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
134 TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
135 TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
136
137 // Initialize scenario
138 fProxy.setScenario(SCEN_SCEN_PER_UID_TEST);
139
140 // ------------------------------------------------------------------------
141 // Create session
142 // ------------------------------------------------------------------------
143 TraceSessionComponent session = fFacility.createSession(groups[1]);
144
145 // Verify that session was created
146 assertNotNull(session);
147 assertEquals("mysession", session.getName());
148
149 // ------------------------------------------------------------------------
150 // Enable default channel on created session above
151 // ------------------------------------------------------------------------
152 EnableChannelDialogStub channelStub = new EnableChannelDialogStub();
153 channelStub.setIsKernel(false);
154 ChannelInfo info = (ChannelInfo)channelStub.getChannelInfo();
155 info.setName("mychannel");
156 info.setOverwriteMode(false);
157 info.setSubBufferSize(-1);
158 info.setNumberOfSubBuffers(-1);
159 info.setSwitchTimer(-1);
160 info.setReadTimer(-1);
161 info.setMaxNumberTraceFiles(-1);
162 info.setMaxSizeTraceFiles(-1);
163 info.setBufferType(BufferType.BUFFER_PER_UID);
164 channelStub.setChannelInfo(info);
165
166 TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub);
167
168 fFacility.executeCommand(session, "enableChannelOnSession");
169
170 // Verify that UST domain was created
171 ITraceControlComponent[] domains = session.getChildren();
172 assertNotNull(domains);
173 assertEquals(1, domains.length);
174
175 assertEquals("UST global", domains[0].getName());
176 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_UID, ((TraceDomainComponent)domains[0]).getBufferType());
177
178 // Verify that channel was created with correct data
179 ITraceControlComponent[] channels = domains[0].getChildren();
180 assertNotNull(channels);
181 assertEquals(1, channels.length);
182
183 assertTrue(channels[0] instanceof TraceChannelComponent);
184 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
185 assertEquals("mychannel", channel.getName());
186
187 // ------------------------------------------------------------------------
188 // Destroy session
189 // ------------------------------------------------------------------------
190 fFacility.destroySession(session);
191
192 // Verify that no more session components exist
193 assertEquals(0, groups[1].getChildren().length);
194
195 // ------------------------------------------------------------------------
196 // Create session (per-pid buffers)
197 // ------------------------------------------------------------------------
198
199 // Initialize scenario
200 fProxy.setScenario(SCEN_SCEN_PER_PID_TEST);
201
202 session = fFacility.createSession(groups[1]);
203
204 // Verify that session was created
205 assertNotNull(session);
206 assertEquals("mysession", session.getName());
207
208 // ------------------------------------------------------------------------
209 // Enable default channel on created session above
210 // ------------------------------------------------------------------------
211 info = (ChannelInfo)channelStub.getChannelInfo();
212 info.setName("mychannel");
213 info.setBufferType(BufferType.BUFFER_PER_PID);
214 channelStub.setChannelInfo(info);
215
216 fFacility.executeCommand(session, "enableChannelOnSession");
217
218 // Verify that UST domain was created
219 domains = session.getChildren();
220 assertNotNull(domains);
221 assertEquals(1, domains.length);
222
223 assertEquals("UST global", domains[0].getName());
224 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType());
225
226 // Verify that channel was created with correct data
227 channels = domains[0].getChildren();
228 assertNotNull(channels);
229 assertEquals(1, channels.length);
230
231 assertTrue(channels[0] instanceof TraceChannelComponent);
232 channel = (TraceChannelComponent) channels[0];
233 assertEquals("mychannel", channel.getName());
234
235 // ------------------------------------------------------------------------
236 // Destroy session
237 // ------------------------------------------------------------------------
238 fFacility.destroySession(session);
239
240 // Verify that no more session components exist
241 assertEquals(0, groups[1].getChildren().length);
242
243 // ------------------------------------------------------------------------
244 // Create session (configured file size and number of files)
245 // ------------------------------------------------------------------------
246
247 // Initialize scenario
248 fProxy.setScenario(SCEN_SCEN_BUF_SIZE_TEST);
249
250 session = fFacility.createSession(groups[1]);
251
252 // Verify that session was created
253 assertNotNull(session);
254 assertEquals("mysession", session.getName());
255
256 // ------------------------------------------------------------------------
257 // Enable default channel on created session above
258 // ------------------------------------------------------------------------
259 info = (ChannelInfo)channelStub.getChannelInfo();
260 info.setName("mychannel");
261 info.setMaxNumberTraceFiles(10);
262 info.setMaxSizeTraceFiles(1024);
263 info.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
264 channelStub.setChannelInfo(info);
265
266 fFacility.executeCommand(session, "enableChannelOnSession");
267
268 // Verify that UST domain was created
269 domains = session.getChildren();
270 assertNotNull(domains);
271 assertEquals(1, domains.length);
272
273 assertEquals("UST global", domains[0].getName());
274 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType());
275
276 // Verify that channel was created with correct data
277 channels = domains[0].getChildren();
278 assertNotNull(channels);
279 assertEquals(1, channels.length);
280
281 assertTrue(channels[0] instanceof TraceChannelComponent);
282 channel = (TraceChannelComponent) channels[0];
283 assertEquals("mychannel", channel.getName());
284
285 // ------------------------------------------------------------------------
286 // Destroy session
287 // ------------------------------------------------------------------------
288 fFacility.destroySession(session);
289
290 // Verify that no more session components exist
291 assertEquals(0, groups[1].getChildren().length);
292
293 //-------------------------------------------------------------------------
294 // Disconnect node
295 //-------------------------------------------------------------------------
296 fFacility.executeCommand(node, "disconnect");
297 assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
298
299 //-------------------------------------------------------------------------
300 // Delete node
301 //-------------------------------------------------------------------------
302
303 fFacility.executeCommand(node, "delete");
304
305 assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
306 }
307 }
This page took 0.038296 seconds and 5 git commands to generate.