SAMZA-1761: Reduce runTime of TestZkUtils test from 40s to 800ms.
authorShanthoosh Venkataraman <santhoshvenkat1988@gmail.com>
Mon, 9 Jul 2018 19:29:14 +0000 (12:29 -0700)
committerJagadish <jvenkatraman@linkedin.com>
Mon, 9 Jul 2018 19:29:14 +0000 (12:29 -0700)
Author: Shanthoosh Venkataraman <santhoshvenkat1988@gmail.com>

Reviewers: Prateek <pmaheshw@linkedin.com>

Closes #565 from shanthoosh/SAMZA-1761

samza-core/src/main/java/org/apache/samza/zk/ZkUtils.java
samza-core/src/test/java/org/apache/samza/zk/TestZkUtils.java

index 4d325c5..6349432 100644 (file)
@@ -147,7 +147,7 @@ public class ZkUtils {
           long currentTimeMs = System.currentTimeMillis();
           if ((currentTimeMs - startTimeMs) < retryTimeOutMs) {
             LOG.info("Processor: {} is duplicate. Retrying registration again.", processorId);
-            timeDelay(5000);
+            timeDelay(1000);
           } else {
             LOG.info("Processor: {} is duplicate. Deleting zookeeper node at path: {}.", processorId, ephemeralPath);
             zkClient.delete(ephemeralPath);
index 19a05a6..d0008b1 100644 (file)
@@ -56,8 +56,8 @@ public class TestZkUtils {
   private static EmbeddedZookeeper zkServer = null;
   private static final ZkKeyBuilder KEY_BUILDER = new ZkKeyBuilder("test");
   private ZkClient zkClient = null;
-  private static final int SESSION_TIMEOUT_MS = 20000;
-  private static final int CONNECTION_TIMEOUT_MS = 10000;
+  private static final int SESSION_TIMEOUT_MS = 500;
+  private static final int CONNECTION_TIMEOUT_MS = 1000;
   private ZkUtils zkUtils;
 
   @Rule
@@ -148,12 +148,12 @@ public class TestZkUtils {
     zkUtils.validateZkVersion();
 
     String root = zkUtils.getKeyBuilder().getRootPath();
-    String ver = (String) zkUtils.getZkClient().readData(root);
+    String ver = zkUtils.getZkClient().readData(root);
     Assert.assertEquals(ZkUtils.ZK_PROTOCOL_VERSION, ver);
 
     // do it again (in case original value was null
     zkUtils.validateZkVersion();
-    ver = (String) zkUtils.getZkClient().readData(root);
+    ver = zkUtils.getZkClient().readData(root);
     Assert.assertEquals(ZkUtils.ZK_PROTOCOL_VERSION, ver);
 
     // now negative case