|
18 | 18 |
|
19 | 19 | import org.apache.http.HttpStatus; |
20 | 20 | import org.apache.logging.log4j.Level; |
21 | | -import org.apache.lucene.index.CorruptIndexException; |
22 | | -import org.apache.lucene.store.AlreadyClosedException; |
23 | 21 | import org.elasticsearch.ExceptionsHelper; |
24 | 22 | import org.elasticsearch.cluster.metadata.RepositoryMetadata; |
25 | 23 | import org.elasticsearch.common.BackoffPolicy; |
|
81 | 79 | import java.util.Objects; |
82 | 80 | import java.util.OptionalInt; |
83 | 81 | import java.util.Set; |
84 | | -import java.util.concurrent.atomic.AtomicBoolean; |
85 | 82 | import java.util.concurrent.atomic.AtomicInteger; |
86 | 83 | import java.util.concurrent.atomic.AtomicLong; |
87 | | -import java.util.concurrent.atomic.AtomicReference; |
88 | 84 | import java.util.function.IntConsumer; |
89 | 85 | import java.util.regex.Pattern; |
90 | 86 |
|
@@ -327,58 +323,6 @@ public void testWriteBlobWithReadTimeouts() { |
327 | 323 | assertThat(exception.getCause().getCause().getMessage().toLowerCase(Locale.ROOT), containsString("read timed out")); |
328 | 324 | } |
329 | 325 |
|
330 | | - /** |
331 | | - * This test shows that the AWS SDKv1 defers the closing of the InputStream used to upload a blob after the HTTP request has been sent |
332 | | - * to S3, swallowing any exception thrown at closing time. |
333 | | - */ |
334 | | - @AwaitsFix(bugUrl = "TODO NOMERGE") |
335 | | - public void testWriteBlobWithExceptionThrownAtClosingTime() throws Exception { |
336 | | - var maxRetries = randomInt(3); |
337 | | - var blobLength = randomIntBetween(1, 4096 * 3); |
338 | | - var blobName = getTestName().toLowerCase(Locale.ROOT); |
339 | | - var blobContainer = createBlobContainer(maxRetries, null, true, null, null); |
340 | | - |
341 | | - var uploadedBytes = new AtomicReference<BytesReference>(); |
342 | | - httpServer.createContext(downloadStorageEndpoint(blobContainer, blobName), exchange -> { |
343 | | - var requestComponents = S3HttpHandler.parseRequestComponents(S3HttpHandler.getRawRequestString(exchange)); |
344 | | - if ("PUT".equals(requestComponents.method()) && requestComponents.query().isEmpty()) { |
345 | | - var body = Streams.readFully(exchange.getRequestBody()); |
346 | | - if (uploadedBytes.compareAndSet(null, body)) { |
347 | | - exchange.sendResponseHeaders(HttpStatus.SC_OK, -1); |
348 | | - exchange.close(); |
349 | | - return; |
350 | | - } |
351 | | - } |
352 | | - exchange.sendResponseHeaders(HttpStatus.SC_BAD_REQUEST, -1); |
353 | | - exchange.close(); |
354 | | - }); |
355 | | - |
356 | | - final byte[] bytes = randomByteArrayOfLength(blobLength); |
357 | | - |
358 | | - var exceptionThrown = new AtomicBoolean(); |
359 | | - blobContainer.writeBlobAtomic(randomPurpose(), blobName, new FilterInputStream(new ByteArrayInputStream(bytes)) { |
360 | | - @Override |
361 | | - public void close() throws IOException { |
362 | | - if (exceptionThrown.compareAndSet(false, true)) { |
363 | | - switch (randomInt(3)) { |
364 | | - case 0: |
365 | | - throw new CorruptIndexException("simulated", blobName); |
366 | | - case 1: |
367 | | - throw new AlreadyClosedException("simulated"); |
368 | | - case 2: |
369 | | - throw new RuntimeException("simulated"); |
370 | | - case 3: |
371 | | - default: |
372 | | - throw new IOException("simulated"); |
373 | | - } |
374 | | - } |
375 | | - } |
376 | | - }, blobLength, true); |
377 | | - |
378 | | - assertThat(exceptionThrown.get(), is(true)); |
379 | | - assertArrayEquals(bytes, BytesReference.toBytes(uploadedBytes.get())); |
380 | | - } |
381 | | - |
382 | 326 | @AwaitsFix(bugUrl = "TODO NOMERGE") |
383 | 327 | public void testWriteLargeBlob() throws Exception { |
384 | 328 | final boolean useTimeout = rarely(); |
|
0 commit comments