Allow the TcpClientIT test to work with any sessiond
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 18 Feb 2016 22:36:13 +0000 (17:36 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 18 Feb 2016 23:45:14 +0000 (18:45 -0500)
Instead of hard-coding for a root sessiond, we can try root
then fall-back on a user sessiond for these tests.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java

index 69ef96f61f793bbb9a1ac48d597be01717e32566..8f3750ba782dda78de9284b39febc879531cd907 100644 (file)
@@ -20,6 +20,7 @@ package org.lttng.ust.agent.integration.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -71,7 +72,6 @@ public class TcpClientIT {
     /* Test configuration */
     private static final int DOMAIN_VALUE = ILttngAgent.Domain.JUL.value();
     private static final ILttngSession.Domain SESSION_DOMAIN = ILttngSession.Domain.JUL;
-    private static final boolean ROOT_SESSIOND = true;
 
     private static TcpClientDebugListener clientListener;
     private static LttngTcpSessiondClient client;
@@ -91,12 +91,29 @@ public class TcpClientIT {
         LttngToolsHelper.destroyAllSessions();
 
         clientListener = new TcpClientDebugListener();
-        client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, ROOT_SESSIOND);
 
+        /* Try connecting to a root sessiond first */
+        client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, true);
         clientThread = new Thread(client);
         clientThread.start();
 
-        assertTrue("Timed out waiting for root sessiond", client.waitForConnection(5));
+        if (client.waitForConnection(5)) {
+            return;
+        }
+
+        /* Connection was not established, try a user sessiond instead */
+        client.close();
+        try {
+            clientThread.join();
+        } catch (InterruptedException e) {
+            fail(e.getMessage());
+        }
+
+        client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, false);
+        clientThread = new Thread(client);
+        clientThread.start();
+
+        assertTrue("Timed out waiting for a sessiond", client.waitForConnection(5));
     }
 
     /**
This page took 0.024752 seconds and 4 git commands to generate.