Speed up Sentinel related tests

* remove FIXME sleep codes for Sentinel related tests
** add functions for Sentinel tests (JedisSentinelTestUtil)
*** waitForSentinelRecognizeRedisReplication
*** waitForNewPromotedMaster
*** waitForSentinelsRecognizeEachOthers
**** TODO: there're no command for sentinel to list recognized sentinel
**** sleep 5.5 sec (sentinel pings to master every 5 sec)

* set HostAndPort class to public(no longer inner) class
** reason: We cannot know pool's current master if HostAndPort class is
private inner class / HostAndPort classes are duplicated (main/test)
** make getter method and parameterized constructor
*** set fields once, get anytime
This commit is contained in:
Jungtaek Lim
2013-10-07 11:03:32 +09:00
parent 597366343d
commit 7e1a1a70b2
19 changed files with 431 additions and 259 deletions

View File

@@ -3,8 +3,8 @@ package redis.clients.jedis.tests.commands;
import org.junit.Test;
import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.tests.HostAndPortUtil;
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
protected static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
@@ -16,7 +16,7 @@ public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
@Test
public void binary_quit() {
BinaryJedis bj = new BinaryJedis(hnp.host);
BinaryJedis bj = new BinaryJedis(hnp.getHost());
assertEquals("OK", bj.quit());
}
}

View File

@@ -1,18 +1,19 @@
package redis.clients.jedis.tests.commands;
import org.junit.After;
import org.junit.Before;
import org.junit.ComparisonFailure;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.tests.HostAndPortUtil;
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
import redis.clients.jedis.tests.JedisTestBase;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.ComparisonFailure;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.tests.HostAndPortUtil;
import redis.clients.jedis.tests.JedisTestBase;
public abstract class JedisCommandTestBase extends JedisTestBase {
protected static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
@@ -24,7 +25,7 @@ public abstract class JedisCommandTestBase extends JedisTestBase {
@Before
public void setUp() throws Exception {
jedis = new Jedis(hnp.host, hnp.port, 500);
jedis = new Jedis(hnp.getHost(), hnp.getPort(), 500);
jedis.connect();
jedis.auth("foobared");
jedis.configSet("timeout", "300");
@@ -37,7 +38,7 @@ public abstract class JedisCommandTestBase extends JedisTestBase {
}
protected Jedis createJedis() {
Jedis j = new Jedis(hnp.host, hnp.port);
Jedis j = new Jedis(hnp.getHost(), hnp.getPort());
j.connect();
j.auth("foobared");
j.flushAll();

View File

@@ -475,7 +475,7 @@ public class PublishSubscribeCommandsTest extends JedisCommandTestBase {
@Test @Ignore
public void subscribeWithoutConnecting() {
try {
Jedis jedis = new Jedis(hnp.host, hnp.port);
Jedis jedis = new Jedis(hnp.getHost(), hnp.getPort());
jedis.subscribe(new JedisPubSub() {
public void onMessage(String channel, String message) {
}

View File

@@ -32,7 +32,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
public void setUp() throws Exception {
super.setUp();
nj = new Jedis(hnp.host, hnp.port, 500);
nj = new Jedis(hnp.getHost(), hnp.getPort(), 500);
nj.connect();
nj.auth("foobared");
nj.flushAll();