|
|
@@ -21,6 +21,7 @@ package org.elasticsearch.snapshots;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.action.ActionFuture;
|
|
|
import org.elasticsearch.action.ActionListener;
|
|
|
+import org.elasticsearch.action.ActionRunnable;
|
|
|
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
|
@@ -44,6 +45,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
+import org.elasticsearch.common.util.BigArrays;
|
|
|
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
|
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
@@ -57,6 +59,7 @@ import org.elasticsearch.repositories.RepositoryData;
|
|
|
import org.elasticsearch.repositories.ShardGenerations;
|
|
|
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
|
|
import org.elasticsearch.repositories.blobstore.BlobStoreTestUtil;
|
|
|
+import org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat;
|
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
|
import org.elasticsearch.snapshots.mockstore.MockRepository;
|
|
|
import org.elasticsearch.test.ESIntegTestCase;
|
|
|
@@ -321,7 +324,8 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
|
|
|
final CreateSnapshotResponse createSnapshotResponse = clusterAdmin()
|
|
|
.prepareCreateSnapshot(repoName, oldVersionSnapshot).setIndices("does-not-exist-for-sure-*")
|
|
|
.setWaitForCompletion(true).get();
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), is(0));
|
|
|
+ final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
|
+ assertThat(snapshotInfo.totalShards(), is(0));
|
|
|
|
|
|
logger.info("--> writing downgraded RepositoryData for repository metadata version [{}]", version);
|
|
|
final RepositoryData repositoryData = getRepositoryData(repoName);
|
|
|
@@ -336,6 +340,17 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
|
|
|
BytesReference.toBytes(BytesReference.bytes(
|
|
|
downgradedRepoData.snapshotsToXContent(XContentFactory.jsonBuilder(), version))),
|
|
|
StandardOpenOption.TRUNCATE_EXISTING);
|
|
|
+ final SnapshotInfo downgradedSnapshotInfo = SnapshotInfo.fromXContentInternal(
|
|
|
+ JsonXContent.jsonXContent.createParser(
|
|
|
+ NamedXContentRegistry.EMPTY,
|
|
|
+ DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
|
|
+ Strings.toString(snapshotInfo, ChecksumBlobStoreFormat.SNAPSHOT_ONLY_FORMAT_PARAMS)
|
|
|
+ .replace(String.valueOf(Version.CURRENT.id), String.valueOf(version.id))));
|
|
|
+ final BlobStoreRepository blobStoreRepository = getRepositoryOnMaster(repoName);
|
|
|
+ PlainActionFuture.get(f -> blobStoreRepository.threadPool().generic().execute(ActionRunnable.run(f, () ->
|
|
|
+ BlobStoreRepository.SNAPSHOT_FORMAT.write(downgradedSnapshotInfo,
|
|
|
+ blobStoreRepository.blobStore().blobContainer(blobStoreRepository.basePath()), snapshotInfo.snapshotId().getUUID(),
|
|
|
+ randomBoolean(), internalCluster().getCurrentMasterNodeInstance(BigArrays.class)))));
|
|
|
return oldVersionSnapshot;
|
|
|
}
|
|
|
|