interop-testing: client compressed tests without probing (#4279)

This commit is contained in:
Arnout Engelen 2018-03-29 00:51:03 +02:00 committed by Eric Gribkoff
parent 5af2515f3e
commit 03a00aa8cf
4 changed files with 45 additions and 20 deletions

View File

@ -390,7 +390,7 @@ public abstract class AbstractInteropTest {
* Tests client per-message compression for unary calls. The Java API does not support inspecting * Tests client per-message compression for unary calls. The Java API does not support inspecting
* a message's compression level, so this is primarily intended to run against a gRPC C++ server. * a message's compression level, so this is primarily intended to run against a gRPC C++ server.
*/ */
public void clientCompressedUnary() throws Exception { public void clientCompressedUnary(boolean probe) throws Exception {
assumeEnoughMemory(); assumeEnoughMemory();
final SimpleRequest expectCompressedRequest = final SimpleRequest expectCompressedRequest =
SimpleRequest.newBuilder() SimpleRequest.newBuilder()
@ -409,15 +409,17 @@ public abstract class AbstractInteropTest {
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[314159]))) .setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[314159])))
.build(); .build();
// Send a non-compressed message with expectCompress=true. Servers supporting this test case if (probe) {
// should return INVALID_ARGUMENT. // Send a non-compressed message with expectCompress=true. Servers supporting this test case
try { // should return INVALID_ARGUMENT.
blockingStub.unaryCall(expectCompressedRequest); try {
fail("expected INVALID_ARGUMENT"); blockingStub.unaryCall(expectCompressedRequest);
} catch (StatusRuntimeException e) { fail("expected INVALID_ARGUMENT");
assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatus().getCode()); } catch (StatusRuntimeException e) {
assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatus().getCode());
}
assertStatsTrace("grpc.testing.TestService/UnaryCall", Status.Code.INVALID_ARGUMENT);
} }
assertStatsTrace("grpc.testing.TestService/UnaryCall", Status.Code.INVALID_ARGUMENT);
assertEquals( assertEquals(
goldenResponse, blockingStub.withCompression("gzip").unaryCall(expectCompressedRequest)); goldenResponse, blockingStub.withCompression("gzip").unaryCall(expectCompressedRequest));
@ -557,7 +559,7 @@ public abstract class AbstractInteropTest {
* inspecting a message's compression level, so this is primarily intended to run against a gRPC * inspecting a message's compression level, so this is primarily intended to run against a gRPC
* C++ server. * C++ server.
*/ */
public void clientCompressedStreaming() throws Exception { public void clientCompressedStreaming(boolean probe) throws Exception {
final StreamingInputCallRequest expectCompressedRequest = final StreamingInputCallRequest expectCompressedRequest =
StreamingInputCallRequest.newBuilder() StreamingInputCallRequest.newBuilder()
.setExpectCompressed(BoolValue.newBuilder().setValue(true)) .setExpectCompressed(BoolValue.newBuilder().setValue(true))
@ -575,13 +577,15 @@ public abstract class AbstractInteropTest {
StreamObserver<StreamingInputCallRequest> requestObserver = StreamObserver<StreamingInputCallRequest> requestObserver =
asyncStub.streamingInputCall(responseObserver); asyncStub.streamingInputCall(responseObserver);
// Send a non-compressed message with expectCompress=true. Servers supporting this test case if (probe) {
// should return INVALID_ARGUMENT. // Send a non-compressed message with expectCompress=true. Servers supporting this test case
requestObserver.onNext(expectCompressedRequest); // should return INVALID_ARGUMENT.
responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS); requestObserver.onNext(expectCompressedRequest);
Throwable e = responseObserver.getError(); responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS);
assertNotNull("expected INVALID_ARGUMENT", e); Throwable e = responseObserver.getError();
assertEquals(Status.INVALID_ARGUMENT.getCode(), Status.fromThrowable(e).getCode()); assertNotNull("expected INVALID_ARGUMENT", e);
assertEquals(Status.INVALID_ARGUMENT.getCode(), Status.fromThrowable(e).getCode());
}
// Start a new stream // Start a new stream
responseObserver = StreamRecorder.create(); responseObserver = StreamRecorder.create();

View File

@ -26,9 +26,13 @@ public enum TestCases {
CACHEABLE_UNARY("cacheable unary rpc sent using GET"), CACHEABLE_UNARY("cacheable unary rpc sent using GET"),
LARGE_UNARY("single request and (large) response"), LARGE_UNARY("single request and (large) response"),
CLIENT_COMPRESSED_UNARY("client compressed unary request"), CLIENT_COMPRESSED_UNARY("client compressed unary request"),
CLIENT_COMPRESSED_UNARY_NOPROBE(
"client compressed unary request (skip initial feature-probing request)"),
SERVER_COMPRESSED_UNARY("server compressed unary response"), SERVER_COMPRESSED_UNARY("server compressed unary response"),
CLIENT_STREAMING("request streaming with single response"), CLIENT_STREAMING("request streaming with single response"),
CLIENT_COMPRESSED_STREAMING("client per-message compression on stream"), CLIENT_COMPRESSED_STREAMING("client per-message compression on stream"),
CLIENT_COMPRESSED_STREAMING_NOPROBE(
"client per-message compression on stream (skip initial feature-probing request)"),
SERVER_STREAMING("single request with response streaming"), SERVER_STREAMING("single request with response streaming"),
SERVER_COMPRESSED_STREAMING("server per-message compression on stream"), SERVER_COMPRESSED_STREAMING("server per-message compression on stream"),
PING_PONG("full-duplex ping-pong streaming"), PING_PONG("full-duplex ping-pong streaming"),

View File

@ -221,7 +221,11 @@ public class TestServiceClient {
break; break;
case CLIENT_COMPRESSED_UNARY: case CLIENT_COMPRESSED_UNARY:
tester.clientCompressedUnary(); tester.clientCompressedUnary(true);
break;
case CLIENT_COMPRESSED_UNARY_NOPROBE:
tester.clientCompressedUnary(false);
break; break;
case SERVER_COMPRESSED_UNARY: case SERVER_COMPRESSED_UNARY:
@ -233,7 +237,11 @@ public class TestServiceClient {
break; break;
case CLIENT_COMPRESSED_STREAMING: case CLIENT_COMPRESSED_STREAMING:
tester.clientCompressedStreaming(); tester.clientCompressedStreaming(true);
break;
case CLIENT_COMPRESSED_STREAMING_NOPROBE:
tester.clientCompressedStreaming(false);
break; break;
case SERVER_STREAMING: case SERVER_STREAMING:

View File

@ -65,12 +65,21 @@ public class TestCasesTest {
"timeout_on_sleeping_server" "timeout_on_sleeping_server"
}; };
assertEquals(testCases.length, TestCases.values().length); // additional test cases
String[] additionalTestCases = {
"client_compressed_unary_noprobe",
"client_compressed_streaming_noprobe"
};
assertEquals(testCases.length + additionalTestCases.length, TestCases.values().length);
Set<TestCases> testCaseSet = new HashSet<TestCases>(testCases.length); Set<TestCases> testCaseSet = new HashSet<TestCases>(testCases.length);
for (String testCase : testCases) { for (String testCase : testCases) {
testCaseSet.add(TestCases.fromString(testCase)); testCaseSet.add(TestCases.fromString(testCase));
} }
for (String testCase : additionalTestCases) {
testCaseSet.add(TestCases.fromString(testCase));
}
assertEquals(TestCases.values().length, testCaseSet.size()); assertEquals(TestCases.values().length, testCaseSet.size());
} }