Migrate to Junit 5 Jupiter
[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.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23 import static org.junit.jupiter.api.Assertions.fail;
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.jupiter.api.Test;
31 import org.junit.jupiter.api.extension.ExtendWith;
32 import org.junit.jupiter.api.AfterAll;
33 import org.junit.jupiter.api.AfterEach;
34 import org.junit.jupiter.api.BeforeAll;
35 import org.junit.jupiter.api.BeforeEach;
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.TestPrintExtension;
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 @ExtendWith(TestPrintExtension.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
76 private static TcpClientDebugListener clientListener;
77 private static LttngTcpSessiondClient client;
78 private static Thread clientThread;
79
80 private ILttngSession session;
81
82 // ------------------------------------------------------------------------
83 // Maintenance
84 // ------------------------------------------------------------------------
85
86 /**
87 * Class setup
88 */
89 @BeforeAll
90 public static void setupClass() {
91 LttngToolsHelper.destroyAllSessions();
92
93 clientListener = new TcpClientDebugListener();
94
95 /* Try connecting to a root sessiond first */
96 client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, true);
97 clientThread = new Thread(client);
98 clientThread.start();
99
100 if (client.waitForConnection(5)) {
101 return;
102 }
103
104 /* Connection was not established, try a user sessiond instead */
105 client.close();
106 try {
107 clientThread.join();
108 } catch (InterruptedException e) {
109 fail(e.getMessage());
110 }
111
112 client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, false);
113 clientThread = new Thread(client);
114 clientThread.start();
115
116 assertTrue(client.waitForConnection(5), "Timed out waiting for a sessiond");
117 }
118
119 /**
120 * Class teardown
121 */
122 @AfterAll
123 public static void teardownClass() {
124 if (client != null) {
125 client.close();
126 }
127 if (clientThread != null) {
128 try {
129 clientThread.join();
130 } catch (InterruptedException e) {
131 }
132 }
133 }
134
135 /**
136 * Test setup
137 */
138 @BeforeEach
139 public void setup() {
140 session = ILttngSession.createSession(null, SESSION_DOMAIN);
141 clientListener.clearAllCommands();
142 }
143
144 /**
145 * Test teardown
146 */
147 @AfterEach
148 public void teardown() {
149 session.close();
150 }
151
152
153 private static ILogLevelStrings getLogLevelStrings() {
154 return ILogLevelStrings.JUL_LOGLEVEL_STRINGS;
155 }
156
157 /**
158 * Check that two lists contain the exact same element (including
159 * duplicates), but their order does not matter.
160 */
161 private static <T extends Comparable<T>> boolean containSameElements(List<T> list1, List<T> list2) {
162 List<T> newlist1 = new ArrayList<>(list1);
163 List<T> newlist2 = new ArrayList<>(list2);
164 Collections.sort(newlist1);
165 Collections.sort(newlist2);
166 return (newlist1.equals(newlist2));
167
168 }
169
170 // ------------------------------------------------------------------------
171 // Event enabling/disabling test cases
172 // ------------------------------------------------------------------------
173
174 /**
175 * Test enabling one event.
176 */
177 @Test
178 public void testEnableEvent() {
179 session.enableEvent(EVENT_NAME_A, null, false, null);
180
181 List<EventRule> expectedCommands = Collections.singletonList(
182 EventRuleFactory.createRule(EVENT_NAME_A));
183
184 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
185 assertEquals(expectedCommands, actualCommands);
186 }
187
188 /**
189 * Test an "enable-event -a" command.
190 */
191 @Test
192 public void testEnableAllEvents() {
193 session.enableAllEvents();
194
195 List<EventRule> expectedCommands = Collections.singletonList(
196 EventRuleFactory.createRuleAllEvents());
197 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
198
199 assertEquals(expectedCommands, actualCommands);
200 }
201
202 /**
203 * Test enabling then disabling one event.
204 */
205 @Test
206 public void testEnableThenDisableOneEvent() {
207 session.enableEvent(EVENT_NAME_A, null, false, null);
208 session.disableEvents(EVENT_NAME_A);
209
210 List<EventRule> expectedEnableCommands = Collections.singletonList(
211 EventRuleFactory.createRule(EVENT_NAME_A));
212 List<String> expectedDisableCommands = Collections.singletonList(EVENT_NAME_A);
213
214 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
215 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
216 }
217
218 /**
219 * Test enabling some events manually, then disabling all events (-a).
220 */
221 @Test
222 public void testEnableSomeThenDisableAll() {
223 session.enableEvent(EVENT_NAME_A, null, false, null);
224 session.enableEvent(EVENT_NAME_B, null, false, null);
225 session.enableEvent(EVENT_NAME_C, null, false, null);
226 session.disableAllEvents();
227
228 List<EventRule> expectedEnableCommands = Arrays.asList(
229 EventRuleFactory.createRule(EVENT_NAME_A),
230 EventRuleFactory.createRule(EVENT_NAME_B),
231 EventRuleFactory.createRule(EVENT_NAME_C));
232 /*
233 * A "disable-event -a" will send one command for each enabled event.
234 * The order may be different though.
235 */
236 List<String> expectedDisableCommands = Arrays.asList(
237 EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C);
238
239 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
240 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
241 }
242
243 /**
244 * Test enabling then (enable-event -a) then disabling all (disable-event -a) events.
245 */
246 @Test
247 public void testEnableAllThenDisableAll() {
248 session.enableAllEvents();
249 session.disableAllEvents();
250
251 List<EventRule> expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents());
252 List<String> expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL);
253
254 assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
255 assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands()));
256 }
257
258 /**
259 * Test enabling then destroying the session (should send corresponding
260 * disable event messages).
261 */
262 @SuppressWarnings("static-method")
263 @Test
264 public void testEnableEventThenDestroy() {
265 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
266 session2.enableEvent(EVENT_NAME_A, null, false, null);
267 session2.enableEvent(EVENT_NAME_B, null, false, null);
268 } // close(), aka destroy the session, sending "disable event" messages
269
270 List<EventRule> expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B));
271 List<String> expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
272
273 assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands());
274 assertTrue(clientListener.getDisabledEventCommands().containsAll(expectedDisabledCommands));
275 }
276
277 /**
278 * Test specifying an event with a --loglevel option.
279 */
280 @Test
281 public void testEnableEventLogLevelRange() {
282 LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
283
284 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, 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 with a --loglevel-only option.
295 */
296 @Test
297 public void testEnableEventLogLevelSingle() {
298 LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
299
300 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
301
302 List<EventRule> expectedCommands = Collections.singletonList(
303 EventRuleFactory.createRule(EVENT_NAME_A, lls));
304 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
305
306 assertEquals(expectedCommands, actualCommands);
307 }
308
309 /**
310 * Test enabling an event twice, for the same loglevel, with --loglevel followed by --loglevel-only.
311 */
312 @Test
313 public void testEnableEventsLogLevelRangeAndSingle() {
314 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
315 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
316
317 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
318 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
319
320 List<EventRule> expectedCommands = Arrays.asList(
321 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
322 EventRuleFactory.createRule(EVENT_NAME_A, lls2)
323 );
324 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
325
326 assertEquals(expectedCommands, actualCommands);
327 }
328
329 /**
330 * Test enabling an event twice, for the same loglevel, with --loglevel-only followed by --loglevel.
331 */
332 @Test
333 public void testEnableEventsLogLevelSingleAndRange() {
334 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
335 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
336
337 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
338 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
339
340 List<EventRule> expectedCommands = Arrays.asList(
341 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
342 EventRuleFactory.createRule(EVENT_NAME_A, lls2)
343 );
344 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
345
346 assertEquals(expectedCommands, actualCommands);
347 }
348
349 /**
350 * Test enabling the same event, same loglevel, but different loglevel types
351 * (--loglevel vs --loglevel-only) in two separate sessions.
352 */
353 @Test
354 public void testEnableEventsLogLevelRangeAndSingleDiffSessions() {
355 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
356
357 LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
358 LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE);
359
360 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
361 session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
362
363 List<EventRule> expectedCommands = Arrays.asList(
364 EventRuleFactory.createRule(EVENT_NAME_A, lls1),
365 EventRuleFactory.createRule(EVENT_NAME_A, lls2));
366 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
367
368 assertEquals(expectedCommands, actualCommands);
369 }
370 }
371
372 /**
373 * Enable the same event multiple times with different filter strings.
374 */
375 @Test
376 public void testEnableEventsDiffFilters() {
377 final String filter1 = "filter1";
378 final String filter2 = "filter2";
379
380 session.enableEvent(EVENT_NAME_A, null, false, null);
381 session.enableEvent(EVENT_NAME_A, null, false, filter1);
382 session.enableEvent(EVENT_NAME_A, null, false, filter2);
383
384 List<EventRule> expectedCommands = Arrays.asList(
385 EventRuleFactory.createRule(EVENT_NAME_A),
386 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1),
387 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2));
388 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
389
390 assertEquals(expectedCommands, actualCommands);
391 }
392
393 /**
394 * Enable the same event multiple times with different log levels and
395 * filters.
396 */
397 @Test
398 public void testEnableEventsLogLevelAndFilters() {
399 final LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
400 final String filter = "filter1";
401
402 session.enableEvent(EVENT_NAME_A, null, false, null);
403 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
404 session.enableEvent(EVENT_NAME_A, null, false, filter);
405 session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter);
406
407 List<EventRule> expectedCommands = Arrays.asList(
408 EventRuleFactory.createRule(EVENT_NAME_A),
409 EventRuleFactory.createRule(EVENT_NAME_A, lls),
410 EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter),
411 EventRuleFactory.createRule(EVENT_NAME_A, lls, filter));
412 List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
413
414 assertEquals(expectedCommands, actualCommands);
415 }
416
417 // ------------------------------------------------------------------------
418 // Application context enabling/disabling test cases
419 // ------------------------------------------------------------------------
420
421 /**
422 * Test enabling one application context.
423 */
424 @Test
425 public void testEnableAppContext() {
426 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
427
428 List<String> expectedCommands = Collections.singletonList(
429 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
430
431 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
432 assertEquals(expectedCommands, actualCommands);
433 }
434
435 /**
436 * Test enabling two application contexts sharing the same retriever name.
437 */
438 @Test
439 public void testEnableAppContextsSameRetriever() {
440 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
441 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_B);
442
443 List<String> expectedCommands = Arrays.asList(
444 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
445 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_B);
446
447 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
448 assertEquals(expectedCommands, actualCommands);
449 }
450
451 /**
452 * Test enabling two application contexts sharing the same context name, but
453 * with different retrievers. Unusual, but they should still be recognized
454 * separately.
455 */
456 @Test
457 public void testEnableAppContextsSameContext() {
458 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
459 session.enableAppContext(CONTEXT_RETRIEVER_NAME_B, CONTEXT_NAME_A);
460
461 List<String> expectedCommands = Arrays.asList(
462 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
463 CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_A);
464
465 List<String> actualCommands = clientListener.getEnabledAppContextCommands();
466 assertEquals(expectedCommands, actualCommands);
467 }
468
469 /**
470 * Test enabling one application context, then destroying the session. We
471 * should receive the corresponding "context removed" message.
472 */
473 @Test
474 @SuppressWarnings("static-method")
475 public void testEnableAppContextThenDestroy() {
476 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
477 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
478 } // close(), aka destroy the session, sending "disable context" messages
479
480 List<String> expectedEnabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
481 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
482 List<String> actualEnabledCommands = clientListener.getEnabledAppContextCommands();
483 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
484
485 assertEquals(expectedEnabledCommands, actualEnabledCommands);
486 assertEquals(expectedDisabledCommands, actualDisabledCommands);
487 }
488
489 /**
490 * Test enabling the same application context in two different sessions.
491 * Upon destroying one, we should only receive one "destroyed" message.
492 */
493 @Test
494 public void testEnableSameAppContextTwoSessions() {
495 List<String> expectedEnabledCommands = Arrays.asList(
496 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
497 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
498 List<String> actualEnabledCommands;
499
500 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
501 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
502 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
503
504 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
505 assertEquals(expectedEnabledCommands, actualEnabledCommands);
506 } // close/destroy session2
507
508 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
509 assertEquals(expectedEnabledCommands, actualEnabledCommands);
510
511 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
512 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
513
514 assertEquals(expectedDisabledCommands, actualDisabledCommands);
515 }
516
517 /**
518 * Test enabling two different application context in two different
519 * sessions. Upon destroying one, we should receive the correct "destroyed"
520 * message.
521 */
522 @Test
523 public void testEnableDiffAppContextTwoSessions() {
524 List<String> expectedEnabledCommands = Arrays.asList(
525 CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A,
526 CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_B);
527 List<String> actualEnabledCommands;
528
529 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
530 session.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
531 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_B, CONTEXT_NAME_B);
532
533 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
534 assertEquals(expectedEnabledCommands, actualEnabledCommands);
535 } // close/destroy session2
536
537 actualEnabledCommands = clientListener.getEnabledAppContextCommands();
538 assertEquals(expectedEnabledCommands, actualEnabledCommands);
539
540 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_B + ':' + CONTEXT_NAME_B);
541 List<String> actualDisabledCommands = clientListener.getDisabledAppContextCommands();
542
543 assertEquals(expectedDisabledCommands, actualDisabledCommands);
544 }
545
546 // ------------------------------------------------------------------------
547 // Application context filtering
548 // ------------------------------------------------------------------------
549
550 /**
551 * Test that enabling an event with a filter string referring to a context
552 * should send an agent message about this context now being "enabled".
553 *
554 * This is because we will pass the context information to UST for the
555 * filtering step, even if the actual context won't be present in the trace.
556 */
557 @SuppressWarnings("static-method")
558 @Test
559 public void testContextInFilterString() {
560 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
561 session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
562
563 List<String> expectedEnabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
564 assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
565 } // close(), aka destroy the session, sending "disable context" messages
566
567 List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
568 assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
569 }
570
571 /**
572 * Test that if we the context is both referred to by a filter string *and*
573 * enabled directly, we receive *2* messages about this context being
574 * enabled (and disabled on session teardown).
575 */
576 @SuppressWarnings("static-method")
577 @Test
578 public void testContextEnabledAndInFilterString() {
579 try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
580 session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
581 session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
582
583 List<String> expectedEnabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
584 assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
585 } // close(), aka destroy the session, sending "disable context" messages
586
587 List<String> expectedDisabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
588 assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
589 }
590 }
This page took 0.043371 seconds and 4 git commands to generate.