|
|
|
@ -128,7 +128,7 @@ public class RedissonTest {
|
|
|
|
|
RedisProcess p = redisTestSmallMemory();
|
|
|
|
|
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useSingleServer().setAddress("127.0.0.1:6319").setTimeout(100000);
|
|
|
|
|
config.useSingleServer().setAddress(p.getRedisServerAddressAndPort()).setTimeout(100000);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
RedissonClient r = Redisson.create(config);
|
|
|
|
@ -146,7 +146,7 @@ public class RedissonTest {
|
|
|
|
|
RedisProcess p = redisTestSmallMemory();
|
|
|
|
|
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useSingleServer().setAddress("127.0.0.1:6319").setTimeout(100000);
|
|
|
|
|
config.useSingleServer().setAddress(p.getRedisServerAddressAndPort()).setTimeout(100000);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
RedissonClient r = Redisson.create(config);
|
|
|
|
@ -171,13 +171,13 @@ public class RedissonTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void testConnectionListener() throws IOException, InterruptedException, TimeoutException {
|
|
|
|
|
|
|
|
|
|
RedisProcess p = redisTestConnection();
|
|
|
|
|
final RedisProcess p = redisTestConnection();
|
|
|
|
|
|
|
|
|
|
final AtomicInteger connectCounter = new AtomicInteger();
|
|
|
|
|
final AtomicInteger disconnectCounter = new AtomicInteger();
|
|
|
|
|
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useSingleServer().setAddress("127.0.0.1:6319");
|
|
|
|
|
config.useSingleServer().setAddress(p.getRedisServerAddressAndPort());
|
|
|
|
|
|
|
|
|
|
RedissonClient r = Redisson.create(config);
|
|
|
|
|
|
|
|
|
@ -185,13 +185,13 @@ public class RedissonTest {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDisconnect(InetSocketAddress addr) {
|
|
|
|
|
assertThat(addr).isEqualTo(new InetSocketAddress("127.0.0.1", 6319));
|
|
|
|
|
assertThat(addr).isEqualTo(new InetSocketAddress(p.getRedisServerBindAddress(), p.getRedisServerPort()));
|
|
|
|
|
disconnectCounter.incrementAndGet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onConnect(InetSocketAddress addr) {
|
|
|
|
|
assertThat(addr).isEqualTo(new InetSocketAddress("127.0.0.1", 6319));
|
|
|
|
|
assertThat(addr).isEqualTo(new InetSocketAddress(p.getRedisServerBindAddress(), p.getRedisServerPort()));
|
|
|
|
|
connectCounter.incrementAndGet();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -206,13 +206,17 @@ public class RedissonTest {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p = redisTestConnection();
|
|
|
|
|
RedisProcess pp = new RedisRunner()
|
|
|
|
|
.nosave()
|
|
|
|
|
.port(p.getRedisServerPort())
|
|
|
|
|
.randomDir()
|
|
|
|
|
.run();
|
|
|
|
|
|
|
|
|
|
r.getBucket("1").get();
|
|
|
|
|
|
|
|
|
|
r.shutdown();
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(0, p.stop());
|
|
|
|
|
Assert.assertEquals(0, pp.stop());
|
|
|
|
|
|
|
|
|
|
await().atMost(1, TimeUnit.SECONDS).until(() -> assertThat(connectCounter.get()).isEqualTo(1));
|
|
|
|
|
await().until(() -> assertThat(disconnectCounter.get()).isEqualTo(1));
|
|
|
|
@ -300,7 +304,7 @@ public class RedissonTest {
|
|
|
|
|
@Test(expected = RedisConnectionException.class)
|
|
|
|
|
public void testSingleConnectionFail() throws InterruptedException {
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useSingleServer().setAddress("127.0.0.1:1111");
|
|
|
|
|
config.useSingleServer().setAddress("127.99.0.1:1111");
|
|
|
|
|
Redisson.create(config);
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1500);
|
|
|
|
@ -309,7 +313,7 @@ public class RedissonTest {
|
|
|
|
|
@Test(expected = RedisConnectionException.class)
|
|
|
|
|
public void testClusterConnectionFail() throws InterruptedException {
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useClusterServers().addNodeAddress("127.0.0.1:1111");
|
|
|
|
|
config.useClusterServers().addNodeAddress("127.99.0.1:1111");
|
|
|
|
|
Redisson.create(config);
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1500);
|
|
|
|
@ -318,7 +322,7 @@ public class RedissonTest {
|
|
|
|
|
@Test(expected = RedisConnectionException.class)
|
|
|
|
|
public void testElasticacheConnectionFail() throws InterruptedException {
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useElasticacheServers().addNodeAddress("127.0.0.1:1111");
|
|
|
|
|
config.useElasticacheServers().addNodeAddress("127.99.0.1:1111");
|
|
|
|
|
Redisson.create(config);
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1500);
|
|
|
|
@ -327,7 +331,7 @@ public class RedissonTest {
|
|
|
|
|
@Test(expected = RedisConnectionException.class)
|
|
|
|
|
public void testMasterSlaveConnectionFail() throws InterruptedException {
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useMasterSlaveServers().setMasterAddress("127.0.0.1:1111");
|
|
|
|
|
config.useMasterSlaveServers().setMasterAddress("127.99.0.1:1111");
|
|
|
|
|
Redisson.create(config);
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1500);
|
|
|
|
@ -336,7 +340,7 @@ public class RedissonTest {
|
|
|
|
|
@Test(expected = RedisConnectionException.class)
|
|
|
|
|
public void testSentinelConnectionFail() throws InterruptedException {
|
|
|
|
|
Config config = new Config();
|
|
|
|
|
config.useSentinelServers().addSentinelAddress("127.0.0.1:1111");
|
|
|
|
|
config.useSentinelServers().addSentinelAddress("127.99.0.1:1111");
|
|
|
|
|
Redisson.create(config);
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1500);
|
|
|
|
@ -344,7 +348,7 @@ public class RedissonTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testManyConnections() {
|
|
|
|
|
Assume.assumeFalse(Boolean.valueOf(System.getProperty("travisEnv")));
|
|
|
|
|
Assume.assumeFalse(RedissonRuntimeEnvironment.isTravis);
|
|
|
|
|
Config redisConfig = new Config();
|
|
|
|
|
redisConfig.useSingleServer()
|
|
|
|
|
.setConnectionMinimumIdleSize(10000)
|
|
|
|
@ -359,7 +363,7 @@ public class RedissonTest {
|
|
|
|
|
.maxmemory("1mb")
|
|
|
|
|
.nosave()
|
|
|
|
|
.randomDir()
|
|
|
|
|
.port(6319)
|
|
|
|
|
.randomPort()
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -367,7 +371,7 @@ public class RedissonTest {
|
|
|
|
|
return new RedisRunner()
|
|
|
|
|
.nosave()
|
|
|
|
|
.randomDir()
|
|
|
|
|
.port(6319)
|
|
|
|
|
.randomPort()
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|