Search in sources :

Example 11 with TestPinpointServerAcceptor

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);
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) IOException(java.io.IOException) PinpointSocketException(com.navercorp.pinpoint.rpc.PinpointSocketException) Test(org.junit.Test)

Example 12 with TestPinpointServerAcceptor

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();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) Test(org.junit.Test)

Example 13 with TestPinpointServerAcceptor

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());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) Test(org.junit.Test)

Example 14 with TestPinpointServerAcceptor

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());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) PingSimplePacket(com.navercorp.pinpoint.rpc.packet.PingSimplePacket) ProtocolException(com.navercorp.pinpoint.rpc.control.ProtocolException) IOException(java.io.IOException) Test(org.junit.Test)

Example 15 with TestPinpointServerAcceptor

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());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket) Test(org.junit.Test)

Aggregations

TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)52 Test (org.junit.Test)50 TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)13 TestRawSocket (com.navercorp.pinpoint.test.client.TestRawSocket)11 TestServerMessageListenerFactory (com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory)11 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)10 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)10 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)10 MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)8 RecordedStreamChannelMessageListener (com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener)6 IOException (java.io.IOException)6 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)3 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)3 ProtocolException (com.navercorp.pinpoint.rpc.control.ProtocolException)3 PingPayloadPacket (com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)3 Ignore (org.junit.Ignore)3 ServerMetaDataRegistryService (com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)2 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)2 PinpointClientReconnectEventListener (com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener)2 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)2