|
25 | 25 | import com.google.common.collect.ImmutableList;
|
26 | 26 | import com.google.common.collect.ImmutableMap;
|
27 | 27 | import com.google.common.collect.ImmutableSet;
|
| 28 | +import com.google.common.collect.ImmutableSortedMap; |
| 29 | +import com.google.common.util.concurrent.Futures; |
28 | 30 | import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
29 | 31 | import com.google.common.util.concurrent.MoreExecutors;
|
30 | 32 | import com.google.common.util.concurrent.SettableFuture;
|
|
71 | 73 | import java.util.concurrent.Executors;
|
72 | 74 | import java.util.concurrent.TimeUnit;
|
73 | 75 | import org.junit.After;
|
| 76 | +import org.junit.Assert; |
74 | 77 | import org.junit.Before;
|
75 | 78 | import org.junit.Rule;
|
76 | 79 | import org.junit.Test;
|
@@ -435,6 +438,29 @@ public void ensureInputsPresent_interruptedDuringUploadBlobs_cancelInProgressUpl
|
435 | 438 | assertThat(remoteCache.casUploadCache.getFinishedTasks()).hasSize(2);
|
436 | 439 | }
|
437 | 440 |
|
| 441 | + @Test |
| 442 | + public void ensureInputsPresent_uploadFailed_propagateErrors() throws Exception { |
| 443 | + RemoteCacheClient cacheProtocol = spy(new InMemoryCacheClient()); |
| 444 | + doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed"))) |
| 445 | + .when(cacheProtocol) |
| 446 | + .uploadBlob(any(), any(), any()); |
| 447 | + doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed"))) |
| 448 | + .when(cacheProtocol) |
| 449 | + .uploadFile(any(), any(), any()); |
| 450 | + RemoteExecutionCache remoteCache = spy(newRemoteExecutionCache(cacheProtocol)); |
| 451 | + Path path = fs.getPath("/execroot/foo"); |
| 452 | + FileSystemUtils.writeContentAsLatin1(path, "bar"); |
| 453 | + SortedMap<PathFragment, Path> inputs = ImmutableSortedMap.of(PathFragment.create("foo"), path); |
| 454 | + MerkleTree merkleTree = MerkleTree.build(inputs, digestUtil); |
| 455 | + |
| 456 | + IOException e = |
| 457 | + Assert.assertThrows( |
| 458 | + IOException.class, |
| 459 | + () -> remoteCache.ensureInputsPresent(context, merkleTree, ImmutableMap.of(), false)); |
| 460 | + |
| 461 | + assertThat(e).hasMessageThat().contains("upload failed"); |
| 462 | + } |
| 463 | + |
438 | 464 | private InMemoryRemoteCache newRemoteCache() {
|
439 | 465 | RemoteOptions options = Options.getDefaults(RemoteOptions.class);
|
440 | 466 | return new InMemoryRemoteCache(options, digestUtil);
|
|
0 commit comments