diff options
author | 2018-03-16 08:48:13 -0700 | |
---|---|---|
committer | 2018-03-16 08:50:15 -0700 | |
commit | 2732df0202499aff75de38c012fec57ed53a5a30 (patch) | |
tree | cf5d5589c7da831f16af5b60d80c311e77814af4 /src/test/java/com | |
parent | 435fde772d284cdb5b73a88c3c02f7aa94a01ec1 (diff) |
Propagating remote results, including stdout/err, to Bazel on execution timeouts.
The refactoring to have an Exception that contains partial results will also be used in the next CL, in order to propagate and save remote server logs.
RELNOTES: None
PiperOrigin-RevId: 189344465
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java | 31 |
1 files changed, 27 insertions, 4 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 150e759718..98b56706d7 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 @@ -63,6 +63,7 @@ import com.google.devtools.common.options.Options; import com.google.devtools.remoteexecution.v1test.ActionResult; import com.google.devtools.remoteexecution.v1test.ExecuteRequest; import com.google.devtools.remoteexecution.v1test.ExecuteResponse; +import com.google.rpc.Code; import java.io.IOException; import java.time.Duration; import java.util.Collection; @@ -536,7 +537,18 @@ public class RemoteSpawnRunnerTest { ActionResult cachedResult = ActionResult.newBuilder().setExitCode(0).build(); when(cache.getCachedActionResult(any(ActionKey.class))).thenReturn(null); - when(executor.executeRemotely(any(ExecuteRequest.class))).thenThrow(new TimeoutException()); + ExecuteResponse resp = + ExecuteResponse.newBuilder() + .setResult(cachedResult) + .setStatus( + com.google.rpc.Status.newBuilder() + .setCode(Code.DEADLINE_EXCEEDED.getNumber()) + .build()) + .build(); + when(executor.executeRemotely(any(ExecuteRequest.class))) + .thenThrow( + new Retrier.RetryException( + "", 1, new ExecutionStatusException(resp.getStatus(), resp))); Spawn spawn = newSimpleSpawn(); @@ -546,7 +558,7 @@ public class RemoteSpawnRunnerTest { assertThat(res.status()).isEqualTo(Status.TIMEOUT); verify(executor).executeRemotely(any(ExecuteRequest.class)); - verify(cache, never()).download(eq(cachedResult), eq(execRoot), any(FileOutErr.class)); + verify(cache).download(eq(cachedResult), eq(execRoot), any(FileOutErr.class)); } @Test @@ -572,7 +584,18 @@ public class RemoteSpawnRunnerTest { ActionResult cachedResult = ActionResult.newBuilder().setExitCode(0).build(); when(cache.getCachedActionResult(any(ActionKey.class))).thenReturn(null); - when(executor.executeRemotely(any(ExecuteRequest.class))).thenThrow(new TimeoutException()); + ExecuteResponse resp = + ExecuteResponse.newBuilder() + .setResult(cachedResult) + .setStatus( + com.google.rpc.Status.newBuilder() + .setCode(Code.DEADLINE_EXCEEDED.getNumber()) + .build()) + .build(); + when(executor.executeRemotely(any(ExecuteRequest.class))) + .thenThrow( + new Retrier.RetryException( + "", 1, new ExecutionStatusException(resp.getStatus(), resp))); Spawn spawn = newSimpleSpawn(); @@ -582,7 +605,7 @@ public class RemoteSpawnRunnerTest { assertThat(res.status()).isEqualTo(Status.TIMEOUT); verify(executor).executeRemotely(any(ExecuteRequest.class)); - verify(cache, never()).download(eq(cachedResult), eq(execRoot), any(FileOutErr.class)); + verify(cache).download(eq(cachedResult), eq(execRoot), any(FileOutErr.class)); verify(localRunner, never()).exec(eq(spawn), eq(policy)); } |