Skip to content

Commit 12d0fec

Browse files
committed
Randomize errors
1 parent 22c267a commit 12d0fec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/fixtures/s3-fixture/src/main/java/fixture/s3/S3HttpHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.logging.LogManager;
2626
import org.elasticsearch.logging.Logger;
2727
import org.elasticsearch.rest.RestStatus;
28+
import org.elasticsearch.test.ESTestCase;
2829
import org.elasticsearch.test.fixture.HttpHeaderParser;
2930

3031
import java.io.IOException;
@@ -397,7 +398,13 @@ public void handle(final HttpExchange exchange) throws IOException {
397398
return;
398399
}
399400

400-
resultBuilder.append(errorBuilder.toString()).append("</DeleteResult>");
401+
if (ESTestCase.randomBoolean()) {
402+
// In practice the real S3 doesn't report errors for blobs that did not exist (this is the desired outcome after a
403+
// delete operation anyway) but this isn't documented, so other implementations may return these errors and can
404+
// legitimately expect Elasticsearch to handle them correctly.
405+
resultBuilder.append(errorBuilder);
406+
}
407+
resultBuilder.append("</DeleteResult>");
401408
byte[] response = resultBuilder.toString().getBytes(StandardCharsets.UTF_8);
402409
exchange.getResponseHeaders().add("Content-Type", "application/xml");
403410
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length);

0 commit comments

Comments
 (0)