2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
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.
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.
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.
19 package org
.lttng
.ust
.agent
.integration
.client
;
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
;
25 import java
.util
.ArrayList
;
26 import java
.util
.Arrays
;
27 import java
.util
.Collections
;
28 import java
.util
.List
;
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
;
48 * Tests for the TCP client only, without using an agent.
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.
54 * @author Alexandre Montplaisir
56 @ExtendWith(TestPrintExtension
.class)
57 public class TcpClientIT
{
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
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";
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";
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
;
76 private static TcpClientDebugListener clientListener
;
77 private static LttngTcpSessiondClient client
;
78 private static Thread clientThread
;
80 private static EventRuleFactory eventRuleFactory
= new EventRuleFactory(SESSION_DOMAIN
);
82 private ILttngSession session
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
92 public static void setupClass() {
93 LttngToolsHelper
.destroyAllSessions();
95 clientListener
= new TcpClientDebugListener();
97 /* Try connecting to a root sessiond first */
98 client
= new LttngTcpSessiondClient(clientListener
, DOMAIN_VALUE
, true);
99 clientThread
= new Thread(client
);
100 clientThread
.start();
102 if (client
.waitForConnection(5)) {
106 /* Connection was not established, try a user sessiond instead */
110 } catch (InterruptedException e
) {
111 fail(e
.getMessage());
114 client
= new LttngTcpSessiondClient(clientListener
, DOMAIN_VALUE
, false);
115 clientThread
= new Thread(client
);
116 clientThread
.start();
118 assertTrue(client
.waitForConnection(5), "Timed out waiting for a sessiond");
125 public static void teardownClass() {
126 if (client
!= null) {
129 if (clientThread
!= null) {
132 } catch (InterruptedException e
) {
141 public void setup() {
142 session
= ILttngSession
.createSession(null, SESSION_DOMAIN
);
143 clientListener
.clearAllCommands();
150 public void teardown() {
155 private static ILogLevelStrings
getLogLevelStrings() {
156 return ILogLevelStrings
.JUL_LOGLEVEL_STRINGS
;
160 * Check that two lists contain the exact same element (including
161 * duplicates), but their order does not matter.
163 private static <T
extends Comparable
<T
>> boolean containSameElements(List
<T
> list1
, List
<T
> list2
) {
164 List
<T
> newlist1
= new ArrayList
<>(list1
);
165 List
<T
> newlist2
= new ArrayList
<>(list2
);
166 Collections
.sort(newlist1
);
167 Collections
.sort(newlist2
);
168 return (newlist1
.equals(newlist2
));
172 // ------------------------------------------------------------------------
173 // Event enabling/disabling test cases
174 // ------------------------------------------------------------------------
177 * Test enabling one event.
180 public void testEnableEvent() {
181 session
.enableEvent(EVENT_NAME_A
, null, false, null);
183 List
<EventRule
> expectedCommands
= Collections
.singletonList(
184 eventRuleFactory
.createRule(EVENT_NAME_A
));
186 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
187 assertEquals(expectedCommands
, actualCommands
);
191 * Test an "enable-event -a" command.
194 public void testEnableAllEvents() {
195 session
.enableAllEvents();
197 List
<EventRule
> expectedCommands
= Collections
.singletonList(
198 eventRuleFactory
.createRuleAllEvents());
199 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
201 assertEquals(expectedCommands
, actualCommands
);
205 * Test enabling then disabling one event.
208 public void testEnableThenDisableOneEvent() {
209 session
.enableEvent(EVENT_NAME_A
, null, false, null);
210 session
.disableEvents(EVENT_NAME_A
);
212 List
<EventRule
> expectedEnableCommands
= Collections
.singletonList(
213 eventRuleFactory
.createRule(EVENT_NAME_A
));
214 List
<String
> expectedDisableCommands
= Collections
.singletonList(EVENT_NAME_A
);
216 assertEquals(expectedEnableCommands
, clientListener
.getEnabledEventCommands());
217 assertTrue(containSameElements(expectedDisableCommands
, clientListener
.getDisabledEventCommands()));
221 * Test enabling some events manually, then disabling all events (-a).
224 public void testEnableSomeThenDisableAll() {
225 session
.enableEvent(EVENT_NAME_A
, null, false, null);
226 session
.enableEvent(EVENT_NAME_B
, null, false, null);
227 session
.enableEvent(EVENT_NAME_C
, null, false, null);
228 session
.disableAllEvents();
230 List
<EventRule
> expectedEnableCommands
= Arrays
.asList(
231 eventRuleFactory
.createRule(EVENT_NAME_A
),
232 eventRuleFactory
.createRule(EVENT_NAME_B
),
233 eventRuleFactory
.createRule(EVENT_NAME_C
));
235 * A "disable-event -a" will send one command for each enabled event.
236 * The order may be different though.
238 List
<String
> expectedDisableCommands
= Arrays
.asList(
239 EVENT_NAME_A
, EVENT_NAME_B
, EVENT_NAME_C
);
241 assertEquals(expectedEnableCommands
, clientListener
.getEnabledEventCommands());
242 assertTrue(containSameElements(expectedDisableCommands
, clientListener
.getDisabledEventCommands()));
246 * Test enabling then (enable-event -a) then disabling all (disable-event -a) events.
249 public void testEnableAllThenDisableAll() {
250 session
.enableAllEvents();
251 session
.disableAllEvents();
253 List
<EventRule
> expectedEnableCommands
= Arrays
.asList(eventRuleFactory
.createRuleAllEvents());
254 List
<String
> expectedDisableCommands
= Arrays
.asList(EventRuleFactory
.EVENT_NAME_ALL
);
256 assertEquals(expectedEnableCommands
, clientListener
.getEnabledEventCommands());
257 assertTrue(containSameElements(expectedDisableCommands
, clientListener
.getDisabledEventCommands()));
261 * Test enabling then destroying the session (should send corresponding
262 * disable event messages).
264 @SuppressWarnings("static-method")
266 public void testEnableEventThenDestroy() {
267 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
268 session2
.enableEvent(EVENT_NAME_A
, null, false, null);
269 session2
.enableEvent(EVENT_NAME_B
, null, false, null);
270 } // close(), aka destroy the session, sending "disable event" messages
272 List
<EventRule
> expectedEnabledCommands
= Arrays
.asList(eventRuleFactory
.createRule(EVENT_NAME_A
), eventRuleFactory
.createRule(EVENT_NAME_B
));
273 List
<String
> expectedDisabledCommands
= Arrays
.asList(EVENT_NAME_A
, EVENT_NAME_B
);
275 assertEquals(expectedEnabledCommands
, clientListener
.getEnabledEventCommands());
276 assertTrue(clientListener
.getDisabledEventCommands().containsAll(expectedDisabledCommands
));
280 * Test specifying an event with a --loglevel option.
283 public void testEnableEventLogLevelRange() {
284 LogLevelSelector lls
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_RANGE
);
286 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, null);
288 List
<EventRule
> expectedCommands
= Collections
.singletonList(
289 eventRuleFactory
.createRule(EVENT_NAME_A
, lls
));
290 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
292 assertEquals(expectedCommands
, actualCommands
);
296 * Test enabling an event with a --loglevel-only option.
299 public void testEnableEventLogLevelSingle() {
300 LogLevelSelector lls
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_SINGLE
);
302 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), true, null);
304 List
<EventRule
> expectedCommands
= Collections
.singletonList(
305 eventRuleFactory
.createRule(EVENT_NAME_A
, lls
));
306 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
308 assertEquals(expectedCommands
, actualCommands
);
312 * Test enabling an event twice, for the same loglevel, with --loglevel followed by --loglevel-only.
315 public void testEnableEventsLogLevelRangeAndSingle() {
316 LogLevelSelector lls1
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_RANGE
);
317 LogLevelSelector lls2
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_SINGLE
);
319 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, null);
320 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), true, null);
322 List
<EventRule
> expectedCommands
= Arrays
.asList(
323 eventRuleFactory
.createRule(EVENT_NAME_A
, lls1
),
324 eventRuleFactory
.createRule(EVENT_NAME_A
, lls2
)
326 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
328 assertEquals(expectedCommands
, actualCommands
);
332 * Test enabling an event twice, for the same loglevel, with --loglevel-only followed by --loglevel.
335 public void testEnableEventsLogLevelSingleAndRange() {
336 LogLevelSelector lls1
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_SINGLE
);
337 LogLevelSelector lls2
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_RANGE
);
339 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), true, null);
340 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, null);
342 List
<EventRule
> expectedCommands
= Arrays
.asList(
343 eventRuleFactory
.createRule(EVENT_NAME_A
, lls1
),
344 eventRuleFactory
.createRule(EVENT_NAME_A
, lls2
)
346 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
348 assertEquals(expectedCommands
, actualCommands
);
352 * Test enabling the same event, same loglevel, but different loglevel types
353 * (--loglevel vs --loglevel-only) in two separate sessions.
356 public void testEnableEventsLogLevelRangeAndSingleDiffSessions() {
357 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
359 LogLevelSelector lls1
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_RANGE
);
360 LogLevelSelector lls2
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_SINGLE
);
362 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, null);
363 session2
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), true, null);
365 List
<EventRule
> expectedCommands
= Arrays
.asList(
366 eventRuleFactory
.createRule(EVENT_NAME_A
, lls1
),
367 eventRuleFactory
.createRule(EVENT_NAME_A
, lls2
));
368 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
370 assertEquals(expectedCommands
, actualCommands
);
375 * Enable the same event multiple times with different filter strings.
378 public void testEnableEventsDiffFilters() {
379 final String filter1
= "filter1";
380 final String filter2
= "filter2";
382 session
.enableEvent(EVENT_NAME_A
, null, false, null);
383 session
.enableEvent(EVENT_NAME_A
, null, false, filter1
);
384 session
.enableEvent(EVENT_NAME_A
, null, false, filter2
);
386 List
<EventRule
> expectedCommands
= Arrays
.asList(
387 eventRuleFactory
.createRule(EVENT_NAME_A
),
388 eventRuleFactory
.createRule(EVENT_NAME_A
, eventRuleFactory
.LOG_LEVEL_UNSPECIFIED
, filter1
),
389 eventRuleFactory
.createRule(EVENT_NAME_A
, eventRuleFactory
.LOG_LEVEL_UNSPECIFIED
, filter2
));
390 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
392 assertEquals(expectedCommands
, actualCommands
);
396 * Enable the same event multiple times with different log levels and
400 public void testEnableEventsLogLevelAndFilters() {
401 final LogLevelSelector lls
= new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType
.LTTNG_EVENT_LOGLEVEL_RANGE
);
402 final String filter
= "filter1";
404 session
.enableEvent(EVENT_NAME_A
, null, false, null);
405 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, null);
406 session
.enableEvent(EVENT_NAME_A
, null, false, filter
);
407 session
.enableEvent(EVENT_NAME_A
, getLogLevelStrings().warningName(), false, filter
);
409 List
<EventRule
> expectedCommands
= Arrays
.asList(
410 eventRuleFactory
.createRule(EVENT_NAME_A
),
411 eventRuleFactory
.createRule(EVENT_NAME_A
, lls
),
412 eventRuleFactory
.createRule(EVENT_NAME_A
, eventRuleFactory
.LOG_LEVEL_UNSPECIFIED
, filter
),
413 eventRuleFactory
.createRule(EVENT_NAME_A
, lls
, filter
));
414 List
<EventRule
> actualCommands
= clientListener
.getEnabledEventCommands();
416 assertEquals(expectedCommands
, actualCommands
);
419 // ------------------------------------------------------------------------
420 // Application context enabling/disabling test cases
421 // ------------------------------------------------------------------------
424 * Test enabling one application context.
427 public void testEnableAppContext() {
428 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
430 List
<String
> expectedCommands
= Collections
.singletonList(
431 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
433 List
<String
> actualCommands
= clientListener
.getEnabledAppContextCommands();
434 assertEquals(expectedCommands
, actualCommands
);
438 * Test enabling two application contexts sharing the same retriever name.
441 public void testEnableAppContextsSameRetriever() {
442 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
443 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_B
);
445 List
<String
> expectedCommands
= Arrays
.asList(
446 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
,
447 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_B
);
449 List
<String
> actualCommands
= clientListener
.getEnabledAppContextCommands();
450 assertEquals(expectedCommands
, actualCommands
);
454 * Test enabling two application contexts sharing the same context name, but
455 * with different retrievers. Unusual, but they should still be recognized
459 public void testEnableAppContextsSameContext() {
460 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
461 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_B
, CONTEXT_NAME_A
);
463 List
<String
> expectedCommands
= Arrays
.asList(
464 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
,
465 CONTEXT_RETRIEVER_NAME_B
+ ':' + CONTEXT_NAME_A
);
467 List
<String
> actualCommands
= clientListener
.getEnabledAppContextCommands();
468 assertEquals(expectedCommands
, actualCommands
);
472 * Test enabling one application context, then destroying the session. We
473 * should receive the corresponding "context removed" message.
476 @SuppressWarnings("static-method")
477 public void testEnableAppContextThenDestroy() {
478 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
479 session2
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
480 } // close(), aka destroy the session, sending "disable context" messages
482 List
<String
> expectedEnabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
483 List
<String
> expectedDisabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
484 List
<String
> actualEnabledCommands
= clientListener
.getEnabledAppContextCommands();
485 List
<String
> actualDisabledCommands
= clientListener
.getDisabledAppContextCommands();
487 assertEquals(expectedEnabledCommands
, actualEnabledCommands
);
488 assertEquals(expectedDisabledCommands
, actualDisabledCommands
);
492 * Test enabling the same application context in two different sessions.
493 * Upon destroying one, we should only receive one "destroyed" message.
496 public void testEnableSameAppContextTwoSessions() {
497 List
<String
> expectedEnabledCommands
= Arrays
.asList(
498 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
,
499 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
500 List
<String
> actualEnabledCommands
;
502 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
503 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
504 session2
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
506 actualEnabledCommands
= clientListener
.getEnabledAppContextCommands();
507 assertEquals(expectedEnabledCommands
, actualEnabledCommands
);
508 } // close/destroy session2
510 actualEnabledCommands
= clientListener
.getEnabledAppContextCommands();
511 assertEquals(expectedEnabledCommands
, actualEnabledCommands
);
513 List
<String
> expectedDisabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
514 List
<String
> actualDisabledCommands
= clientListener
.getDisabledAppContextCommands();
516 assertEquals(expectedDisabledCommands
, actualDisabledCommands
);
520 * Test enabling two different application context in two different
521 * sessions. Upon destroying one, we should receive the correct "destroyed"
525 public void testEnableDiffAppContextTwoSessions() {
526 List
<String
> expectedEnabledCommands
= Arrays
.asList(
527 CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
,
528 CONTEXT_RETRIEVER_NAME_B
+ ':' + CONTEXT_NAME_B
);
529 List
<String
> actualEnabledCommands
;
531 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
532 session
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
533 session2
.enableAppContext(CONTEXT_RETRIEVER_NAME_B
, CONTEXT_NAME_B
);
535 actualEnabledCommands
= clientListener
.getEnabledAppContextCommands();
536 assertEquals(expectedEnabledCommands
, actualEnabledCommands
);
537 } // close/destroy session2
539 actualEnabledCommands
= clientListener
.getEnabledAppContextCommands();
540 assertEquals(expectedEnabledCommands
, actualEnabledCommands
);
542 List
<String
> expectedDisabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_B
+ ':' + CONTEXT_NAME_B
);
543 List
<String
> actualDisabledCommands
= clientListener
.getDisabledAppContextCommands();
545 assertEquals(expectedDisabledCommands
, actualDisabledCommands
);
548 // ------------------------------------------------------------------------
549 // Application context filtering
550 // ------------------------------------------------------------------------
553 * Test that enabling an event with a filter string referring to a context
554 * should send an agent message about this context now being "enabled".
556 * This is because we will pass the context information to UST for the
557 * filtering step, even if the actual context won't be present in the trace.
559 @SuppressWarnings("static-method")
561 public void testContextInFilterString() {
562 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
563 session2
.enableEvent(EVENT_NAME_A
, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
+ "==\"bozo\"");
565 List
<String
> expectedEnabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
566 assertEquals(expectedEnabledCommands
, clientListener
.getEnabledAppContextCommands());
567 } // close(), aka destroy the session, sending "disable context" messages
569 List
<String
> expectedDisabledCommands
= Collections
.singletonList(CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
570 assertEquals(expectedDisabledCommands
, clientListener
.getDisabledAppContextCommands());
574 * Test that if we the context is both referred to by a filter string *and*
575 * enabled directly, we receive *2* messages about this context being
576 * enabled (and disabled on session teardown).
578 @SuppressWarnings("static-method")
580 public void testContextEnabledAndInFilterString() {
581 try (ILttngSession session2
= ILttngSession
.createSession(null, SESSION_DOMAIN
);) {
582 session2
.enableEvent(EVENT_NAME_A
, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
+ "==\"bozo\"");
583 session2
.enableAppContext(CONTEXT_RETRIEVER_NAME_A
, CONTEXT_NAME_A
);
585 List
<String
> expectedEnabledCommands
= Collections
.nCopies(2, CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
586 assertEquals(expectedEnabledCommands
, clientListener
.getEnabledAppContextCommands());
587 } // close(), aka destroy the session, sending "disable context" messages
589 List
<String
> expectedDisabledCommands
= Collections
.nCopies(2, CONTEXT_RETRIEVER_NAME_A
+ ':' + CONTEXT_NAME_A
);
590 assertEquals(expectedDisabledCommands
, clientListener
.getDisabledAppContextCommands());