use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class AbstractTransportTest method transportTracer_client_streamEnded_nonOk.
@Test
public void transportTracer_client_streamEnded_nonOk() throws Exception {
server.start(serverListener);
client = newClientTransport(server);
startTransport(client, mockClientTransportListener);
ClientStream clientStream = client.newStream(methodDescriptor, new Metadata(), callOptions, tracers);
ClientStreamListenerBase clientStreamListener = new ClientStreamListenerBase();
clientStream.start(clientStreamListener);
MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
if (!haveTransportTracer()) {
return;
}
TransportStats serverBefore = getTransportStats(serverTransportListener.transport);
assertEquals(0, serverBefore.streamsFailed);
assertEquals(0, serverBefore.streamsSucceeded);
TransportStats clientBefore = getTransportStats(client);
assertEquals(0, clientBefore.streamsFailed);
assertEquals(0, clientBefore.streamsSucceeded);
clientStream.cancel(Status.UNKNOWN);
// do not validate stats until close() has been called on server
assertNotNull(serverStreamCreation.listener.status.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
TransportStats serverAfter = getTransportStats(serverTransportListener.transport);
assertEquals(1, serverAfter.streamsFailed);
assertEquals(0, serverAfter.streamsSucceeded);
TransportStats clientAfter = getTransportStats(client);
assertEquals(1, clientAfter.streamsFailed);
assertEquals(0, clientAfter.streamsSucceeded);
}
use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class AbstractTransportTest method transportTracer_server_streamEnded_nonOk.
@Test
public void transportTracer_server_streamEnded_nonOk() throws Exception {
server.start(serverListener);
client = newClientTransport(server);
startTransport(client, mockClientTransportListener);
ClientStream clientStream = client.newStream(methodDescriptor, new Metadata(), callOptions, tracers);
ClientStreamListenerBase clientStreamListener = new ClientStreamListenerBase();
clientStream.start(clientStreamListener);
MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
ServerStream serverStream = serverStreamCreation.stream;
if (!haveTransportTracer()) {
return;
}
TransportStats serverBefore = getTransportStats(serverTransportListener.transport);
assertEquals(0, serverBefore.streamsFailed);
assertEquals(0, serverBefore.streamsSucceeded);
TransportStats clientBefore = getTransportStats(client);
assertEquals(0, clientBefore.streamsFailed);
assertEquals(0, clientBefore.streamsSucceeded);
serverStream.close(Status.UNKNOWN, new Metadata());
// do not validate stats until close() has been called on client
assertNotNull(clientStreamListener.status.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
assertNotNull(clientStreamListener.trailers.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
TransportStats serverAfter = getTransportStats(serverTransportListener.transport);
assertEquals(1, serverAfter.streamsFailed);
assertEquals(0, serverAfter.streamsSucceeded);
TransportStats clientAfter = getTransportStats(client);
assertEquals(1, clientAfter.streamsFailed);
assertEquals(0, clientAfter.streamsSucceeded);
client.shutdown(Status.UNAVAILABLE);
}
use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class AbstractTransportTest method transportTracer_server_receive_msg.
@Test
public void transportTracer_server_receive_msg() throws Exception {
server.start(serverListener);
client = newClientTransport(server);
startTransport(client, mockClientTransportListener);
ClientStream clientStream = client.newStream(methodDescriptor, new Metadata(), callOptions, tracers);
ClientStreamListenerBase clientStreamListener = new ClientStreamListenerBase();
clientStream.start(clientStreamListener);
MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
ServerStream serverStream = serverStreamCreation.stream;
ServerStreamListenerBase serverStreamListener = serverStreamCreation.listener;
if (!haveTransportTracer()) {
return;
}
TransportStats serverBefore = getTransportStats(serverTransportListener.transport);
assertEquals(0, serverBefore.messagesReceived);
assertEquals(0, serverBefore.lastMessageReceivedTimeNanos);
TransportStats clientBefore = getTransportStats(client);
assertEquals(0, clientBefore.messagesSent);
assertEquals(0, clientBefore.lastMessageSentTimeNanos);
serverStream.request(1);
clientStream.writeMessage(methodDescriptor.streamRequest("request"));
clientStream.flush();
clientStream.halfClose();
verifyMessageCountAndClose(serverStreamListener.messageQueue, 1);
TransportStats serverAfter = getTransportStats(serverTransportListener.transport);
assertEquals(1, serverAfter.messagesReceived);
assertEquals(fakeCurrentTimeNanos(), serverAfter.lastMessageReceivedTimeNanos);
TransportStats clientAfter = getTransportStats(client);
assertEquals(1, clientAfter.messagesSent);
assertEquals(fakeCurrentTimeNanos(), clientAfter.lastMessageSentTimeNanos);
serverStream.close(Status.OK, new Metadata());
}
use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class NettyHandlerTestBase method transportTracer_windowUpdate_remote.
@Test
public void transportTracer_windowUpdate_remote() throws Exception {
manualSetUp();
TransportStats before = transportTracer.getStats();
assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, before.remoteFlowControlWindow);
assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, before.localFlowControlWindow);
ByteBuf serializedSettings = windowUpdate(0, 1000);
channelRead(serializedSettings);
TransportStats after = transportTracer.getStats();
assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE + 1000, after.remoteFlowControlWindow);
assertEquals(flowControlWindow, after.localFlowControlWindow);
}
use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class NettyHandlerTestBase method transportTracer_windowUpdate_local.
@Test
public void transportTracer_windowUpdate_local() throws Exception {
manualSetUp();
TransportStats before = transportTracer.getStats();
assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, before.remoteFlowControlWindow);
assertEquals(flowControlWindow, before.localFlowControlWindow);
// If the window size is below a certain threshold, netty will wait to apply the update.
// Use a large increment to be sure that it exceeds the threshold.
connection().local().flowController().incrementWindowSize(connection().connectionStream(), 8 * Http2CodecUtil.DEFAULT_WINDOW_SIZE);
TransportStats after = transportTracer.getStats();
assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, after.remoteFlowControlWindow);
assertEquals(flowControlWindow + 8 * Http2CodecUtil.DEFAULT_WINDOW_SIZE, connection().local().flowController().windowSize(connection().connectionStream()));
}
Aggregations