|
@@ -32,13 +32,13 @@ import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotR
|
|
|
import org.elasticsearch.action.admin.cluster.snapshots.status.*;
|
|
|
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
|
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
|
|
+import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
|
|
import org.elasticsearch.action.count.CountResponse;
|
|
|
import org.elasticsearch.client.Client;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
|
|
import org.elasticsearch.cluster.metadata.SnapshotMetaData;
|
|
|
import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider;
|
|
|
-import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
@@ -53,7 +53,7 @@ import org.junit.Test;
|
|
|
import java.io.File;
|
|
|
|
|
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
|
|
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
|
|
import static org.hamcrest.Matchers.*;
|
|
|
|
|
|
@Slow
|
|
@@ -227,8 +227,8 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
|
|
|
|
|
logger.info("--> delete test template");
|
|
|
assertThat(client.admin().indices().prepareDeleteTemplate("test-template").get().isAcknowledged(), equalTo(true));
|
|
|
- ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices(Strings.EMPTY_ARRAY).get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(false));
|
|
|
+ GetIndexTemplatesResponse getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> restore cluster state");
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
@@ -236,8 +236,9 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
|
logger.info("--> check that template is restored");
|
|
|
- clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices(Strings.EMPTY_ARRAY).get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(true));
|
|
|
+ getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateExists(getIndexTemplatesResponse, "test-template");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -266,24 +267,24 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
|
|
|
|
|
logger.info("--> delete test template");
|
|
|
immutableCluster().wipeTemplates("test-template");
|
|
|
- ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices().get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(false));
|
|
|
+ GetIndexTemplatesResponse getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> try restoring cluster state from snapshot without global state");
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-no-global-state").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
|
logger.info("--> check that template wasn't restored");
|
|
|
- clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices().get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(false));
|
|
|
+ getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> restore cluster state");
|
|
|
restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-with-global-state").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
|
logger.info("--> check that template is restored");
|
|
|
- clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices().get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(true));
|
|
|
+ getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateExists(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
createIndex("test-idx");
|
|
|
ensureGreen();
|
|
@@ -304,8 +305,8 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
|
|
logger.info("--> delete test template and index ");
|
|
|
immutableCluster().wipeIndices("test-idx");
|
|
|
immutableCluster().wipeTemplates("test-template");
|
|
|
- clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices().get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(false));
|
|
|
+ getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> try restoring index and cluster state from snapshot without global state");
|
|
|
restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-no-global-state-with-index").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
@@ -314,8 +315,8 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
|
|
|
|
|
ensureGreen();
|
|
|
logger.info("--> check that template wasn't restored but index was");
|
|
|
- clusterStateResponse = client.admin().cluster().prepareState().setRoutingTable(false).setNodes(false).setIndexTemplates("test-template").setIndices().get();
|
|
|
- assertThat(clusterStateResponse.getState().getMetaData().templates().containsKey("test-template"), equalTo(false));
|
|
|
+ getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates().get();
|
|
|
+ assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
assertThat(client.prepareCount("test-idx").get().getCount(), equalTo(100L));
|
|
|
|
|
|
}
|