use of com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager in project pinpoint by naver.
the class GrpcCommandServiceTest method oldVersionHandshakeTest.
@Test
public void oldVersionHandshakeTest() throws IOException, PinpointZookeeperException {
ZookeeperProfilerClusterManager manager = creteMemoryClusterManager();
ZookeeperClusterService mockClusterService = Mockito.mock(ZookeeperClusterService.class);
Mockito.when(mockClusterService.getProfilerClusterManager()).thenReturn(manager);
try (GrpcCommandService commandService = new GrpcCommandService(mockClusterService)) {
TransportMetadata transportMetaData = createTransportMetaData(new InetSocketAddress("127.0.0.1", 61613), 10);
attachContext(transportMetaData);
attachContext(new Header("test", "agentId", "agentName", "applicationName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, null));
StreamObserver<PCmdMessage> handleMessageObserver = commandService.handleCommand(new TempServerCallStreamObserver<>());
handleMessageObserver.onNext(createHandshakeMessage());
awaitility().await("oldVersionHandshakeTest").until(manager::getClusterData, hasSize(1));
assertHandleMessage(commandService, transportMetaData);
}
}
use of com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager in project pinpoint by naver.
the class GrpcCommandServiceTest method oldVersionHandshakeFailTest.
@Test
public void oldVersionHandshakeFailTest() throws IOException, PinpointZookeeperException {
ZookeeperProfilerClusterManager manager = creteMemoryClusterManager();
ZookeeperClusterService mockClusterService = Mockito.mock(ZookeeperClusterService.class);
Mockito.when(mockClusterService.getProfilerClusterManager()).thenReturn(manager);
try (GrpcCommandService commandService = new GrpcCommandService(mockClusterService)) {
TransportMetadata transportMetaData = createTransportMetaData(new InetSocketAddress("127.0.0.1", 61613), 10);
attachContext(transportMetaData);
attachContext(new Header("test", "agentId", "agentName", "applicationName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, getCodeList()));
final TempServerCallStreamObserver<PCmdRequest> requestObserver = new TempServerCallStreamObserver<>();
StreamObserver<PCmdMessage> handleMessageObserver = commandService.handleCommand(requestObserver);
Assert.assertThrows(ConditionTimeoutException.class, () -> {
Awaitility.await("oldVersionHandshakeFailTest").timeout(400, TimeUnit.MILLISECONDS).until(manager::getClusterData, hasSize(1));
});
Assert.assertNotNull(requestObserver.getLatestException());
}
}
use of com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager in project pinpoint by naver.
the class GrpcCommandServiceTest method newVersionHandshakeTest.
@Test
public void newVersionHandshakeTest() throws IOException, PinpointZookeeperException {
ZookeeperProfilerClusterManager manager = creteMemoryClusterManager();
ZookeeperClusterService mockClusterService = Mockito.mock(ZookeeperClusterService.class);
Mockito.when(mockClusterService.getProfilerClusterManager()).thenReturn(manager);
try (GrpcCommandService commandService = new GrpcCommandService(mockClusterService)) {
TransportMetadata transportMetaData = createTransportMetaData(new InetSocketAddress("127.0.0.1", 61613), 10);
attachContext(transportMetaData);
attachContext(new Header("test", "agentId", null, "applicationName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, getCodeList()));
StreamObserver<PCmdMessage> handleMessageObserver = commandService.handleCommandV2(new TempServerCallStreamObserver<>());
awaitility().until(manager::getClusterData, hasSize(1));
assertHandleMessage(commandService, transportMetaData);
}
}
use of com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager in project pinpoint by naver.
the class GrpcCommandServiceTest method creteMemoryClusterManager.
private ZookeeperProfilerClusterManager creteMemoryClusterManager() throws PinpointZookeeperException {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient();
zookeeperClient.connect();
String path = ZKPaths.makePath(ZookeeperConstants.DEFAULT_CLUSTER_ZNODE_ROOT_PATH, ZookeeperConstants.COLLECTOR_LEAF_PATH, this.getClass().getSimpleName());
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, path, new ClusterPointRepository());
manager.start();
return manager;
}
Aggregations