|
60 | 60 | import static org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest.Metric.FS;
|
61 | 61 | import static org.opensearch.core.common.util.CollectionUtils.iterableAsArrayList;
|
62 | 62 | import static org.hamcrest.Matchers.contains;
|
| 63 | +import static org.hamcrest.Matchers.containsString; |
63 | 64 | import static org.hamcrest.Matchers.equalTo;
|
64 | 65 | import static org.hamcrest.Matchers.greaterThan;
|
65 | 66 | import static org.hamcrest.Matchers.is;
|
@@ -789,6 +790,47 @@ public void testDefaultShardPreference() throws Exception {
|
789 | 790 | }
|
790 | 791 | }
|
791 | 792 |
|
| 793 | + public void testRestoreSearchableSnapshotWithIndexStoreTypeThrowsException() throws Exception { |
| 794 | + final String snapshotName = "test-snap"; |
| 795 | + final String repoName = "test-repo"; |
| 796 | + final String indexName1 = "test-idx-1"; |
| 797 | + final int numReplicasIndex1 = randomIntBetween(1, 4); |
| 798 | + final Client client = client(); |
| 799 | + |
| 800 | + internalCluster().ensureAtLeastNumDataNodes(numReplicasIndex1 + 1); |
| 801 | + createIndexWithDocsAndEnsureGreen(numReplicasIndex1, 100, indexName1); |
| 802 | + |
| 803 | + createRepositoryWithSettings(null, repoName); |
| 804 | + takeSnapshot(client, snapshotName, repoName, indexName1); |
| 805 | + deleteIndicesAndEnsureGreen(client, indexName1); |
| 806 | + |
| 807 | + internalCluster().ensureAtLeastNumSearchNodes(numReplicasIndex1 + 1); |
| 808 | + |
| 809 | + // set "index.store.type" to "remote_snapshot" in index settings of restore API and assert appropriate exception with error message |
| 810 | + // is thrown. |
| 811 | + final SnapshotRestoreException error = expectThrows( |
| 812 | + SnapshotRestoreException.class, |
| 813 | + () -> client.admin() |
| 814 | + .cluster() |
| 815 | + .prepareRestoreSnapshot(repoName, snapshotName) |
| 816 | + .setRenamePattern("(.+)") |
| 817 | + .setRenameReplacement("$1-copy") |
| 818 | + .setIndexSettings( |
| 819 | + Settings.builder() |
| 820 | + .put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), RestoreSnapshotRequest.StorageType.REMOTE_SNAPSHOT) |
| 821 | + ) |
| 822 | + .setWaitForCompletion(true) |
| 823 | + .execute() |
| 824 | + .actionGet() |
| 825 | + ); |
| 826 | + assertThat( |
| 827 | + error.getMessage(), |
| 828 | + containsString( |
| 829 | + "cannot restore remote snapshot with index settings \"index.store.type\" set to \"remote_snapshot\". Instead use \"storage_type\": \"remote_snapshot\" as argument to restore." |
| 830 | + ) |
| 831 | + ); |
| 832 | + } |
| 833 | + |
792 | 834 | /**
|
793 | 835 | * Asserts the cache folder count to match the number of shards and the number of indices within the cache folder
|
794 | 836 | * as provided.
|
|
0 commit comments