Fix sentinel test not to be so sensitive to time
This commit is contained in:
1
Makefile
1
Makefile
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -83,7 +81,7 @@ public class JedisClusterTest extends Assert {
|
|||||||
node3.clusterDelSlots(slotsToDelete);
|
node3.clusterDelSlots(slotsToDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=JedisMovedDataException.class)
|
@Test(expected = JedisMovedDataException.class)
|
||||||
public void testThrowMovedException() {
|
public void testThrowMovedException() {
|
||||||
node1.set("foo", "bar");
|
node1.set("foo", "bar");
|
||||||
}
|
}
|
||||||
@@ -94,12 +92,14 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=JedisAskDataException.class)
|
@Test(expected = JedisAskDataException.class)
|
||||||
public void testThrowAskException() {
|
public void testThrowAskException() {
|
||||||
int keySlot = JedisClusterCRC16.getSlot("test");
|
int keySlot = JedisClusterCRC16.getSlot("test");
|
||||||
String node3Id = getNodeId(node3.clusterNodes());
|
String node3Id = getNodeId(node3.clusterNodes());
|
||||||
@@ -122,8 +122,8 @@ public class JedisClusterTest extends Assert {
|
|||||||
JedisCluster jc = new JedisCluster(jedisClusterNode);
|
JedisCluster jc = new JedisCluster(jedisClusterNode);
|
||||||
jc.set("foo", "bar");
|
jc.set("foo", "bar");
|
||||||
jc.set("test", "test");
|
jc.set("test", "test");
|
||||||
assertEquals("bar",node3.get("foo"));
|
assertEquals("bar", node3.get("foo"));
|
||||||
assertEquals("test",node2.get("test"));
|
assertEquals("test", node2.get("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -153,7 +153,7 @@ public class JedisClusterTest extends Assert {
|
|||||||
assertEquals("foo", jc.get("51"));
|
assertEquals("foo", jc.get("51"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=JedisClusterException.class)
|
@Test(expected = JedisClusterException.class)
|
||||||
public void testThrowExceptionWithoutKey() {
|
public void testThrowExceptionWithoutKey() {
|
||||||
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
|
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
|
||||||
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
|
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
|
||||||
@@ -161,13 +161,13 @@ public class JedisClusterTest extends Assert {
|
|||||||
jc.ping();
|
jc.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=JedisClusterMaxRedirectionsException.class)
|
@Test(expected = JedisClusterMaxRedirectionsException.class)
|
||||||
public void testRedisClusterMaxRedirections() {
|
public void testRedisClusterMaxRedirections() {
|
||||||
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
|
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
|
||||||
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
|
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
|
||||||
JedisCluster jc = new JedisCluster(jedisClusterNode);
|
JedisCluster jc = new JedisCluster(jedisClusterNode);
|
||||||
int slot51 = JedisClusterCRC16.getSlot("51");
|
int slot51 = JedisClusterCRC16.getSlot("51");
|
||||||
//This will cause an infinite redirection loop
|
// This will cause an infinite redirection loop
|
||||||
node2.clusterSetSlotMigrating(slot51, getNodeId(node3.clusterNodes()));
|
node2.clusterSetSlotMigrating(slot51, getNodeId(node3.clusterNodes()));
|
||||||
jc.set("51", "foo");
|
jc.set("51", "foo");
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user