diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java | 25 |
1 files changed, 21 insertions, 4 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 c6758c185d..e8b1313fd9 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 @@ -26,6 +26,8 @@ import com.google.bytestream.ByteStreamProto.WriteResponse; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.ListeningScheduledExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ActionInputFileCache; import com.google.devtools.build.lib.actions.ActionInputHelper; @@ -94,8 +96,11 @@ import java.time.Duration; import java.util.Collection; import java.util.Set; import java.util.SortedMap; +import java.util.concurrent.Executors; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -127,6 +132,7 @@ public class GrpcRemoteExecutionClientTest { private RemoteSpawnRunner client; private FileOutErr outErr; private Server fakeServer; + private static ListeningScheduledExecutorService retryService; private final SpawnExecutionContext simplePolicy = new SpawnExecutionContext() { @@ -182,6 +188,11 @@ public class GrpcRemoteExecutionClientTest { } }; + @BeforeClass + public static void beforeEverything() { + retryService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1)); + } + @Before public final void setUp() throws Exception { String fakeServerName = "fake server for " + getClass(); @@ -238,7 +249,8 @@ public class GrpcRemoteExecutionClientTest { outErr = new FileOutErr(stdout, stderr); RemoteOptions options = Options.getDefaults(RemoteOptions.class); RemoteRetrier retrier = - new RemoteRetrier(options, RemoteRetrier.RETRIABLE_GRPC_ERRORS, Retrier.ALLOW_ALL_CALLS); + new RemoteRetrier( + options, RemoteRetrier.RETRIABLE_GRPC_ERRORS, retryService, Retrier.ALLOW_ALL_CALLS); Channel channel = InProcessChannelBuilder.forName(fakeServerName).directExecutor().build(); GrpcRemoteExecutor executor = new GrpcRemoteExecutor(channel, null, options.remoteTimeout, retrier); @@ -268,6 +280,11 @@ public class GrpcRemoteExecutionClientTest { fakeServer.awaitTermination(); } + @AfterClass + public static void afterEverything() { + retryService.shutdownNow(); + } + @Test public void cacheHit() throws Exception { serviceRegistry.addService( @@ -909,10 +926,10 @@ public class GrpcRemoteExecutionClientTest { @Override public void read(ReadRequest request, StreamObserver<ReadResponse> responseObserver) { - // First read is a cache miss, next read succeeds. + // First read is a retriable error, next read succeeds. if (first) { first = false; - responseObserver.onError(Status.NOT_FOUND.asRuntimeException()); + responseObserver.onError(Status.UNAVAILABLE.asRuntimeException()); } else { responseObserver.onNext( ReadResponse.newBuilder().setData(ByteString.copyFromUtf8("stdout")).build()); @@ -968,7 +985,7 @@ public class GrpcRemoteExecutionClientTest { SpawnResult result = client.exec(simpleSpawn, simplePolicy); assertThat(result.setupSuccess()).isTrue(); assertThat(result.exitCode()).isEqualTo(0); - assertThat(result.isCacheHit()).isFalse(); + assertThat(result.isCacheHit()).isTrue(); assertThat(outErr.outAsLatin1()).isEqualTo("stdout"); } } |