Skip to content
Permalink
Browse files
For CURATOR-559 make the test a bit more robust. Wait for the connect…
…ion to go to LOST after server stop
  • Loading branch information
randgalt committed Apr 9, 2020
1 parent b29bb01 commit fd3728d56366bcc9c4b3444182a8b6e7a38633a6
Showing 1 changed file with 9 additions and 0 deletions.
@@ -23,11 +23,13 @@
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 @@ private void prep(CuratorFramework client) throws Exception
{
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

0 comments on commit fd3728d

Please sign in to comment.