diff options
author | 2018-02-28 16:05:49 -0800 | |
---|---|---|
committer | 2018-02-28 16:07:54 -0800 | |
commit | f82731f65a286e2a72948eb32549324bb74bd32b (patch) | |
tree | 65067dc2916a73220a986b4043283d9a55dc40a6 /src/test | |
parent | 20f35b448b5d9d04ba366d74d6bf4c7100d91b63 (diff) |
Verifying result read with retries in the remote execute unit test.
The current behavior is already correct, just adding a test to make sure we retry reads as we should.
TESTED=the unit test
RELNOTES: None
PiperOrigin-RevId: 187398578
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java index be7a4e5bda..49ee7cddee 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java @@ -63,6 +63,7 @@ import com.google.devtools.remoteexecution.v1test.ExecutionGrpc.ExecutionImplBas import com.google.devtools.remoteexecution.v1test.FindMissingBlobsRequest; import com.google.devtools.remoteexecution.v1test.FindMissingBlobsResponse; import com.google.devtools.remoteexecution.v1test.GetActionResultRequest; +import com.google.devtools.remoteexecution.v1test.OutputFile; import com.google.devtools.remoteexecution.v1test.RequestMetadata; import com.google.longrunning.Operation; import com.google.protobuf.Any; @@ -503,10 +504,12 @@ public class GrpcRemoteExecutionClientTest { (numErrors-- <= 0 ? Status.NOT_FOUND : Status.UNAVAILABLE).asRuntimeException()); } }); + final Digest resultDigest = DIGEST_UTIL.compute("bla".getBytes(UTF_8)); final ActionResult actionResult = ActionResult.newBuilder() .setStdoutRaw(ByteString.copyFromUtf8("stdout")) .setStderrRaw(ByteString.copyFromUtf8("stderr")) + .addOutputFiles(OutputFile.newBuilder().setPath("foo").setDigest(resultDigest).build()) .build(); final String opName = "operations/xyz"; @@ -678,6 +681,26 @@ public class GrpcRemoteExecutionClientTest { .thenAnswer(blobWriteAnswerError()) // Error on the input file. .thenAnswer(blobWriteAnswerError()) // Error on the input file again. .thenAnswer(blobWriteAnswer("xyz".getBytes(UTF_8))); // Upload input file successfully. + Mockito.doAnswer( + invocationOnMock -> { + @SuppressWarnings("unchecked") + StreamObserver<ReadResponse> responseObserver = + (StreamObserver<ReadResponse>) invocationOnMock.getArguments()[1]; + responseObserver.onError(Status.INTERNAL.asRuntimeException()); // Will retry. + return null; + }) + .doAnswer( + invocationOnMock -> { + @SuppressWarnings("unchecked") + StreamObserver<ReadResponse> responseObserver = + (StreamObserver<ReadResponse>) invocationOnMock.getArguments()[1]; + responseObserver.onNext( + ReadResponse.newBuilder().setData(ByteString.copyFromUtf8("bla")).build()); + responseObserver.onCompleted(); + return null; + }) + .when(mockByteStreamImpl) + .read(Mockito.<ReadRequest>anyObject(), Mockito.<StreamObserver<ReadResponse>>anyObject()); serviceRegistry.addService(mockByteStreamImpl); SpawnResult result = client.exec(simpleSpawn, simplePolicy); @@ -692,6 +715,8 @@ public class GrpcRemoteExecutionClientTest { Mockito.verify(mockWatcherImpl, Mockito.times(4)) .watch( Mockito.<Request>anyObject(), Mockito.<StreamObserver<ChangeBatch>>anyObject()); + Mockito.verify(mockByteStreamImpl, Mockito.times(2)) + .read(Mockito.<ReadRequest>anyObject(), Mockito.<StreamObserver<ReadResponse>>anyObject()); } @Test |