use of com.ctrip.xpipe.redis.core.server.FakeRedisServer in project x-pipe by ctripcorp.
the class FakeRedis method main.
public static void main(String[] args) throws Exception {
int port = Integer.parseInt(System.getProperty("port", "6379"));
FakeRedisServer fakeRedisServer = new FakeRedisServer(port);
fakeRedisServer.setSendHalfRdbAndCloseConnectionCount(1);
fakeRedisServer.initialize();
fakeRedisServer.start();
}
use of com.ctrip.xpipe.redis.core.server.FakeRedisServer in project x-pipe by ctripcorp.
the class DefaultPsyncTest method beforeDefaultPsyncTest.
@Before
public void beforeDefaultPsyncTest() throws Exception {
FakeRedisServer fakeRedisServer = startFakeRedisServer();
Endpoint masterEndPoint = new DefaultEndPoint("localhost", fakeRedisServer.getPort());
SimpleObjectPool<NettyClient> pool = NettyPoolUtil.createNettyPool(new InetSocketAddress("localhost", fakeRedisServer.getPort()));
when(replicationStoreManager.createIfNotExist()).thenReturn(replicationStore);
when(replicationStore.getMetaStore()).thenReturn(metaStore);
when(metaStore.getReplId()).thenReturn("?");
when(replicationStore.getEndOffset()).thenReturn(-1L);
defaultPsync = new DefaultPsync(pool, masterEndPoint, replicationStoreManager, scheduled);
}
use of com.ctrip.xpipe.redis.core.server.FakeRedisServer in project x-pipe by ctripcorp.
the class AbstractRedisTest method startFakeRedisServer.
protected FakeRedisServer startFakeRedisServer(int serverPort) throws Exception {
FakeRedisServer fakeRedisServer = new FakeRedisServer(serverPort);
fakeRedisServer.initialize();
fakeRedisServer.start();
add(fakeRedisServer);
return fakeRedisServer;
}
use of com.ctrip.xpipe.redis.core.server.FakeRedisServer in project x-pipe by ctripcorp.
the class PingCommandTest method testPing.
@Test
public void testPing() throws Exception {
FakeRedisServer fakeRedisServer = startFakeRedisServer();
PingCommand command = new PingCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress("localhost", fakeRedisServer.getPort())), scheduled);
String result = command.execute().get();
Assert.assertEquals(PingCommand.PONG, result);
}
use of com.ctrip.xpipe.redis.core.server.FakeRedisServer in project x-pipe by ctripcorp.
the class DefaultRedisKeeperServerTest method testKeeperStopNoConnectMaster.
@Test
public void testKeeperStopNoConnectMaster() throws Exception {
FakeRedisServer server1 = startFakeRedisServer();
FakeRedisServer server2 = startFakeRedisServer();
FakeRedisServer server3 = startFakeRedisServer();
RedisKeeperServer redisKeeperServer = createRedisKeeperServer();
redisKeeperServer.initialize();
redisKeeperServer.start();
redisKeeperServer.setRedisKeeperServerState(new RedisKeeperServerStateActive(redisKeeperServer, localhostInetAddress(server1.getPort())));
redisKeeperServer.reconnectMaster();
waitConditionUntilTimeOut(() -> server1.getConnected() == 1);
sleep(100);
redisKeeperServer.stop();
redisKeeperServer.setRedisKeeperServerState(new RedisKeeperServerStateActive(redisKeeperServer, localhostInetAddress(server2.getPort())));
redisKeeperServer.reconnectMaster();
waitConditionUntilTimeOut(() -> server1.getConnected() == 0);
Assert.assertEquals(0, server2.getConnected());
redisKeeperServer.dispose();
redisKeeperServer.setRedisKeeperServerState(new RedisKeeperServerStateActive(redisKeeperServer, localhostInetAddress(server3.getPort())));
redisKeeperServer.reconnectMaster();
sleep(100);
Assert.assertEquals(0, server1.getConnected());
Assert.assertEquals(0, server2.getConnected());
Assert.assertEquals(0, server3.getConnected());
}
Aggregations