Fix latest tests
[lttng-ust-java-tests.git] / lttng-ust-java-tests-common / src / test / java / org / lttng / ust / agent / integration / client / TcpClientIT.java
index a86a273cc3f969d07cba3f0e6830aa1e2b9b5f18..ab27da6dd40c8b108c04a61403be6d762fa4e760 100644 (file)
@@ -255,7 +255,7 @@ public class TcpClientIT {
         List<String> expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
 
         assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands());
-        assertEquals(expectedDisabledCommands, clientListener.getDisabledEventCommands());
+        assertTrue(clientListener.getDisabledEventCommands().containsAll(expectedDisabledCommands));
     }
 
     /**
@@ -526,4 +526,49 @@ public class TcpClientIT {
 
         assertEquals(expectedDisabledCommands, actualDisabledCommands);
     }
+
+    // ------------------------------------------------------------------------
+    // Application context filtering
+    // ------------------------------------------------------------------------
+
+    /**
+     * Test that enabling an event with a filter string referring to a context
+     * should send an agent message about this context now being "enabled".
+     *
+     * This is because we will pass the context information to UST for the
+     * filtering step, even if the actual context won't be present in the trace.
+     */
+    @SuppressWarnings("static-method")
+    @Test
+    public void testContextInFilterString() {
+        try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
+            session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
+
+            List<String> expectedEnabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
+            assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
+        } // close(), aka destroy the session, sending "disable context" messages
+
+        List<String> expectedDisabledCommands = Collections.singletonList(CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
+        assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
+    }
+
+    /**
+     * Test that if we the context is both referred to by a filter string *and*
+     * enabled directly, we receive *2* messages about this context being
+     * enabled (and disabled on session teardown).
+     */
+    @SuppressWarnings("static-method")
+    @Test
+    public void testContextEnabledAndInFilterString() {
+        try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) {
+            session2.enableEvent(EVENT_NAME_A, null, false, "$app." + CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A + "==\"bozo\"");
+            session2.enableAppContext(CONTEXT_RETRIEVER_NAME_A, CONTEXT_NAME_A);
+
+            List<String> expectedEnabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
+            assertEquals(expectedEnabledCommands, clientListener.getEnabledAppContextCommands());
+        } // close(), aka destroy the session, sending "disable context" messages
+
+        List<String> expectedDisabledCommands = Collections.nCopies(2, CONTEXT_RETRIEVER_NAME_A + ':' + CONTEXT_NAME_A);
+        assertEquals(expectedDisabledCommands, clientListener.getDisabledAppContextCommands());
+    }
 }
This page took 0.023368 seconds and 4 git commands to generate.