speed up JedisSentinelTest
This commit is contained in:
1
Makefile
1
Makefile
@@ -60,6 +60,7 @@ pidfile /tmp/redis6.pid
|
||||
logfile /tmp/redis6.log
|
||||
save ""
|
||||
appendonly no
|
||||
slaveof localhost 6379
|
||||
endef
|
||||
|
||||
define REDIS_SENTINEL1
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package redis.clients.jedis.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -10,15 +9,14 @@ import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.tests.utils.JedisSentinelTestUtil;
|
||||
|
||||
public class JedisSentinelTest extends JedisTestBase {
|
||||
private static final String MASTER_NAME = "mymaster";
|
||||
|
||||
protected static HostAndPort master = HostAndPortUtil.getRedisServers()
|
||||
.get(0);
|
||||
protected static HostAndPort slave = HostAndPortUtil.getRedisServers()
|
||||
.get(5);
|
||||
protected static HostAndPort slave = HostAndPortUtil.getRedisServers().get(
|
||||
5);
|
||||
protected static HostAndPort sentinel = HostAndPortUtil
|
||||
.getSentinelServers().get(0);
|
||||
|
||||
@@ -28,25 +26,16 @@ public class JedisSentinelTest extends JedisTestBase {
|
||||
|
||||
@Before
|
||||
public void setup() throws InterruptedException {
|
||||
masterJedis = new Jedis(master.getHost(), master.getPort());
|
||||
|
||||
slaveJedis = new Jedis(slave.getHost(), slave.getPort());
|
||||
slaveJedis.auth("foobared");
|
||||
slaveJedis.configSet("masterauth", "foobared");
|
||||
slaveJedis.slaveof(master.getHost(), master.getPort());
|
||||
|
||||
List<HostAndPort> slaves = new ArrayList<HostAndPort>();
|
||||
slaves.add(slave);
|
||||
|
||||
JedisSentinelTestUtil.waitForSentinelRecognizeRedisReplication(
|
||||
sentinel, MASTER_NAME, master, slaves);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clear() throws InterruptedException {
|
||||
// New Sentinel (after 2.8.1)
|
||||
// when slave promoted to master (slave of no one), New Sentinel force to restore it (demote)
|
||||
// so, promote(slaveof) slave to master has no effect, not same to old Sentinel's behavior
|
||||
// New Sentinel (after 2.8.1)
|
||||
// when slave promoted to master (slave of no one), New Sentinel force
|
||||
// to restore it (demote)
|
||||
// so, promote(slaveof) slave to master has no effect, not same to old
|
||||
// Sentinel's behavior
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,13 +48,15 @@ public class JedisSentinelTest extends JedisTestBase {
|
||||
|
||||
List<String> masterHostAndPort = j
|
||||
.sentinelGetMasterAddrByName(masterName);
|
||||
HostAndPort masterFromSentinel = new HostAndPort(masterHostAndPort.get(0),
|
||||
Integer.parseInt(masterHostAndPort.get(1)));
|
||||
HostAndPort masterFromSentinel = new HostAndPort(
|
||||
masterHostAndPort.get(0), Integer.parseInt(masterHostAndPort
|
||||
.get(1)));
|
||||
assertEquals(master, masterFromSentinel);
|
||||
|
||||
List<Map<String, String>> slaves = j.sentinelSlaves(masterName);
|
||||
assertTrue(slaves.size() > 0);
|
||||
assertEquals(master.getPort(), Integer.parseInt(slaves.get(0).get("master-port")));
|
||||
assertEquals(master.getPort(),
|
||||
Integer.parseInt(slaves.get(0).get("master-port")));
|
||||
|
||||
// DO NOT RE-RUN TEST TOO FAST, RESET TAKES SOME TIME TO... RESET
|
||||
assertEquals(Long.valueOf(1), j.sentinelReset(masterName));
|
||||
|
||||
@@ -423,7 +423,6 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
jedis.lpush("foo", "bar");
|
||||
result = jedis.blpop(1, "foo");
|
||||
System.out.println("lalalala");
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.size());
|
||||
@@ -433,7 +432,6 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
// Binary
|
||||
jedis.lpush(bfoo, bbar);
|
||||
List<byte[]> bresult = jedis.blpop(1, bfoo);
|
||||
System.out.println("lalalala");
|
||||
|
||||
assertNotNull(bresult);
|
||||
assertEquals(2, bresult.size());
|
||||
|
||||
Reference in New Issue
Block a user