Skip to content

Commit

Permalink
Wait 5 seconds, not over an hour
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Jan 25, 2016
1 parent 2bd0887 commit c70a769
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
private TestServiceGrpc.TestService asyncStub;
private String testCase;
private TestListener listener;
private static int OPERATION_TIMEOUT = 5000;
private static int TIMEOUT_MILLIS = 5000;

class ResponseObserver implements StreamObserver<Messages.StreamingOutputCallResponse> {
public LinkedBlockingQueue<Object> responses = new LinkedBlockingQueue<Object>();
Expand Down Expand Up @@ -369,7 +369,7 @@ public void pingPong() throws Exception {
= asyncStub.fullDuplexCall(responseObserver);
for (int i = 0; i < requests.length; i++) {
requestObserver.onNext(requests[i]);
Object response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
Object response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
if (!(response instanceof Messages.StreamingOutputCallResponse)) {
fail("Unexpected: " + response);
}
Expand All @@ -379,7 +379,7 @@ public void pingPong() throws Exception {
}
requestObserver.onCompleted();
assertEquals(responseObserver.magicTailResponse,
responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS));
responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
}

public void emptyStream() throws Exception {
Expand All @@ -389,7 +389,7 @@ public void emptyStream() throws Exception {
= asyncStub.fullDuplexCall(responseObserver);
requestObserver.onCompleted();
assertEquals(responseObserver.magicTailResponse,
responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS));
responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
}

public void cancelAfterBegin() throws Exception {
Expand Down Expand Up @@ -419,14 +419,14 @@ public void cancelAfterFirstResponse() throws Exception {
StreamObserver<StreamingOutputCallRequest> requestObserver
= asyncStub.fullDuplexCall(responseObserver);
requestObserver.onNext(request);
Object response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
Object response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
if (!(response instanceof Messages.StreamingOutputCallResponse)) {
fail("Unexpected: " + response);
}
assertMessageEquals(goldenResponse, (Messages.StreamingOutputCallResponse) response);

requestObserver.onError(new RuntimeException());
response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
if (!(response instanceof Throwable)) {
fail("Unexpected: " + response);
}
Expand Down Expand Up @@ -542,7 +542,7 @@ public void onClose(io.grpc.Status status, Metadata trailers) {
// Time how long it takes to get the first response.
call.request(1);
assertMessageEquals(goldenResponses[0],
(StreamingOutputCallResponse) queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
(StreamingOutputCallResponse) queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
long firstCallDuration = System.nanoTime() - start;

// Without giving additional flow control, make sure that we don't get another response. We wait
Expand All @@ -555,8 +555,8 @@ public void onClose(io.grpc.Status status, Metadata trailers) {
// Make sure that everything still completes.
call.request(1);
assertMessageEquals(goldenResponses[1],
(StreamingOutputCallResponse) queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
assertEquals(io.grpc.Status.OK, queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
(StreamingOutputCallResponse) queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
assertEquals(io.grpc.Status.OK, queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
}

public void veryLargeRequest() throws Exception {
Expand Down Expand Up @@ -684,23 +684,23 @@ public void gracefulShutdown() throws Exception {
StreamObserver<StreamingOutputCallRequest> requestObserver
= asyncStub.fullDuplexCall(responseObserver);
requestObserver.onNext(requests[0]);
Object response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
Object response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
assertMessageEquals(goldenResponses[0], (Messages.StreamingOutputCallResponse) response);
// Initiate graceful shutdown.
channel.shutdown();
// The previous ping-pong could have raced with the shutdown, but this one certainly shouldn't.
requestObserver.onNext(requests[1]);
response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
assertMessageEquals(goldenResponses[1], (Messages.StreamingOutputCallResponse) response);
requestObserver.onNext(requests[2]);
response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
assertMessageEquals(goldenResponses[2], (Messages.StreamingOutputCallResponse) response);
requestObserver.onCompleted();
assertEquals(responseObserver.magicTailResponse,
responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS));
responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
}

/** Sends an rpc to an unimplemented method on the server. */
Expand Down

0 comments on commit c70a769

Please sign in to comment.