Fix sentinel test not to be so sensitive to time

This commit is contained in:
Jonathan Leibiusky
2014-01-16 20:37:47 -05:00
parent 424ae75c7d
commit 23b54c2cef
3 changed files with 136 additions and 134 deletions

View File

@@ -188,6 +188,7 @@ stop:
test: test:
make start make start
sleep 2
mvn -Dtest=${TEST} clean compile test mvn -Dtest=${TEST} clean compile test
make stop make stop

View File

@@ -66,11 +66,9 @@ public class JedisClusterTest extends Assert {
pipeline2.sync(); pipeline2.sync();
pipeline3.sync(); pipeline3.sync();
waitForClusterReady(); waitForClusterReady();
} }
@After @After
public void tearDown() { public void tearDown() {
// clear all slots // clear all slots
@@ -94,7 +92,9 @@ public class JedisClusterTest extends Assert {
node1.set("foo", "bar"); node1.set("foo", "bar");
} catch (JedisMovedDataException jme) { } catch (JedisMovedDataException jme) {
assertEquals(12182, jme.getSlot()); assertEquals(12182, jme.getSlot());
assertEquals(new HostAndPort("127.0.0.1", 7381), jme.getTargetNode()); assertEquals(new HostAndPort("127.0.0.1", 7381),
jme.getTargetNode());
return;
} }
fail(); fail();
} }
@@ -184,9 +184,9 @@ public class JedisClusterTest extends Assert {
private void waitForClusterReady() throws InterruptedException { private void waitForClusterReady() throws InterruptedException {
boolean clusterOk = false; boolean clusterOk = false;
while (!clusterOk) { while (!clusterOk) {
if (node1.clusterInfo().split("\n")[0].contains("ok") && if (node1.clusterInfo().split("\n")[0].contains("ok")
node2.clusterInfo().split("\n")[0].contains("ok") && && node2.clusterInfo().split("\n")[0].contains("ok")
node3.clusterInfo().split("\n")[0].contains("ok") ) { && node3.clusterInfo().split("\n")[0].contains("ok")) {
clusterOk = true; clusterOk = true;
} }
Thread.sleep(50); Thread.sleep(50);

View File

@@ -69,6 +69,7 @@ public class JedisSentinelPoolTest extends JedisTestBase {
} }
waitForFailover(pool, oldMaster); waitForFailover(pool, oldMaster);
Thread.sleep(100);
jedis = pool.getResource(); jedis = pool.getResource();
assertEquals("PONG", jedis.ping()); assertEquals("PONG", jedis.ping());