mirror of https://github.com/grpc/grpc-java.git
Split large payload into separate test with higher timeout
Also show more exception info in case the test still fails.
This commit is contained in:
parent
d8fb6f0bad
commit
2cbbd4706a
|
|
@ -31,6 +31,12 @@ dependencies {
|
||||||
|
|
||||||
test {
|
test {
|
||||||
jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath
|
jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath
|
||||||
|
testLogging {
|
||||||
|
exceptionFormat "full"
|
||||||
|
showExceptions true
|
||||||
|
showCauses true
|
||||||
|
showStackTraces true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow execution of test client and server.
|
// Allow execution of test client and server.
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,39 @@ public abstract class AbstractTransportTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 30000)
|
||||||
|
public void veryLargeRequest() throws Exception {
|
||||||
|
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||||
|
.setPayload(Payload.newBuilder()
|
||||||
|
.setType(PayloadType.COMPRESSABLE)
|
||||||
|
.setBody(ByteString.copyFrom(new byte[unaryPayloadLength()])))
|
||||||
|
.setResponseSize(10)
|
||||||
|
.setResponseType(PayloadType.COMPRESSABLE)
|
||||||
|
.build();
|
||||||
|
final SimpleResponse goldenResponse = SimpleResponse.newBuilder()
|
||||||
|
.setPayload(Payload.newBuilder()
|
||||||
|
.setType(PayloadType.COMPRESSABLE)
|
||||||
|
.setBody(ByteString.copyFrom(new byte[10])))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 30000)
|
||||||
|
public void veryLargeResponse() throws Exception {
|
||||||
|
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||||
|
.setResponseSize(unaryPayloadLength())
|
||||||
|
.setResponseType(PayloadType.COMPRESSABLE)
|
||||||
|
.build();
|
||||||
|
final SimpleResponse goldenResponse = SimpleResponse.newBuilder()
|
||||||
|
.setPayload(Payload.newBuilder()
|
||||||
|
.setType(PayloadType.COMPRESSABLE)
|
||||||
|
.setBody(ByteString.copyFrom(new byte[unaryPayloadLength()])))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test(timeout = 10000)
|
||||||
public void exchangeContextUnaryCall() throws Exception {
|
public void exchangeContextUnaryCall() throws Exception {
|
||||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||||
|
|
@ -494,7 +527,7 @@ public abstract class AbstractTransportTest {
|
||||||
AtomicReference<Metadata.Headers> headersCapture = new AtomicReference<Metadata.Headers>();
|
AtomicReference<Metadata.Headers> headersCapture = new AtomicReference<Metadata.Headers>();
|
||||||
stub = MetadataUtils.captureMetadata(stub, headersCapture, trailersCapture);
|
stub = MetadataUtils.captureMetadata(stub, headersCapture, trailersCapture);
|
||||||
|
|
||||||
Assert.assertNotNull(stub.unaryCall(unaryRequest()));
|
Assert.assertNotNull(stub.emptyCall(Empty.getDefaultInstance()));
|
||||||
|
|
||||||
// Assert that our side channel object is echoed back in both headers and trailers
|
// Assert that our side channel object is echoed back in both headers and trailers
|
||||||
Assert.assertEquals(contextValue, headersCapture.get().get(METADATA_KEY));
|
Assert.assertEquals(contextValue, headersCapture.get().get(METADATA_KEY));
|
||||||
|
|
@ -550,16 +583,6 @@ public abstract class AbstractTransportTest {
|
||||||
return 10485760;
|
return 10485760;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SimpleRequest unaryRequest() {
|
|
||||||
SimpleRequest.Builder unaryBuilder = SimpleRequest.newBuilder();
|
|
||||||
unaryBuilder.getPayloadBuilder().setType(PayloadType.COMPRESSABLE);
|
|
||||||
byte[] data = new byte[unaryPayloadLength()];
|
|
||||||
new Random().nextBytes(data);
|
|
||||||
unaryBuilder.getPayloadBuilder().setBody(ByteString.copyFrom(data));
|
|
||||||
unaryBuilder.setResponseSize(10).setResponseType(PayloadType.COMPRESSABLE);
|
|
||||||
return unaryBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void assertSuccess(StreamRecorder<?> recorder) {
|
protected 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