You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2020/04/09 15:16:11 UTC

[curator] branch master updated: For CURATOR-559 make the test a bit more robust. Wait for the connection to go to LOST after server stop

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

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


The following commit(s) were added to refs/heads/master by this push:
     new fd3728d  For CURATOR-559 make the test a bit more robust. Wait for the connection to go to LOST after server stop
fd3728d is described below

commit fd3728d56366bcc9c4b3444182a8b6e7a38633a6
Author: randgalt <ra...@apache.org>
AuthorDate: Thu Apr 9 10:16:05 2020 -0500

    For CURATOR-559 make the test a bit more robust. Wait for the connection to go to LOST after server stop
---
 .../org/apache/curator/connection/TestThreadLocalRetryLoop.java  | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java b/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
index 785c2c2..16b345a 100644
--- a/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
+++ b/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
@@ -23,11 +23,13 @@ import org.apache.curator.RetrySleeper;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock;
+import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.retry.RetryNTimes;
 import org.apache.curator.test.compatibility.CuratorTestBase;
 import org.apache.zookeeper.KeeperException;
 import org.testng.Assert;
 import org.testng.annotations.Test;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -85,7 +87,14 @@ public class TestThreadLocalRetryLoop extends CuratorTestBase
     {
         client.start();
         client.create().forPath("/test");
+        CountDownLatch lostLatch = new CountDownLatch(1);
+        client.getConnectionStateListenable().addListener((__, newState) -> {
+            if (newState == ConnectionState.LOST) {
+                lostLatch.countDown();
+            }
+        });
         server.stop();
+        Assert.assertTrue(timing.awaitLatch(lostLatch));
     }
 
     private Void doLock(CuratorFramework client) throws Exception