Skip to content

Commit 04a5b43

Browse files
committed
Remove testWriteBlobWithExceptionThrownAtClosingTime
Reverts the test added in #123505 - this is not behaviour on which we rely any more, and it does not apply with SDKv2 anyway.
1 parent 95cf145 commit 04a5b43

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/S3BlobContainerRetriesTests.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import org.apache.http.HttpStatus;
2424
import org.apache.logging.log4j.Level;
25-
import org.apache.lucene.index.CorruptIndexException;
26-
import org.apache.lucene.store.AlreadyClosedException;
2725
import org.elasticsearch.ExceptionsHelper;
2826
import org.elasticsearch.cluster.metadata.RepositoryMetadata;
2927
import org.elasticsearch.common.BackoffPolicy;
@@ -85,7 +83,6 @@
8583
import java.util.concurrent.atomic.AtomicBoolean;
8684
import java.util.concurrent.atomic.AtomicInteger;
8785
import java.util.concurrent.atomic.AtomicLong;
88-
import java.util.concurrent.atomic.AtomicReference;
8986
import java.util.function.IntConsumer;
9087
import java.util.regex.Pattern;
9188

@@ -343,57 +340,6 @@ public void testWriteBlobWithReadTimeouts() {
343340
assertThat(exception.getCause().getCause().getMessage().toLowerCase(Locale.ROOT), containsString("read timed out"));
344341
}
345342

346-
/**
347-
* 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
348-
* to S3, swallowing any exception thrown at closing time.
349-
*/
350-
public void testWriteBlobWithExceptionThrownAtClosingTime() throws Exception {
351-
var maxRetries = randomInt(3);
352-
var blobLength = randomIntBetween(1, 4096 * 3);
353-
var blobName = getTestName().toLowerCase(Locale.ROOT);
354-
var blobContainer = createBlobContainer(maxRetries, null, true, null, null);
355-
356-
var uploadedBytes = new AtomicReference<BytesReference>();
357-
httpServer.createContext(downloadStorageEndpoint(blobContainer, blobName), exchange -> {
358-
var requestComponents = parseRequest(exchange);
359-
if (requestComponents.isPutObjectRequest()) {
360-
var body = Streams.readFully(exchange.getRequestBody());
361-
if (uploadedBytes.compareAndSet(null, body)) {
362-
exchange.sendResponseHeaders(HttpStatus.SC_OK, -1);
363-
exchange.close();
364-
return;
365-
}
366-
}
367-
exchange.sendResponseHeaders(HttpStatus.SC_BAD_REQUEST, -1);
368-
exchange.close();
369-
});
370-
371-
final byte[] bytes = randomByteArrayOfLength(blobLength);
372-
373-
var exceptionThrown = new AtomicBoolean();
374-
blobContainer.writeBlobAtomic(randomPurpose(), blobName, new FilterInputStream(new ByteArrayInputStream(bytes)) {
375-
@Override
376-
public void close() throws IOException {
377-
if (exceptionThrown.compareAndSet(false, true)) {
378-
switch (randomInt(3)) {
379-
case 0:
380-
throw new CorruptIndexException("simulated", blobName);
381-
case 1:
382-
throw new AlreadyClosedException("simulated");
383-
case 2:
384-
throw new RuntimeException("simulated");
385-
case 3:
386-
default:
387-
throw new IOException("simulated");
388-
}
389-
}
390-
}
391-
}, blobLength, true);
392-
393-
assertThat(exceptionThrown.get(), is(true));
394-
assertArrayEquals(bytes, BytesReference.toBytes(uploadedBytes.get()));
395-
}
396-
397343
public void testWriteLargeBlob() throws Exception {
398344
final boolean useTimeout = rarely();
399345
final TimeValue readTimeout = useTimeout ? TimeValue.timeValueMillis(randomIntBetween(100, 500)) : null;

0 commit comments

Comments
 (0)