lttng: Add a diagram showing the dependencies between plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui.tests / src / org / eclipse / linuxtools / lttng2 / ui / tests / control / model / component / TraceControlUstSessionTests2.java
CommitLineData
83051fc3
BH
1/**********************************************************************
2 * Copyright (c) 2013 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 **********************************************************************/
12
13package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
14
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertNotNull;
17import static org.junit.Assert.assertTrue;
18
19import java.io.File;
20import java.net.URL;
21
22import org.eclipse.core.runtime.FileLocator;
23import org.eclipse.core.runtime.Path;
24import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
25import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType;
26import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
27import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
28import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
29import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub;
30import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.GetEventInfoDialogStub;
31import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
32import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
33import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
34import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
35import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
36import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
37import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
38import org.eclipse.rse.core.RSECorePlugin;
39import org.eclipse.rse.core.model.IHost;
40import org.eclipse.rse.core.model.ISystemProfile;
41import org.eclipse.rse.core.model.ISystemRegistry;
42import org.junit.After;
43import org.junit.Before;
44import org.junit.Test;
45import 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 */
51public 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 ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
114 ISystemProfile profile = registry.createSystemProfile("myProfile", true);
115 IHost host = registry.createLocalHost(profile, "myProfile", "user");
116
117 TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
118
119 root.addChild(node);
120 fFacility.waitForJobs();
121
122 fFacility.executeCommand(node, "connect");
123 int i = 0;
124 while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) {
125 i++;
126 fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
127 }
128
129 // Get provider groups
130 ITraceControlComponent[] groups = node.getChildren();
131 assertNotNull(groups);
132 assertEquals(2, groups.length);
133
134 // Initialize dialog implementations for command execution
135 TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
136 TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
137 TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
138
139 // Initialize scenario
140 fProxy.setScenario(SCEN_SCEN_PER_UID_TEST);
141
142 // ------------------------------------------------------------------------
143 // Create session
144 // ------------------------------------------------------------------------
145 TraceSessionComponent session = fFacility.createSession(groups[1]);
146
147 // Verify that session was created
148 assertNotNull(session);
149 assertEquals("mysession", session.getName());
150
151 // ------------------------------------------------------------------------
152 // Enable default channel on created session above
153 // ------------------------------------------------------------------------
154 EnableChannelDialogStub channelStub = new EnableChannelDialogStub();
155 channelStub.setIsKernel(false);
156 ChannelInfo info = (ChannelInfo)channelStub.getChannelInfo();
157 info.setName("mychannel");
158 info.setOverwriteMode(false);
159 info.setSubBufferSize(-1);
160 info.setNumberOfSubBuffers(-1);
161 info.setSwitchTimer(-1);
162 info.setReadTimer(-1);
163 info.setMaxNumberTraceFiles(-1);
164 info.setMaxSizeTraceFiles(-1);
165 info.setBufferType(BufferType.BUFFER_PER_UID);
166 channelStub.setChannelInfo(info);
167
168 TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub);
169
170 fFacility.executeCommand(session, "enableChannelOnSession");
171
172 // Verify that UST domain was created
173 ITraceControlComponent[] domains = session.getChildren();
174 assertNotNull(domains);
175 assertEquals(1, domains.length);
176
177 assertEquals("UST global", domains[0].getName());
178 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_UID, ((TraceDomainComponent)domains[0]).getBufferType());
179
180 // Verify that channel was created with correct data
181 ITraceControlComponent[] channels = domains[0].getChildren();
182 assertNotNull(channels);
183 assertEquals(1, channels.length);
184
185 assertTrue(channels[0] instanceof TraceChannelComponent);
186 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
187 assertEquals("mychannel", channel.getName());
188
189 // ------------------------------------------------------------------------
190 // Destroy session
191 // ------------------------------------------------------------------------
192 fFacility.destroySession(session);
193
194 // Verify that no more session components exist
195 assertEquals(0, groups[1].getChildren().length);
196
197 // ------------------------------------------------------------------------
198 // Create session (per-pid buffers)
199 // ------------------------------------------------------------------------
200
201 // Initialize scenario
202 fProxy.setScenario(SCEN_SCEN_PER_PID_TEST);
203
204 session = fFacility.createSession(groups[1]);
205
206 // Verify that session was created
207 assertNotNull(session);
208 assertEquals("mysession", session.getName());
209
210 // ------------------------------------------------------------------------
211 // Enable default channel on created session above
212 // ------------------------------------------------------------------------
213 info = (ChannelInfo)channelStub.getChannelInfo();
214 info.setName("mychannel");
215 info.setBufferType(BufferType.BUFFER_PER_PID);
216 channelStub.setChannelInfo(info);
217
218 fFacility.executeCommand(session, "enableChannelOnSession");
219
220 // Verify that UST domain was created
221 domains = session.getChildren();
222 assertNotNull(domains);
223 assertEquals(1, domains.length);
224
225 assertEquals("UST global", domains[0].getName());
226 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType());
227
228 // Verify that channel was created with correct data
229 channels = domains[0].getChildren();
230 assertNotNull(channels);
231 assertEquals(1, channels.length);
232
233 assertTrue(channels[0] instanceof TraceChannelComponent);
234 channel = (TraceChannelComponent) channels[0];
235 assertEquals("mychannel", channel.getName());
236
237 // ------------------------------------------------------------------------
238 // Destroy session
239 // ------------------------------------------------------------------------
240 fFacility.destroySession(session);
241
242 // Verify that no more session components exist
243 assertEquals(0, groups[1].getChildren().length);
244
245 // ------------------------------------------------------------------------
246 // Create session (configured file size and number of files)
247 // ------------------------------------------------------------------------
248
249 // Initialize scenario
250 fProxy.setScenario(SCEN_SCEN_BUF_SIZE_TEST);
251
252 session = fFacility.createSession(groups[1]);
253
254 // Verify that session was created
255 assertNotNull(session);
256 assertEquals("mysession", session.getName());
257
258 // ------------------------------------------------------------------------
259 // Enable default channel on created session above
260 // ------------------------------------------------------------------------
261 info = (ChannelInfo)channelStub.getChannelInfo();
262 info.setName("mychannel");
263 info.setMaxNumberTraceFiles(10);
264 info.setMaxSizeTraceFiles(1024);
265 info.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
266 channelStub.setChannelInfo(info);
267
268 fFacility.executeCommand(session, "enableChannelOnSession");
269
270 // Verify that UST domain was created
271 domains = session.getChildren();
272 assertNotNull(domains);
273 assertEquals(1, domains.length);
274
275 assertEquals("UST global", domains[0].getName());
276 assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType());
277
278 // Verify that channel was created with correct data
279 channels = domains[0].getChildren();
280 assertNotNull(channels);
281 assertEquals(1, channels.length);
282
283 assertTrue(channels[0] instanceof TraceChannelComponent);
284 channel = (TraceChannelComponent) channels[0];
285 assertEquals("mychannel", channel.getName());
286
287 // ------------------------------------------------------------------------
288 // Destroy session
289 // ------------------------------------------------------------------------
290 fFacility.destroySession(session);
291
292 // Verify that no more session components exist
293 assertEquals(0, groups[1].getChildren().length);
294
295 //-------------------------------------------------------------------------
296 // Disconnect node
297 //-------------------------------------------------------------------------
298 fFacility.executeCommand(node, "disconnect");
299 assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
300
301 //-------------------------------------------------------------------------
302 // Delete node
303 //-------------------------------------------------------------------------
304
305 fFacility.executeCommand(node, "delete");
306
307 assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
308 }
309}
This page took 0.041271 seconds and 5 git commands to generate.