|
36 | 36 |
|
37 | 37 | import static org.hamcrest.Matchers.equalTo; |
38 | 38 | import static org.hamcrest.Matchers.greaterThan; |
| 39 | +import static org.mockito.ArgumentMatchers.any; |
39 | 40 | import static org.mockito.Mockito.doReturn; |
| 41 | +import static org.mockito.Mockito.doThrow; |
40 | 42 | import static org.mockito.Mockito.mock; |
41 | 43 |
|
42 | 44 | @ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class) |
@@ -234,6 +236,39 @@ public void testDownloadFailsAsyncDownload() throws Exception { |
234 | 236 | MatcherAssert.assertThat(fileCache.usage(), equalTo(0L)); |
235 | 237 | } |
236 | 238 |
|
| 239 | + public void testDownloadFailsAsyncDownloadException() throws Exception { |
| 240 | + mockExceptionWhileReading(); |
| 241 | + doThrow(new IllegalArgumentException("Invalid thread pool")).when(threadPool).executor(ThreadPool.Names.REMOTE_RECOVERY); |
| 242 | + List<BlobFetchRequest.BlobPart> blobParts = new ArrayList<>(); |
| 243 | + blobParts.add(new BlobFetchRequest.BlobPart("failure-blob", 0, EIGHT_MB)); |
| 244 | + expectThrows(IllegalArgumentException.class, () -> { |
| 245 | + BlobFetchRequest blobFetchRequest = BlobFetchRequest.builder() |
| 246 | + .fileName("file") |
| 247 | + .directory(directory) |
| 248 | + .blobParts(blobParts) |
| 249 | + .build(); |
| 250 | + transferManager.fetchBlobAsync(blobFetchRequest); |
| 251 | + }); |
| 252 | + MatcherAssert.assertThat(fileCache.activeUsage(), equalTo(0L)); |
| 253 | + } |
| 254 | + |
| 255 | + public void testDownloadFailsAsyncDownloadExceptionFileCache() throws Exception { |
| 256 | + mockExceptionWhileReading(); |
| 257 | + |
| 258 | + doThrow(new IOException("Invalid key")).when(fileCache).compute(any(), any()); |
| 259 | + List<BlobFetchRequest.BlobPart> blobParts = new ArrayList<>(); |
| 260 | + blobParts.add(new BlobFetchRequest.BlobPart("failure-blob", 0, EIGHT_MB)); |
| 261 | + expectThrows(IOException.class, () -> { |
| 262 | + BlobFetchRequest blobFetchRequest = BlobFetchRequest.builder() |
| 263 | + .fileName("file") |
| 264 | + .directory(directory) |
| 265 | + .blobParts(blobParts) |
| 266 | + .build(); |
| 267 | + transferManager.fetchBlobAsync(blobFetchRequest); |
| 268 | + }); |
| 269 | + MatcherAssert.assertThat(fileCache.activeUsage(), equalTo(0L)); |
| 270 | + } |
| 271 | + |
237 | 272 | public void testFetchesToDifferentBlobsDoNotBlockOnEachOther() throws Exception { |
238 | 273 | // Mock a call for a blob that will block until the latch is released, |
239 | 274 | // then start the fetch for that blob on a separate thread |
|
0 commit comments