Commit | Line | Data |
---|---|---|
83051fc3 | 1 | /********************************************************************** |
533d0bc3 | 2 | * Copyright (c) 2013, 2015 Ericsson |
83051fc3 BH |
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 | |
b732adaa | 11 | * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE |
83051fc3 BH |
12 | **********************************************************************/ |
13 | ||
9bc60be7 | 14 | package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component; |
83051fc3 BH |
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; | |
d8a4fd60 | 25 | import org.eclipse.jdt.annotation.NonNull; |
b732adaa | 26 | import org.eclipse.remote.core.IRemoteConnection; |
9bc60be7 | 27 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState; |
f3023b37 | 28 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
9bc60be7 AM |
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; | |
b6b4e8b4 | 42 | import org.eclipse.tracecompass.tmf.remote.core.proxy.TmfRemoteConnectionFactory; |
f3023b37 | 43 | import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; |
83051fc3 BH |
44 | import org.junit.After; |
45 | import org.junit.Before; | |
46 | import org.junit.Test; | |
47 | import org.osgi.framework.FrameworkUtil; | |
48 | ||
49 | /** | |
b0d2c558 | 50 | * The class {@link TraceControlUstSession2Test} contains UST |
83051fc3 BH |
51 | * session/channel/event handling test cases for LTTng 2.2. |
52 | */ | |
b0d2c558 | 53 | public class TraceControlUstSession2Test { |
83051fc3 BH |
54 | |
55 | // ------------------------------------------------------------------------ | |
56 | // Constants | |
57 | // ------------------------------------------------------------------------ | |
58 | ||
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"; | |
63 | ||
64 | // ------------------------------------------------------------------------ | |
65 | // Test data | |
66 | // ------------------------------------------------------------------------ | |
67 | ||
68 | private TraceControlTestFacility fFacility; | |
b6b4e8b4 | 69 | private IRemoteConnection fHost = TmfRemoteConnectionFactory.getLocalConnection(); |
d8a4fd60 | 70 | private @NonNull TestRemoteSystemProxy fProxy = new TestRemoteSystemProxy(fHost); |
83051fc3 BH |
71 | private String fTestFile; |
72 | ||
73 | // ------------------------------------------------------------------------ | |
74 | // Housekeeping | |
75 | // ------------------------------------------------------------------------ | |
76 | ||
77 | /** | |
78 | * Perform pre-test initialization. | |
79 | * | |
80 | * @throws Exception | |
81 | * if the initialization fails for some reason | |
82 | */ | |
83 | @Before | |
84 | public void setUp() throws Exception { | |
85 | fFacility = TraceControlTestFacility.getInstance(); | |
86 | fFacility.init(); | |
83051fc3 BH |
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(); | |
90 | } | |
91 | ||
92 | /** | |
93 | * Perform post-test clean-up. | |
94 | */ | |
95 | @After | |
96 | public void tearDown() { | |
83051fc3 BH |
97 | fFacility.dispose(); |
98 | } | |
99 | ||
100 | /** | |
101 | * Run the TraceControlComponent. | |
102 | * | |
103 | * @throws Exception | |
104 | * This will fail the test | |
105 | */ | |
106 | @Test | |
107 | public void testTraceSessionTree() throws Exception { | |
108 | ||
109 | fProxy.setTestFile(fTestFile); | |
110 | fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); | |
111 | ||
112 | ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot(); | |
113 | ||
d8a4fd60 | 114 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, fProxy); |
83051fc3 BH |
115 | |
116 | root.addChild(node); | |
117 | fFacility.waitForJobs(); | |
118 | ||
119 | fFacility.executeCommand(node, "connect"); | |
f3023b37 | 120 | WaitUtils.waitUntil(new TargetNodeConnectedCondition(node)); |
83051fc3 BH |
121 | |
122 | // Get provider groups | |
123 | ITraceControlComponent[] groups = node.getChildren(); | |
124 | assertNotNull(groups); | |
125 | assertEquals(2, groups.length); | |
126 | ||
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()); | |
131 | ||
132 | // Initialize scenario | |
133 | fProxy.setScenario(SCEN_SCEN_PER_UID_TEST); | |
134 | ||
135 | // ------------------------------------------------------------------------ | |
136 | // Create session | |
137 | // ------------------------------------------------------------------------ | |
138 | TraceSessionComponent session = fFacility.createSession(groups[1]); | |
139 | ||
140 | // Verify that session was created | |
141 | assertNotNull(session); | |
142 | assertEquals("mysession", session.getName()); | |
143 | ||
144 | // ------------------------------------------------------------------------ | |
145 | // Enable default channel on created session above | |
146 | // ------------------------------------------------------------------------ | |
147 | EnableChannelDialogStub channelStub = new EnableChannelDialogStub(); | |
1bc37054 | 148 | channelStub.setDomain(TraceDomainType.UST); |
83051fc3 BH |
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); | |
160 | ||
161 | TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub); | |
162 | ||
163 | fFacility.executeCommand(session, "enableChannelOnSession"); | |
164 | ||
165 | // Verify that UST domain was created | |
166 | ITraceControlComponent[] domains = session.getChildren(); | |
167 | assertNotNull(domains); | |
168 | assertEquals(1, domains.length); | |
169 | ||
170 | assertEquals("UST global", domains[0].getName()); | |
171 | assertEquals("Domain buffer Type", BufferType.BUFFER_PER_UID, ((TraceDomainComponent)domains[0]).getBufferType()); | |
172 | ||
173 | // Verify that channel was created with correct data | |
174 | ITraceControlComponent[] channels = domains[0].getChildren(); | |
175 | assertNotNull(channels); | |
176 | assertEquals(1, channels.length); | |
177 | ||
178 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
179 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; | |
180 | assertEquals("mychannel", channel.getName()); | |
181 | ||
182 | // ------------------------------------------------------------------------ | |
183 | // Destroy session | |
184 | // ------------------------------------------------------------------------ | |
185 | fFacility.destroySession(session); | |
186 | ||
187 | // Verify that no more session components exist | |
188 | assertEquals(0, groups[1].getChildren().length); | |
189 | ||
190 | // ------------------------------------------------------------------------ | |
191 | // Create session (per-pid buffers) | |
192 | // ------------------------------------------------------------------------ | |
193 | ||
194 | // Initialize scenario | |
195 | fProxy.setScenario(SCEN_SCEN_PER_PID_TEST); | |
196 | ||
197 | session = fFacility.createSession(groups[1]); | |
198 | ||
199 | // Verify that session was created | |
200 | assertNotNull(session); | |
201 | assertEquals("mysession", session.getName()); | |
202 | ||
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); | |
210 | ||
211 | fFacility.executeCommand(session, "enableChannelOnSession"); | |
212 | ||
213 | // Verify that UST domain was created | |
214 | domains = session.getChildren(); | |
215 | assertNotNull(domains); | |
216 | assertEquals(1, domains.length); | |
217 | ||
218 | assertEquals("UST global", domains[0].getName()); | |
219 | assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType()); | |
220 | ||
221 | // Verify that channel was created with correct data | |
222 | channels = domains[0].getChildren(); | |
223 | assertNotNull(channels); | |
224 | assertEquals(1, channels.length); | |
225 | ||
226 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
227 | channel = (TraceChannelComponent) channels[0]; | |
228 | assertEquals("mychannel", channel.getName()); | |
229 | ||
230 | // ------------------------------------------------------------------------ | |
231 | // Destroy session | |
232 | // ------------------------------------------------------------------------ | |
233 | fFacility.destroySession(session); | |
234 | ||
235 | // Verify that no more session components exist | |
236 | assertEquals(0, groups[1].getChildren().length); | |
237 | ||
238 | // ------------------------------------------------------------------------ | |
239 | // Create session (configured file size and number of files) | |
240 | // ------------------------------------------------------------------------ | |
241 | ||
242 | // Initialize scenario | |
243 | fProxy.setScenario(SCEN_SCEN_BUF_SIZE_TEST); | |
244 | ||
245 | session = fFacility.createSession(groups[1]); | |
246 | ||
247 | // Verify that session was created | |
248 | assertNotNull(session); | |
249 | assertEquals("mysession", session.getName()); | |
250 | ||
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); | |
260 | ||
261 | fFacility.executeCommand(session, "enableChannelOnSession"); | |
262 | ||
263 | // Verify that UST domain was created | |
264 | domains = session.getChildren(); | |
265 | assertNotNull(domains); | |
266 | assertEquals(1, domains.length); | |
267 | ||
268 | assertEquals("UST global", domains[0].getName()); | |
269 | assertEquals("Domain buffer Type", BufferType.BUFFER_PER_PID, ((TraceDomainComponent)domains[0]).getBufferType()); | |
270 | ||
271 | // Verify that channel was created with correct data | |
272 | channels = domains[0].getChildren(); | |
273 | assertNotNull(channels); | |
274 | assertEquals(1, channels.length); | |
275 | ||
276 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
277 | channel = (TraceChannelComponent) channels[0]; | |
278 | assertEquals("mychannel", channel.getName()); | |
279 | ||
280 | // ------------------------------------------------------------------------ | |
281 | // Destroy session | |
282 | // ------------------------------------------------------------------------ | |
283 | fFacility.destroySession(session); | |
284 | ||
285 | // Verify that no more session components exist | |
286 | assertEquals(0, groups[1].getChildren().length); | |
287 | ||
288 | //------------------------------------------------------------------------- | |
289 | // Disconnect node | |
290 | //------------------------------------------------------------------------- | |
291 | fFacility.executeCommand(node, "disconnect"); | |
292 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); | |
293 | ||
294 | //------------------------------------------------------------------------- | |
295 | // Delete node | |
296 | //------------------------------------------------------------------------- | |
297 | ||
298 | fFacility.executeCommand(node, "delete"); | |
83051fc3 BH |
299 | assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length); |
300 | } | |
301 | } |