mirror of https://github.com/grpc/grpc-java.git
Wait 5 seconds, not over an hour
This commit is contained in:
parent
2bd0887db3
commit
c70a769da7
|
|
@ -99,7 +99,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
private TestServiceGrpc.TestService asyncStub;
|
private TestServiceGrpc.TestService asyncStub;
|
||||||
private String testCase;
|
private String testCase;
|
||||||
private TestListener listener;
|
private TestListener listener;
|
||||||
private static int OPERATION_TIMEOUT = 5000;
|
private static int TIMEOUT_MILLIS = 5000;
|
||||||
|
|
||||||
class ResponseObserver implements StreamObserver<Messages.StreamingOutputCallResponse> {
|
class ResponseObserver implements StreamObserver<Messages.StreamingOutputCallResponse> {
|
||||||
public LinkedBlockingQueue<Object> responses = new LinkedBlockingQueue<Object>();
|
public LinkedBlockingQueue<Object> responses = new LinkedBlockingQueue<Object>();
|
||||||
|
|
@ -369,7 +369,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
= asyncStub.fullDuplexCall(responseObserver);
|
= asyncStub.fullDuplexCall(responseObserver);
|
||||||
for (int i = 0; i < requests.length; i++) {
|
for (int i = 0; i < requests.length; i++) {
|
||||||
requestObserver.onNext(requests[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)) {
|
if (!(response instanceof Messages.StreamingOutputCallResponse)) {
|
||||||
fail("Unexpected: " + response);
|
fail("Unexpected: " + response);
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +379,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
}
|
}
|
||||||
requestObserver.onCompleted();
|
requestObserver.onCompleted();
|
||||||
assertEquals(responseObserver.magicTailResponse,
|
assertEquals(responseObserver.magicTailResponse,
|
||||||
responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS));
|
responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emptyStream() throws Exception {
|
public void emptyStream() throws Exception {
|
||||||
|
|
@ -389,7 +389,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
= asyncStub.fullDuplexCall(responseObserver);
|
= asyncStub.fullDuplexCall(responseObserver);
|
||||||
requestObserver.onCompleted();
|
requestObserver.onCompleted();
|
||||||
assertEquals(responseObserver.magicTailResponse,
|
assertEquals(responseObserver.magicTailResponse,
|
||||||
responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS));
|
responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelAfterBegin() throws Exception {
|
public void cancelAfterBegin() throws Exception {
|
||||||
|
|
@ -419,14 +419,14 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
StreamObserver<StreamingOutputCallRequest> requestObserver
|
StreamObserver<StreamingOutputCallRequest> requestObserver
|
||||||
= asyncStub.fullDuplexCall(responseObserver);
|
= asyncStub.fullDuplexCall(responseObserver);
|
||||||
requestObserver.onNext(request);
|
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)) {
|
if (!(response instanceof Messages.StreamingOutputCallResponse)) {
|
||||||
fail("Unexpected: " + response);
|
fail("Unexpected: " + response);
|
||||||
}
|
}
|
||||||
assertMessageEquals(goldenResponse, (Messages.StreamingOutputCallResponse) response);
|
assertMessageEquals(goldenResponse, (Messages.StreamingOutputCallResponse) response);
|
||||||
|
|
||||||
requestObserver.onError(new RuntimeException());
|
requestObserver.onError(new RuntimeException());
|
||||||
response = responseObserver.responses.poll(OPERATION_TIMEOUT, TimeUnit.SECONDS);
|
response = responseObserver.responses.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
|
||||||
if (!(response instanceof Throwable)) {
|
if (!(response instanceof Throwable)) {
|
||||||
fail("Unexpected: " + response);
|
fail("Unexpected: " + response);
|
||||||
}
|
}
|
||||||
|
|
@ -542,7 +542,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
// Time how long it takes to get the first response.
|
// Time how long it takes to get the first response.
|
||||||
call.request(1);
|
call.request(1);
|
||||||
assertMessageEquals(goldenResponses[0],
|
assertMessageEquals(goldenResponses[0],
|
||||||
(StreamingOutputCallResponse) queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
|
(StreamingOutputCallResponse) queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
|
||||||
long firstCallDuration = System.nanoTime() - start;
|
long firstCallDuration = System.nanoTime() - start;
|
||||||
|
|
||||||
// Without giving additional flow control, make sure that we don't get another response. We wait
|
// Without giving additional flow control, make sure that we don't get another response. We wait
|
||||||
|
|
@ -555,8 +555,8 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
// Make sure that everything still completes.
|
// Make sure that everything still completes.
|
||||||
call.request(1);
|
call.request(1);
|
||||||
assertMessageEquals(goldenResponses[1],
|
assertMessageEquals(goldenResponses[1],
|
||||||
(StreamingOutputCallResponse) queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
|
(StreamingOutputCallResponse) queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
|
||||||
assertEquals(io.grpc.Status.OK, queue.poll(OPERATION_TIMEOUT, TimeUnit.MILLISECONDS));
|
assertEquals(io.grpc.Status.OK, queue.poll(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void veryLargeRequest() throws Exception {
|
public void veryLargeRequest() throws Exception {
|
||||||
|
|
@ -684,23 +684,23 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
StreamObserver<StreamingOutputCallRequest> requestObserver
|
StreamObserver<StreamingOutputCallRequest> requestObserver
|
||||||
= asyncStub.fullDuplexCall(responseObserver);
|
= asyncStub.fullDuplexCall(responseObserver);
|
||||||
requestObserver.onNext(requests[0]);
|
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);
|
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
|
||||||
assertMessageEquals(goldenResponses[0], (Messages.StreamingOutputCallResponse) response);
|
assertMessageEquals(goldenResponses[0], (Messages.StreamingOutputCallResponse) response);
|
||||||
// Initiate graceful shutdown.
|
// Initiate graceful shutdown.
|
||||||
channel.shutdown();
|
channel.shutdown();
|
||||||
// The previous ping-pong could have raced with the shutdown, but this one certainly shouldn't.
|
// The previous ping-pong could have raced with the shutdown, but this one certainly shouldn't.
|
||||||
requestObserver.onNext(requests[1]);
|
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);
|
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
|
||||||
assertMessageEquals(goldenResponses[1], (Messages.StreamingOutputCallResponse) response);
|
assertMessageEquals(goldenResponses[1], (Messages.StreamingOutputCallResponse) response);
|
||||||
requestObserver.onNext(requests[2]);
|
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);
|
assertTrue(response instanceof Messages.StreamingOutputCallResponse);
|
||||||
assertMessageEquals(goldenResponses[2], (Messages.StreamingOutputCallResponse) response);
|
assertMessageEquals(goldenResponses[2], (Messages.StreamingOutputCallResponse) response);
|
||||||
requestObserver.onCompleted();
|
requestObserver.onCompleted();
|
||||||
assertEquals(responseObserver.magicTailResponse,
|
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. */
|
/** Sends an rpc to an unimplemented method on the server. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue