Fix latest tests
[lttng-ust-java-tests.git] / lttng-ust-java-tests-common / src / test / java / org / lttng / ust / agent / integration / client / TcpClientIT.java
1 /*
2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 package org.lttng.ust.agent.integration.client;
20
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assume.assumeTrue;
24
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.Collections;
28 import java.util.List;
29
30 import org.junit.After;
31 import org.junit.AfterClass;
32 import org.junit.Before;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.lttng.tools.ILttngSession;
37 import org.lttng.tools.LttngToolsHelper;
38 import org.lttng.ust.agent.ILttngAgent;
39 import org.lttng.ust.agent.client.LttngTcpSessiondClient;
40 import org.lttng.ust.agent.session.EventRule;
41 import org.lttng.ust.agent.session.LogLevelSelector;
42 import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType;
43 import org.lttng.ust.agent.utils.EventRuleFactory;
44 import org.lttng.ust.agent.utils.ILogLevelStrings;
45 import org.lttng.ust.agent.utils.TestPrintRunner;
46
47 /**
48 * Tests for the TCP client only, without using an agent.
49 *
50 * This test suite requires that a *root* session daemon is running on the
51 * system. Since we have to explicitly tell the TCP client which sessiond to
52 * connect to, we have to hard-code it in here.
53 *
54 * @author Alexandre Montplaisir
55 */
56 @RunWith(TestPrintRunner.class)
57 public class TcpClientIT {
58
59 // ------------------------------------------------------------------------
60 // Attributes
61 // ------------------------------------------------------------------------
62
63 private static final String EVENT_NAME_A = "eventA";
64 private static final String EVENT_NAME_B = "eventB";
65 private static final String EVENT_NAME_C = "eventC";
66
67 private static final String CONTEXT_RETRIEVER_NAME_A = "retrieverA";
68 private static final String CONTEXT_RETRIEVER_NAME_B = "retrieverB";
69 private static final String CONTEXT_NAME_A = "contextA";
70 private static final String CONTEXT_NAME_B = "contextB";
71
72 /* Test configuration */
73 private static final int DOMAIN_VALUE = ILttngAgent.Domain.JUL.value();
74 private static final ILttngSession.Domain SESSION_DOMAIN = ILttngSession.Domain.JUL;
75 private static final boolean ROOT_SESSIOND = true;
76
77 private static TcpClientDebugListener clientListener;
78 private static LttngTcpSessiondClient client;
79 private static Thread clientThread;
80
81 private ILttngSession session;
82
83 // ------------------------------------------------------------------------
84 // Maintenance
85 // ------------------------------------------------------------------------
86
87 /**
88 * Class setup
89 */
90 @BeforeClass
91 public static void setupClass() {
92 LttngToolsHelper.destroyAllSessions();
93
94 clientListener = new TcpClientDebugListener();
95 client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, ROOT_SESSIOND);
96
97 clientThread = new Thread(client);
98 clientThread.start();
99
100 assumeTrue("Timed out waiting for root sessiond", client.waitForConnection(5));
101 }
102
103 /**
104 * Class teardown
105 */
106 @AfterClass
107 public static void teardownClass() {
108 if (client != null) {
109 client.close();
110 }
111 if (clientThread != null) {
112 try {
113 clientThread.join();
114 } catch (InterruptedException e) {
115 }
116 }
117 }
118
119 /**
120 * Test setup
121 */
122 @Before
123 public void setup() {
124 session = ILttngSession.createSession(null, SESSION_DOMAIN);
125 clientListener.clearAllCommands();
126 }
127
128 /**
129 * Test teardown
130 */
131 @After
132 public void teardown() {
133 session.close();
134 }
135
136
137 private static ILogLevelStrings getLogLevelStrings() {
138 return ILogLevelStrings.JUL_LOGLEVEL_STRINGS;
139 }
140
141 /**
142 * Check that two lists contain the exact same element (including
143 * duplicates), but their order does not matter.
144 */
145 private static <T extends Comparable<T>> boolean containSameElements(List<T> list1, List<T> list2) {
146 List<T> newlist1 = new ArrayList<>(list1);
147 List<T> newlist2 = new ArrayList<>(list2);
148 Collections.sort(newlist1);
149 Collections.sort(newlist2);
150 return (newlist1.equals(newlist2));
151
152 }
153
154 // ------------------------------------------------------------------------
155 // Event enabling/disabling test cases
156 // ------------------------------------------------------------------------
157
158 /**
159 * Test enabling one event.
160 */
161 @Test
162 public void testEnableEvent() {
163 session.enableEvent(EVENT_NAME_A, null, false, null);
164
165 List<EventRule> expectedCommands = Collections.singletonList(
166 EventRuleFactory.createRule(EVENT_NAME_A));
167
168 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
169 assertEquals(expectedCommands, actualCommands);
170 }
171
172 /**
173 * Test an "enable-event -a" command.
174 */
175 @Test
176 public void testEnableAllEvents() {
177 session.enableAllEvents();
178
179 List<EventRule> expectedCommands = Collections.singletonList(
180 EventRuleFactory.createRuleAllEvents());
181 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
182
183 assertEquals(expectedCommands, actualCommands);
184 }
185
186 /**
187 * Test enabling then disabling one event.
188 */
189 @Test
190 public void testEnableThenDisableOneEvent() {
191 session.enableEvent(EVENT_NAME_A, null, false, null);
192 session.disableEvents(EVENT_NAME_A);
193
194 List<EventRule> expectedEnableCommands = Collections.singletonList(
195 EventRuleFactory.createRule(EVENT_NAME_A));
196 List<String> expectedDisableCommands = Collections.singletonList(EVENT_NAME_A);
197
198 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
199 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
200 }
201
202 /**
203 * Test enabling some events manually, then disabling all events (-a).
204 */
205 @Test
206 public void testEnableSomeThenDisableAll() {
207 session.enableEvent(EVENT_NAME_A, null, false, null);
208 session.enableEvent(EVENT_NAME_B, null, false, null);
209 session.enableEvent(EVENT_NAME_C, null, false, null);
210 session.disableAllEvents();
211
212 List<EventRule> expectedEnableCommands = Arrays.asList(
213 EventRuleFactory.createRule(EVENT_NAME_A),
214 EventRuleFactory.createRule(EVENT_NAME_B),
215 EventRuleFactory.createRule(EVENT_NAME_C));
216 /*
217 * A "disable-event -a" will send one command for each enabled event.
218 * The order may be different though.
219 */
220 List<String> expectedDisableCommands = Arrays.asList(
221 EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C);
222
223 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
224 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
225 }
226
227 /**
228 * Test enabling then (enable-event -a) then disabling all (disable-event -a) events.
229 */
230 @Test
231 public void testEnableAllThenDisableAll() {
232 session.enableAllEvents();
233 session.disableAllEvents();
234
235 List<EventRule> expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents());
236 List<String> expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL);
237
238 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
239 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
240 }
241
242 /**
243 * Test enabling then destroying the session (should send corresponding
244 * disable event messages).
245 */
246 @SuppressWarnings("static-method")
247 @Test
248 public void testEnableEventThenDestroy() {
249 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
250 session2.enableEvent(EVENT_NAME_A, null, false, null);
251 session2.enableEvent(EVENT_NAME_B, null, false, null);
252 } // close(), aka destroy the session, sending "disable event" messages
253
254 List<EventRule> expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B));
255 List<String> expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
256
257 assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands());
258 assertTrue(clientListener.getDisabledEventCommands().containsAll(expectedDisabledCommands));
259 }
260
261 /**
262 * Test specifying an event with a --loglevel option.
263 */
264 @Test
265 public void testEnableEventLogLevelRange() {
266 LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
267
268 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
269
270 List<EventRule> expectedCommands = Collections.singletonList(
271 EventRuleFactory.createRule(EVENT_NAME_A, lls));
272 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
273
274 assertEquals(expectedCommands, actualCommands);
275 }
276
277 /**
278 * Test enabling an event with a --loglevel-only option.
279 */
280 @Test
281 public void testEnableEventLogLevelSingle() {
282 LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
283
284 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
285
286 List<EventRule> expectedCommands = Collections.singletonList(
287 EventRuleFactory.createRule(EVENT_NAME_A, lls));
288 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
289
290 assertEquals(expectedCommands, actualCommands);
291 }
292
293 /**
294 * Test enabling an event twice, for the same loglevel, with --loglevel followed by --loglevel-only.
295 */
296 @Test
297 public void testEnableEventsLogLevelRangeAndSingle() {
298 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
299 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
300
301 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
302 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
303
304 List<EventRule> expectedCommands = Arrays.asList(
305 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
306 EventRuleFactory.createRule(EVENT_NAME_A, lls2)
307 );
308 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
309
310 assertEquals(expectedCommands, actualCommands);
311 }
312
313 /**
314 * Test enabling an event twice, for the same loglevel, with --loglevel-only followed by --loglevel.
315 */
316 @Test
317 public void testEnableEventsLogLevelSingleAndRange() {
318 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
319 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
320
321 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
322 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
323
324 List<EventRule> expectedCommands = Arrays.asList(
325 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
326 EventRuleFactory.createRule(EVENT_NAME_A, lls2)
327 );
328 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
329
330 assertEquals(expectedCommands, actualCommands);
331 }
332
333 /**
334 * Test enabling the same event, same loglevel, but different loglevel types
335 * (--loglevel vs --loglevel-only) in two separate sessions.
336 */
337 @Test
338 public void testEnableEventsLogLevelRangeAndSingleDiffSessions() {
339 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
340
341 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
342 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
343
344 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
345 session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
346
347 List<EventRule> expectedCommands = Arrays.asList(
348 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
349 EventRuleFactory.createRule(EVENT_NAME_A, lls2));
350 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
351
352 assertEquals(expectedCommands, actualCommands);
353 }
354 }
355
356 /**
357 * Enable the same event multiple times with different filter strings.
358 */
359 @Test
360 public void testEnableEventsDiffFilters() {
361 final String filter1 = "filter1";
362 final String filter2 = "filter2";
363
364 session.enableEvent(EVENT_NAME_A, null, false, null);
365 session.enableEvent(EVENT_NAME_A, null, false, filter1);
366 session.enableEvent(EVENT_NAME_A, null, false, filter2);
367
368 List<EventRule> expectedCommands = Arrays.asList(
369 EventRuleFactory.createRule(EVENT_NAME_A),
370 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1),
371 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2));
372 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
373
374 assertEquals(expectedCommands, actualCommands);
375 }
376
377 /**
378 * Enable the same event multiple times with different log levels and
379 * filters.
380 */
381 @Test
382 public void testEnableEventsLogLevelAndFilters() {
383 final LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
384 final String filter = "filter1";
385
386 session.enableEvent(EVENT_NAME_A, null, false, null);
387 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
388 session.enableEvent(EVENT_NAME_A, null, false, filter);
389 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter);
390
391 List<EventRule> expectedCommands = Arrays.asList(
392 EventRuleFactory.createRule(EVENT_NAME_A),
393 EventRuleFactory.createRule(EVENT_NAME_A, lls),
394 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter),
395 EventRuleFactory.createRule(EVENT_NAME_A, lls, filter));
396 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
397
398 assertEquals(expectedCommands, actualCommands);
399 }
400
401 // ------------------------------------------------------------------------
402 // Application context enabling/disabling test cases
403 // ------------------------------------------------------------------------
404
405 /**
406 * Test enabling one application context.
407 */
408 @Test
409 public void testEnableAppContext() {
410 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
411
412 List<String> expectedCommands = Collections.singletonList(
413 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
414
415 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
416 assertEquals(expectedCommands, actualCommands);
417 }
418
419 /**
420 * Test enabling two application contexts sharing the same retriever name.
421 */
422 @Test
423 public void testEnableAppContextsSameRetriever() {
424 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
425 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_B);
426
427 List<String> expectedCommands = Arrays.asList(
428 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
429 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_B);
430
431 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
432 assertEquals(expectedCommands, actualCommands);
433 }
434
435 /**
436 * Test enabling two application contexts sharing the same context name, but
437 * with different retrievers. Unusual, but they should still be recognized
438 * separately.
439 */
440 @Test
441 public void testEnableAppContextsSameContext() {
442 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
443 session.enableAppContext(CONTEXT_RETRIEVER_NAME_B, CONTEXT_NAME_A);
444
445 List<String> expectedCommands = Arrays.asList(
446 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
447 CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_A);
448
449 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
450 assertEquals(expectedCommands, actualCommands);
451 }
452
453 /**
454 * Test enabling one application context, then destroying the session. We
455 * should receive the corresponding "context removed" message.
456 */
457 @Test
458 @SuppressWarnings("static-method")
459 public void testEnableAppContextThenDestroy() {
460 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
461 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
462 } // close(), aka destroy the session, sending "disable context" messages
463
464 List<String> expectedEnabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
465 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
466 List<String> actualEnabledCommands = clientListener.getEnabledAppContextCommands();
467 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
468
469 assertEquals(expectedEnabledCommands, actualEnabledCommands);
470 assertEquals(expectedDisabledCommands, actualDisabledCommands);
471 }
472
473 /**
474 * Test enabling the same application context in two different sessions.
475 * Upon destroying one, we should only receive one "destroyed" message.
476 */
477 @Test
478 public void testEnableSameAppContextTwoSessions() {
479 List<String> expectedEnabledCommands = Arrays.asList(
480 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
481 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
482 List<String> actualEnabledCommands;
483
484 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
485 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
486 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
487
488 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
489 assertEquals(expectedEnabledCommands, actualEnabledCommands);
490 } // close/destroy session2
491
492 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
493 assertEquals(expectedEnabledCommands, actualEnabledCommands);
494
495 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
496 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
497
498 assertEquals(expectedDisabledCommands, actualDisabledCommands);
499 }
500
501 /**
502 * Test enabling two different application context in two different
503 * sessions. Upon destroying one, we should receive the correct "destroyed"
504 * message.
505 */
506 @Test
507 public void testEnableDiffAppContextTwoSessions() {
508 List<String> expectedEnabledCommands = Arrays.asList(
509 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
510 CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_B);
511 List<String> actualEnabledCommands;
512
513 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
514 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
515 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_B, CONTEXT_NAME_B);
516
517 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
518 assertEquals(expectedEnabledCommands, actualEnabledCommands);
519 } // close/destroy session2
520
521 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
522 assertEquals(expectedEnabledCommands, actualEnabledCommands);
523
524 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_B);
525 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
526
527 assertEquals(expectedDisabledCommands, actualDisabledCommands);
528 }
529
530 // ------------------------------------------------------------------------
531 // Application context filtering
532 // ------------------------------------------------------------------------
533
534 /**
535 * Test that enabling an event with a filter string referring to a context
536 * should send an agent message about this context now being "enabled".
537 *
538 * This is because we will pass the context information to UST for the
539 * filtering step, even if the actual context won't be present in the trace.
540 */
541 @SuppressWarnings("static-method")
542 @Test
543 public void testContextInFilterString() {
544 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
545 session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
546
547 List<String> expectedEnabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
548 assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
549 } // close(), aka destroy the session, sending "disable context" messages
550
551 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
552 assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
553 }
554
555 /**
556 * Test that if we the context is both referred to by a filter string *and*
557 * enabled directly, we receive *2* messages about this context being
558 * enabled (and disabled on session teardown).
559 */
560 @SuppressWarnings("static-method")
561 @Test
562 public void testContextEnabledAndInFilterString() {
563 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
564 session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
565 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
566
567 List<String> expectedEnabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
568 assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
569 } // close(), aka destroy the session, sending "disable context" messages
570
571 List<String> expectedDisabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
572 assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
573 }
574 }
This page took 0.064426 seconds and 4 git commands to generate.