aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar buchgr <buchgr@google.com>2017-08-30 14:37:21 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-08-30 18:24:19 +0200
commit4763abc3764042323efc30844b5b16a8e20fca02 (patch)
tree78e0d55fa28091cd503678668df3693532f0167e /src/test/java/com/google/devtools
parentaa0093be3800911f6d0f1ff4564d9eebd24fbeae (diff)
remote: support timeouts
PiperOrigin-RevId: 166981977
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
index b8e4f21ec0..ea1ac727df 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
@@ -383,6 +383,40 @@ public class RemoteSpawnRunnerTest {
verify(executor).executeRemotely(any(ExecuteRequest.class));
}
+ @Test
+ public void testRemoteExecutionTimeout() throws Exception {
+ // If remote execution times out the SpawnResult status should be TIMEOUT.
+
+ RemoteOptions options = Options.getDefaults(RemoteOptions.class);
+ options.remoteLocalFallback = false;
+
+ RemoteSpawnRunner runner =
+ new RemoteSpawnRunner(execRoot, options, localRunner, true, /*cmdlineReporter=*/null,
+ cache, executor);
+
+ ActionResult cachedResult = ActionResult.newBuilder().setExitCode(0).build();
+ when(cache.getCachedActionResult(any(ActionKey.class))).thenReturn(null);
+ when(executor.executeRemotely(any(ExecuteRequest.class))).thenThrow(new TimeoutException());
+
+ Spawn spawn =
+ new SimpleSpawn(
+ new FakeOwner("foo", "bar"),
+ /*arguments=*/ ImmutableList.of(),
+ /*environment=*/ ImmutableMap.of(),
+ /*executionInfo=*/ ImmutableMap.of(),
+ /*inputs=*/ ImmutableList.of(),
+ /*outputs=*/ ImmutableList.<ActionInput>of(),
+ ResourceSet.ZERO);
+
+ SpawnExecutionPolicy policy = new FakeSpawnExecutionPolicy(spawn);
+
+ SpawnResult res = runner.exec(spawn, policy);
+ assertThat(res.status()).isEqualTo(Status.TIMEOUT);
+
+ verify(executor).executeRemotely(any(ExecuteRequest.class));
+ verify(cache, never()).download(eq(cachedResult), eq(execRoot), any(FileOutErr.class));
+ }
+
// TODO(buchgr): Extract a common class to be used for testing.
class FakeSpawnExecutionPolicy implements SpawnExecutionPolicy {