use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class PingCommandTest method testTimeout.
@Test(expected = CommandTimeoutException.class)
public void testTimeout() throws Throwable {
Server server = startServer((String) null);
PingCommand command = new PingCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress("127.0.0.1", server.getPort())), scheduled);
try {
String result = command.execute().get();
} catch (ExecutionException e) {
throw e.getCause();
}
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class RoleCommandTest method test.
@Test
public void test() throws Exception {
SlaveRole role = new SlaveRole(SERVER_ROLE.KEEPER, "localhost", randomPort(), MASTER_STATE.REDIS_REPL_CONNECT, 0L);
Server server = startServer(ByteBufUtils.readToString(role.format()));
RoleCommand roleCommand = new RoleCommand("localhost", server.getPort(), scheduled);
Role real = roleCommand.execute().get();
logger.info("[test]{}", real);
Assert.assertEquals(role, real);
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class AtLeastOneCheckerTest method testCheckerSuccess.
@Test
public void testCheckerSuccess() throws Exception {
int count = 3;
List<RedisMeta> redises = new LinkedList<>();
Set<Integer> ports = randomPorts(count);
int i = 0;
for (int port : ports) {
if (i == count - 1) {
Server server = startServer(port, toRedisProtocalString("PONG"));
}
redises.add(new RedisMeta().setIp("localhost").setPort(port));
i++;
}
SimpleErrorMessage check = new AtLeastOneChecker(redises, getXpipeNettyClientKeyedObjectPool(), scheduled).check();
Assert.assertEquals(SIMPLE_RETURN_CODE.SUCCESS, check.getErrorType());
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class PrimaryDcKeeperMasterChooserAlgorithmTest method testLongConnection.
@Test
public void testLongConnection() throws Exception {
SlaveRole role = new SlaveRole(SERVER_ROLE.MASTER, "localhost", randomPort(), MASTER_STATE.REDIS_REPL_CONNECT, 0L);
RedisMeta chosen = redises.get(0);
Server server = startServer(chosen.getPort(), ByteBufUtils.readToString(role.format()));
Assert.assertEquals(0, server.getConnected());
for (int i = 0; i < 10; i++) {
primaryAlgorithm.choose();
Assert.assertEquals(1, server.getConnected());
}
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class TcpPortCheckCommandTest method testOk.
@Test
public void testOk() throws Exception {
Server server = startEchoServer();
for (int i = 0; i < count; i++) {
TcpPortCheckCommand checkCommand = new TcpPortCheckCommand("localhost", server.getPort());
CommandFuture<Boolean> future = checkCommand.execute();
Assert.assertTrue(future.get(500, TimeUnit.SECONDS));
}
}
Aggregations