use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class AtLeastOneCheckerTest method testCheckerTimeout.
@Test
public void testCheckerTimeout() throws Exception {
Server server = startServer((String) null);
List<RedisMeta> redises = new LinkedList<>();
redises.add(new RedisMeta().setIp("localhost").setPort(server.getPort()));
SimpleErrorMessage check = new AtLeastOneChecker(redises, getXpipeNettyClientKeyedObjectPool(), scheduled).check();
Assert.assertEquals(SIMPLE_RETURN_CODE.FAIL, check.getErrorType());
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class TcpPortCheckCommandTest method testResource.
// @Test
public void testResource() throws Exception {
Server server = startEchoServer();
int i = 0;
try {
for (; i < (1 << 10); i++) {
TcpPortCheckCommand checkCommand = new TcpPortCheckCommand("localhost", server.getPort());
CommandFuture<Boolean> future = checkCommand.execute();
Assert.assertTrue(future.get(500, TimeUnit.SECONDS));
}
} catch (Exception e) {
logger.error("[testResource]" + i, e);
}
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class XpipeNettyClientKeyedObjectPoolTest method testIdleClose.
@Test
public void testIdleClose() throws Exception {
Server echoServer = startEchoServer();
InetSocketAddress key = new InetSocketAddress("localhost", echoServer.getPort());
pool.setKeyPooConfig(0, 200, 500, 100);
SimpleObjectPool<NettyClient> objectPool = pool.getKeyPool(key);
NettyClient nettyClient1 = objectPool.borrowObject();
NettyClient nettyClient2 = objectPool.borrowObject();
waitConditionUntilTimeOut(() -> echoServer.getConnected() == 2);
objectPool.returnObject(nettyClient1);
objectPool.returnObject(nettyClient2);
waitConditionUntilTimeOut(() -> echoServer.getConnected() == 0, 60000);
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class XpipeNettyClientKeyedObjectPoolTest method testKeyPoolReuse.
@Test
public void testKeyPoolReuse() throws Exception {
Server echoServer = startEchoServer();
InetSocketAddress key = new InetSocketAddress("localhost", echoServer.getPort());
Assert.assertEquals(0, echoServer.getConnected());
SimpleObjectPool<NettyClient> objectPool = pool.getKeyPool(key);
for (int i = 0; i < testCount; i++) {
NettyClient client = objectPool.borrowObject();
sleep(10);
Assert.assertEquals(1, echoServer.getTotalConnected());
objectPool.returnObject(client);
}
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class XpipeNettyClientKeyedObjectPoolTest method testMax.
@Test
public void testMax() throws Exception {
Server echoServer = startEchoServer();
InetSocketAddress key = new InetSocketAddress("localhost", echoServer.getPort());
Assert.assertEquals(0, echoServer.getConnected());
for (int i = 0; i < maxPerKey; i++) {
pool.borrowObject(key);
sleep(100);
Assert.assertEquals(i + 1, echoServer.getConnected());
}
try {
pool.borrowObject(key);
Assert.fail();
} catch (BorrowObjectException e) {
}
}
Aggregations