|
@@ -24,7 +24,6 @@ import com.microsoft.azure.storage.RetryPolicyFactory;
|
|
|
import com.microsoft.azure.storage.blob.BlobRequestOptions;
|
|
|
import com.sun.net.httpserver.HttpExchange;
|
|
|
import com.sun.net.httpserver.HttpServer;
|
|
|
-import org.apache.http.HttpStatus;
|
|
|
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.SuppressForbidden;
|
|
@@ -164,7 +163,7 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
|
|
|
exchange.getResponseHeaders().add("Content-Type", "application/octet-stream");
|
|
|
exchange.getResponseHeaders().add("x-ms-blob-content-length", String.valueOf(bytes.length));
|
|
|
exchange.getResponseHeaders().add("x-ms-blob-type", "blockblob");
|
|
|
- exchange.sendResponseHeaders(HttpStatus.SC_OK, -1);
|
|
|
+ exchange.sendResponseHeaders(RestStatus.OK.getStatus(), -1);
|
|
|
exchange.close();
|
|
|
return;
|
|
|
}
|
|
@@ -176,15 +175,14 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
|
|
|
exchange.getResponseHeaders().add("Content-Type", "application/octet-stream");
|
|
|
exchange.getResponseHeaders().add("x-ms-blob-content-length", String.valueOf(length));
|
|
|
exchange.getResponseHeaders().add("x-ms-blob-type", "blockblob");
|
|
|
- exchange.sendResponseHeaders(HttpStatus.SC_OK, length);
|
|
|
+ exchange.sendResponseHeaders(RestStatus.OK.getStatus(), length);
|
|
|
exchange.getResponseBody().write(bytes, rangeStart, length);
|
|
|
exchange.close();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (randomBoolean()) {
|
|
|
- exchange.sendResponseHeaders(randomFrom(HttpStatus.SC_INTERNAL_SERVER_ERROR, HttpStatus.SC_BAD_GATEWAY,
|
|
|
- HttpStatus.SC_SERVICE_UNAVAILABLE, HttpStatus.SC_GATEWAY_TIMEOUT), -1);
|
|
|
+ TestUtils.sendError(exchange, randomFrom(RestStatus.INTERNAL_SERVER_ERROR, RestStatus.SERVICE_UNAVAILABLE));
|
|
|
}
|
|
|
exchange.close();
|
|
|
});
|
|
@@ -209,7 +207,7 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
|
|
|
if (Objects.deepEquals(bytes, BytesReference.toBytes(body))) {
|
|
|
exchange.sendResponseHeaders(RestStatus.CREATED.getStatus(), -1);
|
|
|
} else {
|
|
|
- exchange.sendResponseHeaders(HttpStatus.SC_BAD_REQUEST, -1);
|
|
|
+ TestUtils.sendError(exchange, RestStatus.BAD_REQUEST);
|
|
|
}
|
|
|
exchange.close();
|
|
|
return;
|
|
@@ -220,8 +218,7 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
|
|
|
Streams.readFully(exchange.getRequestBody(), new byte[randomIntBetween(1, Math.max(1, bytes.length - 1))]);
|
|
|
} else {
|
|
|
Streams.readFully(exchange.getRequestBody());
|
|
|
- exchange.sendResponseHeaders(randomFrom(HttpStatus.SC_INTERNAL_SERVER_ERROR, HttpStatus.SC_BAD_GATEWAY,
|
|
|
- HttpStatus.SC_SERVICE_UNAVAILABLE, HttpStatus.SC_GATEWAY_TIMEOUT), -1);
|
|
|
+ TestUtils.sendError(exchange, randomFrom(RestStatus.INTERNAL_SERVER_ERROR, RestStatus.SERVICE_UNAVAILABLE));
|
|
|
}
|
|
|
}
|
|
|
exchange.close();
|
|
@@ -283,8 +280,7 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
|
|
|
|
|
|
if (randomBoolean()) {
|
|
|
Streams.readFully(exchange.getRequestBody());
|
|
|
- exchange.sendResponseHeaders(randomFrom(HttpStatus.SC_INTERNAL_SERVER_ERROR, HttpStatus.SC_BAD_GATEWAY,
|
|
|
- HttpStatus.SC_SERVICE_UNAVAILABLE, HttpStatus.SC_GATEWAY_TIMEOUT), -1);
|
|
|
+ TestUtils.sendError(exchange, randomFrom(RestStatus.INTERNAL_SERVER_ERROR, RestStatus.SERVICE_UNAVAILABLE));
|
|
|
}
|
|
|
exchange.close();
|
|
|
});
|