Search in sources :

Example 6 with TestServerMessageListenerFactory

use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory 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)

Example 7 with TestServerMessageListenerFactory

use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory in project pinpoint by naver.

the class TcpDataSenderTest method connectAndSend.

@Test
public void connectAndSend() {
    TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
    TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    PinpointClientFactory clientFactory = createPinpointClientFactory();
    TcpDataSender<Object> sender = new TcpDataSender<>(this.getClass().getName(), TestPinpointServerAcceptor.LOCALHOST, bindPort, clientFactory);
    try {
        sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi"));
        sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi"));
        serverMessageListener.awaitAssertExpectedSendCount(2, 1000);
    } finally {
        sender.stop();
        if (clientFactory != null) {
            clientFactory.release();
        }
        testPinpointServerAcceptor.close();
    }
}
Also used : TApiMetaData(com.navercorp.pinpoint.thrift.dto.TApiMetaData) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) Test(org.junit.Test)

Example 8 with TestServerMessageListenerFactory

use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory 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());
}
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) ProtocolException(com.navercorp.pinpoint.rpc.control.ProtocolException) IOException(java.io.IOException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with TestServerMessageListenerFactory

use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory 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());
}
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) ProtocolException(com.navercorp.pinpoint.rpc.control.ProtocolException) IOException(java.io.IOException) Test(org.junit.Test)

Example 10 with TestServerMessageListenerFactory

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

Aggregations

TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)11 TestServerMessageListenerFactory (com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory)11 Test (org.junit.Test)11 TestRawSocket (com.navercorp.pinpoint.test.client.TestRawSocket)6 ProtocolException (com.navercorp.pinpoint.rpc.control.ProtocolException)3 PingPayloadPacket (com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)3 IOException (java.io.IOException)3 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)1 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)1 PingPacket (com.navercorp.pinpoint.rpc.packet.PingPacket)1 PingSimplePacket (com.navercorp.pinpoint.rpc.packet.PingSimplePacket)1 TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)1 TApiMetaData (com.navercorp.pinpoint.thrift.dto.TApiMetaData)1 Ignore (org.junit.Ignore)1