use of com.alibaba.nacos.api.remote.request.HealthCheckRequest in project nacos by alibaba.
the class ClusterRpcClientProxyTest method testSendRequest.
@Test
public void testSendRequest() {
Member member = new Member();
member.setIp("1.1.1.1");
try {
Response response = clusterRpcClientProxy.sendRequest(member, new HealthCheckRequest());
} catch (NacosException e) {
Assert.assertEquals(-401, e.getErrCode());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.alibaba.nacos.api.remote.request.HealthCheckRequest in project nacos by alibaba.
the class ClusterRpcClientProxyTest method testAsyncRequest.
@Test
public void testAsyncRequest() {
RequestCallBack requestCallBack = new RequestCallBack() {
@Override
public Executor getExecutor() {
return null;
}
@Override
public long getTimeout() {
return 0;
}
@Override
public void onResponse(Response response) {
}
@Override
public void onException(Throwable e) {
Assert.assertTrue(e instanceof NacosException);
}
};
Member member = new Member();
member.setIp("1.1.1.1");
try {
clusterRpcClientProxy.asyncRequest(member, new HealthCheckRequest(), requestCallBack);
} catch (NacosException e) {
Assert.assertEquals(500, e.getErrCode());
}
}
use of com.alibaba.nacos.api.remote.request.HealthCheckRequest in project nacos by alibaba.
the class RemoteRequestAuthFilterTest method testFilter.
@Test
public void testFilter() {
Mockito.when(authConfigs.isAuthEnabled()).thenReturn(true);
Request healthCheckRequest = new HealthCheckRequest();
try {
Response healthCheckResponse = remoteRequestAuthFilter.filter(healthCheckRequest, new RequestMeta(), MockRequestHandler.class);
Assert.assertNull(healthCheckResponse);
} catch (NacosException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.alibaba.nacos.api.remote.request.HealthCheckRequest in project nacos by alibaba.
the class GrpcRequestAcceptorTest method testHandleRequestSuccess.
@Test
public void testHandleRequestSuccess() {
ApplicationUtils.setStarted(true);
Mockito.when(requestHandlerRegistry.getByRequestType(Mockito.anyString())).thenReturn(mockHandler);
Mockito.when(connectionManager.checkValid(Mockito.any())).thenReturn(true);
String ip = "1.1.1.1";
ConnectionMeta connectionMeta = new ConnectionMeta(connectId, ip, ip, 8888, 9848, "GRPC", "", "", new HashMap<>());
Connection connection = new GrpcConnection(connectionMeta, null, null);
Mockito.when(connectionManager.getConnection(Mockito.any())).thenReturn(connection);
RequestMeta metadata = new RequestMeta();
metadata.setClientIp("127.0.0.1");
metadata.setConnectionId(connectId);
HealthCheckRequest mockRequest = new HealthCheckRequest();
Payload payload = GrpcUtils.convert(mockRequest, metadata);
StreamObserver<Payload> streamObserver = new StreamObserver<Payload>() {
@Override
public void onNext(Payload payload) {
System.out.println("Receive data from server: " + payload);
Object res = GrpcUtils.parse(payload);
Assert.assertTrue(res instanceof HealthCheckResponse);
}
@Override
public void onError(Throwable throwable) {
Assert.fail(throwable.getMessage());
}
@Override
public void onCompleted() {
System.out.println("complete");
}
};
streamStub.request(payload, streamObserver);
ApplicationUtils.setStarted(false);
}
Aggregations