Search in sources :

Example 1 with ResponseParameters

use of io.grpc.testing.integration.Messages.ResponseParameters in project grpc-java by grpc.

the class TestServiceImpl method toChunkQueue.

/**
   * Breaks down the request and creates a queue of response chunks for the given request.
   */
public Queue<Chunk> toChunkQueue(StreamingOutputCallRequest request) {
    Queue<Chunk> chunkQueue = new LinkedList<Chunk>();
    int offset = 0;
    boolean compressable = compressableResponse(request.getResponseType());
    for (ResponseParameters params : request.getResponseParametersList()) {
        chunkQueue.add(new Chunk(params.getIntervalUs(), offset, params.getSize(), compressable));
        // Increment the offset past this chunk.
        // Both buffers need to be circular.
        offset = (offset + params.getSize()) % (compressable ? compressableBuffer.size() : uncompressableBuffer.size());
    }
    return chunkQueue;
}
Also used : ResponseParameters(io.grpc.testing.integration.Messages.ResponseParameters) LinkedList(java.util.LinkedList)

Example 2 with ResponseParameters

use of io.grpc.testing.integration.Messages.ResponseParameters in project grpc-java by grpc.

the class AbstractInteropTest method deadlineExceededServerStreaming.

@Test(timeout = 10000)
public void deadlineExceededServerStreaming() throws Exception {
    // warm up the channel and JVM
    blockingStub.emptyCall(Empty.getDefaultInstance());
    ResponseParameters.Builder responseParameters = ResponseParameters.newBuilder().setSize(1).setIntervalUs(10000);
    StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder().setResponseType(PayloadType.COMPRESSABLE).addResponseParameters(responseParameters).addResponseParameters(responseParameters).addResponseParameters(responseParameters).addResponseParameters(responseParameters).build();
    StreamRecorder<StreamingOutputCallResponse> recorder = StreamRecorder.create();
    TestServiceGrpc.newStub(channel).withDeadlineAfter(30, TimeUnit.MILLISECONDS).streamingOutputCall(request, recorder);
    recorder.awaitCompletion();
    assertEquals(Status.DEADLINE_EXCEEDED.getCode(), Status.fromThrowable(recorder.getError()).getCode());
    if (metricsExpected()) {
        assertMetrics("grpc.testing.TestService/EmptyCall", Status.Code.OK);
        assertClientMetrics("grpc.testing.TestService/StreamingOutputCall", Status.Code.DEADLINE_EXCEEDED);
    // Do not check server-side metrics, because the status on the server side is undetermined.
    }
}
Also used : ResponseParameters(io.grpc.testing.integration.Messages.ResponseParameters) StreamingOutputCallRequest(io.grpc.testing.integration.Messages.StreamingOutputCallRequest) StreamingOutputCallResponse(io.grpc.testing.integration.Messages.StreamingOutputCallResponse) Test(org.junit.Test)

Aggregations

ResponseParameters (io.grpc.testing.integration.Messages.ResponseParameters)2 StreamingOutputCallRequest (io.grpc.testing.integration.Messages.StreamingOutputCallRequest)1 StreamingOutputCallResponse (io.grpc.testing.integration.Messages.StreamingOutputCallResponse)1 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1