You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by fj...@apache.org on 2020/04/08 17:07:20 UTC

[druid] branch master updated: fix flaky jetty test (#9633)

This is an automated email from the ASF dual-hosted git repository.

fjy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 7bf2dfa  fix flaky jetty test (#9633)
7bf2dfa is described below

commit 7bf2dfa3b1a1bb324cc6cb802964ddb13d188d2d
Author: Clint Wylie <cw...@apache.org>
AuthorDate: Wed Apr 8 10:07:06 2020 -0700

    fix flaky jetty test (#9633)
---
 .../java/org/apache/druid/server/initialization/JettyTest.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java b/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java
index 64ccd14..206c318 100644
--- a/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java
+++ b/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java
@@ -78,6 +78,7 @@ import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.zip.GZIPInputStream;
@@ -186,6 +187,8 @@ public class JettyTest extends BaseJettyTest
       throw new RuntimeException(e);
     }
 
+    final int ephemeralPort = ThreadLocalRandom.current().nextInt(49152, 65535);
+
     latchedRequestState = new LatchedRequestStateHolder();
     injector = Initialization.makeInjectorWithModules(
         GuiceInjectors.makeStartupInjector(),
@@ -198,7 +201,7 @@ public class JettyTest extends BaseJettyTest
                 JsonConfigProvider.bindInstance(
                     binder,
                     Key.get(DruidNode.class, Self.class),
-                    new DruidNode("test", "localhost", false, 9988, 9999, true, true)
+                    new DruidNode("test", "localhost", false, ephemeralPort, ephemeralPort + 1, true, true)
                 );
                 binder.bind(TLSServerConfig.class).toInstance(tlsConfig);
                 binder.bind(JettyServerInitializer.class).to(JettyServerInit.class).in(LazySingleton.class);
@@ -450,6 +453,7 @@ public class JettyTest extends BaseJettyTest
 
     JettyServerModule jsm = injector.getInstance(JettyServerModule.class);
     latchedRequestState.reset();
+    waitForJettyServerModuleActiveConnectionsZero(jsm);
 
     Assert.assertEquals(0, jsm.getActiveConnections());
     ListenableFuture<InputStream> go = client.go(
@@ -489,6 +493,7 @@ public class JettyTest extends BaseJettyTest
     JettyServerModule jsm = injector.getInstance(JettyServerModule.class);
     latchedRequestState.reset();
 
+    waitForJettyServerModuleActiveConnectionsZero(jsm);
     Assert.assertEquals(0, jsm.getActiveConnections());
     ListenableFuture<InputStream> go = client.go(
         request,
@@ -511,5 +516,8 @@ public class JettyTest extends BaseJettyTest
     while (jsm.getActiveConnections() > 0 && count++ < totalSleeps) {
       Thread.sleep(sleepTimeMills);
     }
+    if (jsm.getActiveConnections() > 0) {
+      throw new RuntimeException("Connections greater than 0");
+    }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org