diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java index 8744bd2093..0d081996c7 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java @@ -19,20 +19,20 @@ package org.apache.curator.framework.recipes.leader; import com.google.common.collect.Lists; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingCluster; -import org.apache.curator.test.Timing; +import org.apache.curator.test.compatibility.CuratorTestBase; +import org.apache.curator.test.compatibility.Timing2; +import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; import org.testng.annotations.Test; import java.util.Collection; import java.util.List; -public class TestLeaderLatchCluster +public class TestLeaderLatchCluster extends CuratorTestBase { private static final int MAX_LOOPS = 5; @@ -54,9 +54,9 @@ private ClientAndLatch(CuratorFramework client, LeaderLatch latch, int index) public void testInCluster() throws Exception { final int PARTICIPANT_QTY = 3; + final int sessionLength = timing.session() / 4; List clients = Lists.newArrayList(); - Timing timing = new Timing(); TestingCluster cluster = new TestingCluster(PARTICIPANT_QTY); try { @@ -65,7 +65,7 @@ public void testInCluster() throws Exception List instances = Lists.newArrayList(cluster.getInstances()); for ( int i = 0; i < PARTICIPANT_QTY; ++i ) { - CuratorFramework client = CuratorFrameworkFactory.newClient(instances.get(i).getConnectString(), timing.session(), timing.connection(), new ExponentialBackoffRetry(100, 3)); + CuratorFramework client = CuratorFrameworkFactory.newClient(instances.get(i).getConnectString(), sessionLength, sessionLength, new ExponentialBackoffRetry(100, 3)); LeaderLatch latch = new LeaderLatch(client, "/latch"); clients.add(new ClientAndLatch(client, latch, i)); @@ -78,7 +78,7 @@ public void testInCluster() throws Exception cluster.killServer(instances.get(leader.index)); - Thread.sleep(timing.multiple(2).session()); + Thread.sleep(sessionLength * 2); leader = waitForALeader(clients, timing); Assert.assertNotNull(leader); @@ -96,7 +96,13 @@ public void testInCluster() throws Exception } } - private ClientAndLatch waitForALeader(List latches, Timing timing) throws InterruptedException + @Override + protected void createServer() + { + // NOP + } + + private ClientAndLatch waitForALeader(List latches, Timing2 timing) throws InterruptedException { for ( int i = 0; i < MAX_LOOPS; ++i ) {