|
@@ -8,27 +8,31 @@
|
|
|
|
|
|
package org.elasticsearch.repositories.azure;
|
|
|
|
|
|
-import static org.hamcrest.Matchers.blankOrNullString;
|
|
|
-import static org.hamcrest.Matchers.equalTo;
|
|
|
-import static org.hamcrest.Matchers.not;
|
|
|
-
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.util.Collection;
|
|
|
-
|
|
|
+import com.azure.storage.blob.BlobContainerClient;
|
|
|
+import com.azure.storage.blob.BlobServiceClient;
|
|
|
+import com.azure.storage.blob.models.BlobStorageException;
|
|
|
import org.elasticsearch.action.ActionRunnable;
|
|
|
import org.elasticsearch.action.support.PlainActionFuture;
|
|
|
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
+import org.elasticsearch.common.UUIDs;
|
|
|
+import org.elasticsearch.common.blobstore.BlobContainer;
|
|
|
import org.elasticsearch.common.settings.MockSecureSettings;
|
|
|
import org.elasticsearch.common.settings.SecureSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.common.unit.ByteSizeUnit;
|
|
|
+import org.elasticsearch.common.unit.ByteSizeValue;
|
|
|
import org.elasticsearch.plugins.Plugin;
|
|
|
import org.elasticsearch.repositories.AbstractThirdPartyRepositoryTestCase;
|
|
|
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
|
|
|
|
|
-import com.azure.storage.blob.BlobContainerClient;
|
|
|
-import com.azure.storage.blob.BlobServiceClient;
|
|
|
-import com.azure.storage.blob.models.BlobStorageException;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+import static org.hamcrest.Matchers.blankOrNullString;
|
|
|
+import static org.hamcrest.Matchers.equalTo;
|
|
|
+import static org.hamcrest.Matchers.not;
|
|
|
|
|
|
public class AzureStorageCleanupThirdPartyTests extends AbstractThirdPartyRepositoryTestCase {
|
|
|
|
|
@@ -78,6 +82,7 @@ public class AzureStorageCleanupThirdPartyTests extends AbstractThirdPartyReposi
|
|
|
.setSettings(Settings.builder()
|
|
|
.put("container", System.getProperty("test.azure.container"))
|
|
|
.put("base_path", System.getProperty("test.azure.base"))
|
|
|
+ .put("max_single_part_upload_size", new ByteSizeValue(1, ByteSizeUnit.MB))
|
|
|
).get();
|
|
|
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
|
|
if (Strings.hasText(System.getProperty("test.azure.sas_token"))) {
|
|
@@ -111,4 +116,18 @@ public class AzureStorageCleanupThirdPartyTests extends AbstractThirdPartyReposi
|
|
|
}));
|
|
|
future.actionGet();
|
|
|
}
|
|
|
+
|
|
|
+ public void testMultiBlockUpload() throws Exception {
|
|
|
+ final BlobStoreRepository repo = getRepository();
|
|
|
+ // The configured threshold for this test suite is 1mb
|
|
|
+ final int blobSize = ByteSizeUnit.MB.toIntBytes(2);
|
|
|
+ PlainActionFuture<Void> future = PlainActionFuture.newFuture();
|
|
|
+ repo.threadPool().generic().execute(ActionRunnable.run(future, () -> {
|
|
|
+ final BlobContainer blobContainer = repo.blobStore().blobContainer(repo.basePath().add("large_write"));
|
|
|
+ blobContainer.writeBlob(UUIDs.base64UUID(),
|
|
|
+ new ByteArrayInputStream(randomByteArrayOfLength(blobSize)), blobSize, false);
|
|
|
+ blobContainer.delete();
|
|
|
+ }));
|
|
|
+ future.get();
|
|
|
+ }
|
|
|
}
|