use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HealthCheckTest method expiredHealthCheckTest.
@Ignore
@Test
public void expiredHealthCheckTest() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
Thread.sleep(35 * 60 * 1000);
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
Assert.fail();
} catch (Exception ignore) {
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HealthCheckTest method stateSyncFailTest.
@Test
public void stateSyncFailTest() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
boolean isSuccess = false;
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
isSuccess = true;
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(isSuccess);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HealthCheckTest method legacyHealthCheckTest2.
@Test
public void legacyHealthCheckTest2() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendPingAndReceivePongPacket(testRawSocket, new PingPacket(1, (byte) 1, (byte) 10));
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertTrue(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientStateTest method unexpectedCloseStateTest.
@Test
public void unexpectedCloseStateTest() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
DefaultPinpointClientFactory clientFactory = null;
DefaultPinpointClientHandler handler = null;
try {
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
handler = connect(clientFactory, bindPort);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
clientFactory.release();
assertHandlerState(SocketStateCode.UNEXPECTED_CLOSE_BY_CLIENT, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientFactory);
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientStateTest method closeByPeerStateTest.
@Test
public void closeByPeerStateTest() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
DefaultPinpointClientFactory clientFactory = null;
DefaultPinpointClientHandler handler = null;
try {
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
handler = connect(clientFactory, bindPort);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
testPinpointServerAcceptor.close();
assertHandlerState(SocketStateCode.CLOSED_BY_SERVER, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientFactory);
testPinpointServerAcceptor.close();
}
}
Aggregations