use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest4.
// after success of registering, when success message are sent repeatedly.
// test 1) confirm to return success code, 2) confirm to return already success code.
@Test
public void registerAgentTest4() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new HandshakeVerifyMessageListenerFactory());
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendAndReceiveSimplePacket(testRawSocket);
int code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(0, code);
sendAndReceiveSimplePacket(testRawSocket);
code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(1, code);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest1.
// Test for being possible to send messages in case of failure of registering packet ( return code : 2, lack of parameter)
@Test
public void registerAgentTest1() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new HandshakeVerifyMessageListenerFactory());
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendAndReceiveSimplePacket(testRawSocket);
int code = sendAndReceiveRegisterPacket(testRawSocket);
Assert.assertEquals(2, code);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest2.
// Test for being possible to send messages in case of success of registering packet ( return code : 0)
@Test
public void registerAgentTest2() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new HandshakeVerifyMessageListenerFactory());
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendAndReceiveSimplePacket(testRawSocket);
int code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(0, code);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseByPeerTest.
@Test
public void unexpectedCloseByPeerTest() throws IOException, ProtocolException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
try {
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
testRawSocket.connect(bindPort);
testRawSocket.sendHandshakePacket(PinpointRPCTestUtils.getParams());
testPinpointServerAcceptor.assertAwaitClientConnected(1, 1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
if (!(pinpointServer instanceof PinpointServer)) {
testRawSocket.close();
Assert.fail();
}
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testRawSocket.close();
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_CLIENT, (PinpointServer) pinpointServer);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestRawSocket 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());
}
Aggregations