From 4763abc3764042323efc30844b5b16a8e20fca02 Mon Sep 17 00:00:00 2001 From: buchgr Date: Wed, 30 Aug 2017 14:37:21 +0200 Subject: remote: support timeouts PiperOrigin-RevId: 166981977 --- .../build/lib/remote/RemoteSpawnRunnerTest.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/test/java/com/google/devtools') 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.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 { -- cgit v1.2.3