Search in sources :

Example 26 with TestPinpointServerAcceptor

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

the class StreamChannelManagerTest method streamSuccessTest3.

@Test
public void streamSuccessTest3() throws IOException, InterruptedException, StreamException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    SimpleStreamBO bo = new SimpleStreamBO();
    TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, new ServerListener(bo));
    try {
        testPinpointClient.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
        Assert.assertEquals(1, writableServerList.size());
        PinpointSocket writableServer = writableServerList.get(0);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        if (writableServer instanceof PinpointServer) {
            ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
            int sendCount = 4;
            for (int i = 0; i < sendCount; i++) {
                sendRandomBytes(bo);
            }
            clientListener.getLatch().await();
            Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
            clientStreamChannel.close();
        } else {
            Assert.fail();
        }
    } finally {
        testPinpointClient.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) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) Test(org.junit.Test)

Example 27 with TestPinpointServerAcceptor

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

the class StreamChannelManagerTest method streamSuccessTest1.

// Client to Server Stream
@Test
public void streamSuccessTest1() throws IOException, InterruptedException, StreamException {
    SimpleStreamBO bo = new SimpleStreamBO();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory, new ServerListener(bo));
    int bindPort = testPinpointServerAcceptor.bind();
    TestPinpointClient testPinpointClient = new TestPinpointClient();
    try {
        testPinpointClient.connect(bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        ClientStreamChannel clientStreamChannel = testPinpointClient.openStream(new byte[0], clientListener);
        int sendCount = 4;
        for (int i = 0; i < sendCount; i++) {
            sendRandomBytes(bo);
        }
        clientListener.getLatch().await();
        Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
        clientStreamChannel.close();
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) Test(org.junit.Test)

Example 28 with TestPinpointServerAcceptor

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

the class StreamChannelManagerTest method streamClosedTest2.

@Test
public void streamClosedTest2() throws IOException, InterruptedException, StreamException {
    final SimpleStreamBO bo = new SimpleStreamBO();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory, new ServerListener(bo));
    int bindPort = testPinpointServerAcceptor.bind();
    TestPinpointClient testPinpointClient = new TestPinpointClient();
    try {
        testPinpointClient.connect(bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        ClientStreamChannel clientStreamChannel = testPinpointClient.openStream(new byte[0], clientListener);
        Assert.assertEquals(1, bo.getStreamChannelContextSize());
        clientStreamChannel.close();
        Awaitility.await().until(new Callable<Integer>() {

            @Override
            public Integer call() throws Exception {
                return bo.getStreamChannelContextSize();
            }
        }, is(0));
        Assert.assertEquals(0, bo.getStreamChannelContextSize());
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) IOException(java.io.IOException) PinpointSocketException(com.navercorp.pinpoint.rpc.PinpointSocketException) Test(org.junit.Test)

Example 29 with TestPinpointServerAcceptor

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

the class StreamChannelManagerTest method streamClosedTest1.

@Test(expected = StreamException.class)
public void streamClosedTest1() throws IOException, InterruptedException, StreamException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    TestPinpointClient testPinpointClient = new TestPinpointClient();
    try {
        testPinpointClient.connect(bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        testPinpointClient.openStream(new byte[0], clientListener);
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) Test(org.junit.Test)

Example 30 with TestPinpointServerAcceptor

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

the class TcpDataSenderReconnectTest method connectAndSend.

@Test
public void connectAndSend() throws InterruptedException {
    TestPinpointServerAcceptor oldTestPinpointServerAcceptor = new TestPinpointServerAcceptor(new LoggingServerMessageListenerFactory(true));
    int bindPort = oldTestPinpointServerAcceptor.bind();
    PinpointClientFactory clientFactory = createPinpointClientFactory();
    TcpDataSender sender = new TcpDataSender(this.getClass().getName(), TestPinpointServerAcceptor.LOCALHOST, bindPort, clientFactory);
    oldTestPinpointServerAcceptor.assertAwaitClientConnected(5000);
    oldTestPinpointServerAcceptor.close();
    waitClientDisconnected(sender);
    logger.debug("Server start------------------");
    TestPinpointServerAcceptor newTestPinpointServerAcceptor = new TestPinpointServerAcceptor(new LoggingServerMessageListenerFactory(true));
    newTestPinpointServerAcceptor.bind(bindPort);
    newTestPinpointServerAcceptor.assertAwaitClientConnected(5000);
    logger.debug("sendMessage------------------");
    sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi"));
    Thread.sleep(500);
    logger.debug("sender stop------------------");
    sender.stop();
    newTestPinpointServerAcceptor.close();
    clientFactory.release();
}
Also used : TApiMetaData(com.navercorp.pinpoint.thrift.dto.TApiMetaData) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) LoggingServerMessageListenerFactory(com.navercorp.pinpoint.rpc.server.LoggingServerMessageListenerFactory) 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