mirror of https://github.com/grpc/grpc-java.git
Some changes to Android interop test App:
1. Call runTest() for test "all", this is required by some internal code. 2. Turn off proguard for debug App. 3. Catch Throwable when we run the test, so that some errors like OutOfMemoryError would fail the test. 4. Compare message size for veryLargeResponse test, otherwise comparing two message would create two more large byte arrarys.
This commit is contained in:
parent
7ce50f76c7
commit
d238d86a3c
|
|
@ -14,8 +14,7 @@ android {
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
|
|
|
||||||
|
|
@ -171,13 +171,13 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
try {
|
try {
|
||||||
runTest(testCase);
|
runTest(testCase);
|
||||||
return SUCCESS_MESSAGE;
|
return SUCCESS_MESSAGE;
|
||||||
} catch (Exception | AssertionError e) {
|
} catch (Throwable t) {
|
||||||
// Print the stack trace to logcat.
|
// Print the stack trace to logcat.
|
||||||
e.printStackTrace();
|
t.printStackTrace();
|
||||||
// Then print to the error message.
|
// Then print to the error message.
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
t.printStackTrace(new PrintWriter(sw));
|
||||||
return "Failed... : " + e.getMessage() + "\n" + sw.toString();
|
return "Failed... : " + t.getMessage() + "\n" + sw.toString();
|
||||||
} finally {
|
} finally {
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
@ -195,26 +195,26 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
|
|
||||||
public void runTest(String testCase) throws Exception {
|
public void runTest(String testCase) throws Exception {
|
||||||
if ("all".equals(testCase)) {
|
if ("all".equals(testCase)) {
|
||||||
emptyUnary();
|
runTest("empty_unary");
|
||||||
largeUnary();
|
runTest("large_unary");
|
||||||
clientStreaming();
|
runTest("client_streaming");
|
||||||
serverStreaming();
|
runTest("server_streaming");
|
||||||
pingPong();
|
runTest("ping_pong");
|
||||||
emptyStream();
|
runTest("empty_stream");
|
||||||
cancelAfterBegin();
|
runTest("cancel_after_begin");
|
||||||
cancelAfterFirstResponse();
|
runTest("cancel_after_first_response");
|
||||||
fullDuplexCallShouldSucceed();
|
runTest("full_duplex_call_should_succeed");
|
||||||
halfDuplexCallShouldSucceed();
|
runTest("half_duplex_call_should_succeed");
|
||||||
serverStreamingShouldBeFlowControlled();
|
runTest("server_streaming_should_be_flow_controlled");
|
||||||
veryLargeRequest();
|
runTest("very_large_request");
|
||||||
veryLargeResponse();
|
runTest("very_large_response");
|
||||||
deadlineNotExceeded();
|
runTest("deadline_not_exceeded");
|
||||||
deadlineExceeded();
|
runTest("deadline_exceeded");
|
||||||
deadlineExceededServerStreaming();
|
runTest("deadline_exceeded_server_streaming");
|
||||||
unimplementedMethod();
|
runTest("unimplemented_method");
|
||||||
timeoutOnSleepingServer();
|
runTest("timeout_on_sleeping_server");
|
||||||
// This has to be the last one, because it will shut down the channel.
|
// This has to be the last one, because it will shut down the channel.
|
||||||
gracefulShutdown();
|
runTest("graceful_shutdown");
|
||||||
} else if ("empty_unary".equals(testCase)) {
|
} else if ("empty_unary".equals(testCase)) {
|
||||||
emptyUnary();
|
emptyUnary();
|
||||||
} else if ("large_unary".equals(testCase)) {
|
} else if ("large_unary".equals(testCase)) {
|
||||||
|
|
@ -584,7 +584,7 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
goldenResponse.payload.type = Messages.COMPRESSABLE;
|
goldenResponse.payload.type = Messages.COMPRESSABLE;
|
||||||
goldenResponse.payload.body = new byte[unaryPayloadLength()];
|
goldenResponse.payload.body = new byte[unaryPayloadLength()];
|
||||||
|
|
||||||
assertMessageEquals(goldenResponse, blockingStub.unaryCall(request));
|
assertMessageSizeEquals(goldenResponse, blockingStub.unaryCall(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deadlineNotExceeded() {
|
public void deadlineNotExceeded() {
|
||||||
|
|
@ -744,6 +744,11 @@ public final class InteropTester extends AsyncTask<Void, Void, String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void assertMessageSizeEquals(MessageNano expected, MessageNano actual) {
|
||||||
|
assertEquals(expected.getSerializedSize(), actual.getSerializedSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void assertSuccess(StreamRecorder<?> recorder) {
|
private static void assertSuccess(StreamRecorder<?> recorder) {
|
||||||
if (recorder.getError() != null) {
|
if (recorder.getError() != null) {
|
||||||
throw new AssertionError(recorder.getError());
|
throw new AssertionError(recorder.getError());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue