|
@@ -24,8 +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.HttpHandler;
|
|
|
-import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
|
|
|
-import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.common.SuppressForbidden;
|
|
|
import org.elasticsearch.common.bytes.BytesArray;
|
|
|
import org.elasticsearch.common.bytes.BytesReference;
|
|
@@ -34,13 +32,10 @@ import org.elasticsearch.common.regex.Regex;
|
|
|
import org.elasticsearch.common.settings.MockSecureSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
|
|
-import org.elasticsearch.common.unit.TimeValue;
|
|
|
-import org.elasticsearch.index.IndexSettings;
|
|
|
import org.elasticsearch.plugins.Plugin;
|
|
|
import org.elasticsearch.repositories.blobstore.ESMockAPIBasedRepositoryIntegTestCase;
|
|
|
import org.elasticsearch.rest.RestStatus;
|
|
|
import org.elasticsearch.rest.RestUtils;
|
|
|
-import org.elasticsearch.test.BackgroundIndexer;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
@@ -58,10 +53,6 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
|
|
-import static org.hamcrest.Matchers.equalTo;
|
|
|
-
|
|
|
@SuppressForbidden(reason = "this test uses a HttpServer to emulate an Azure endpoint")
|
|
|
public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTestCase {
|
|
|
|
|
@@ -73,6 +64,7 @@ public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryInteg
|
|
|
@Override
|
|
|
protected Settings repositorySettings() {
|
|
|
return Settings.builder()
|
|
|
+ .put(super.repositorySettings())
|
|
|
.put(AzureRepository.Repository.CONTAINER_SETTING.getKey(), "container")
|
|
|
.put(AzureStorageSettings.ACCOUNT_SETTING.getKey(), "test")
|
|
|
.build();
|
|
@@ -108,41 +100,6 @@ public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryInteg
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Test the snapshot and restore of an index which has large segments files.
|
|
|
- */
|
|
|
- public void testSnapshotWithLargeSegmentFiles() throws Exception {
|
|
|
- final String repository = createRepository(randomName());
|
|
|
- final String index = "index-no-merges";
|
|
|
- createIndex(index, Settings.builder()
|
|
|
- .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
|
- .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), TimeValue.MINUS_ONE)
|
|
|
- .build());
|
|
|
-
|
|
|
- // the number of documents here dictates the size of the single segment
|
|
|
- // we want a large segment (1Mb+) so that Azure SDK client executes Put Block API calls
|
|
|
- // the size of each uploaded block is defined by Constants.DEFAULT_STREAM_WRITE_IN_BYTES (~4Mb)
|
|
|
- final long nbDocs = randomLongBetween(10_000L, 20_000L);
|
|
|
- try (BackgroundIndexer indexer = new BackgroundIndexer(index, "_doc", client(), (int) nbDocs)) {
|
|
|
- awaitBusy(() -> indexer.totalIndexedDocs() >= nbDocs);
|
|
|
- }
|
|
|
-
|
|
|
- flushAndRefresh(index);
|
|
|
- ForceMergeResponse forceMerge = client().admin().indices().prepareForceMerge(index).setFlush(true).setMaxNumSegments(1).get();
|
|
|
- assertThat(forceMerge.getSuccessfulShards(), equalTo(1));
|
|
|
- assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs);
|
|
|
-
|
|
|
- assertSuccessfulSnapshot(client().admin().cluster().prepareCreateSnapshot(repository, "snapshot")
|
|
|
- .setWaitForCompletion(true).setIndices(index));
|
|
|
-
|
|
|
- assertAcked(client().admin().indices().prepareDelete(index));
|
|
|
-
|
|
|
- assertSuccessfulRestore(client().admin().cluster().prepareRestoreSnapshot(repository, "snapshot").setWaitForCompletion(true));
|
|
|
- ensureGreen(index);
|
|
|
- assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* AzureRepositoryPlugin that allows to set low values for the Azure's client retry policy
|
|
|
* and for BlobRequestOptions#getSingleBlobPutThresholdInBytes().
|