use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ReconnectTest method serverCloseAndWrite.
@Test
public void serverCloseAndWrite() throws IOException, InterruptedException {
// when abnormal case in which server has been closed first, confirm that a client socket should be closed properly.
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor();
int bindPort = testPinpointServerAcceptor.bind();
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
// just close server and request
testPinpointServerAcceptor.close();
byte[] randomByte = TestByteUtils.createRandomByte(10);
Future<ResponseMessage> response = client.request(randomByte);
response.await();
try {
response.getResult();
Assert.fail("expected exception");
} catch (Exception e) {
}
assertClientDisconnected(client);
PinpointRPCTestUtils.close(client);
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest2.
@Test
public void clientMessageListenerTest2() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener1 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient1 = new TestPinpointClient(echoMessageListener1, PinpointRPCTestUtils.getParams());
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener2 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient2 = new TestPinpointClient(echoMessageListener2, PinpointRPCTestUtils.getParams());
try {
testPinpointClient1.connect(bindPort);
testPinpointClient2.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(2, 1000);
PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
assertRequestMessage(writableServer, "socket1", null);
PinpointSocket writableServer2 = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(1);
assertRequestMessage(writableServer2, "socket2", null);
echoMessageListener1.awaitAssertExpectedRequestCount(1, 0);
echoMessageListener2.awaitAssertExpectedRequestCount(1, 0);
} finally {
testPinpointClient1.closeAll();
testPinpointClient2.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HealthCheckTest method legacyHealthCheckTest1.
@Test
public void legacyHealthCheckTest1() 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, PingPacket.PING_PACKET);
} 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 healthCheckSimplePingTest.
@Test
public void healthCheckSimplePingTest() 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 PingSimplePacket());
Assert.fail();
} catch (Exception e) {
} 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 healthCheckTest.
@Test
public void healthCheckTest() 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);
// RUN_WITHOUT_HANDSHAKE
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 10));
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertTrue(serverMessageListener.hasReceivedPing());
}
Aggregations