|
54 | 54 | import static org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest.Metric.FS;
|
55 | 55 | import static org.opensearch.core.common.util.CollectionUtils.iterableAsArrayList;
|
56 | 56 | import static org.hamcrest.Matchers.contains;
|
| 57 | +import static org.hamcrest.Matchers.containsString; |
57 | 58 | import static org.hamcrest.Matchers.equalTo;
|
58 | 59 | import static org.hamcrest.Matchers.greaterThan;
|
59 | 60 | import static org.hamcrest.Matchers.is;
|
@@ -722,6 +723,47 @@ public void testDefaultShardPreference() throws Exception {
|
722 | 723 | }
|
723 | 724 | }
|
724 | 725 |
|
| 726 | + public void testRestoreSearchableSnapshotWithIndexStoreTypeThrowsException() throws Exception { |
| 727 | + final String snapshotName = "test-snap"; |
| 728 | + final String repoName = "test-repo"; |
| 729 | + final String indexName1 = "test-idx-1"; |
| 730 | + final int numReplicasIndex1 = randomIntBetween(1, 4); |
| 731 | + final Client client = client(); |
| 732 | + |
| 733 | + internalCluster().ensureAtLeastNumDataNodes(numReplicasIndex1 + 1); |
| 734 | + createIndexWithDocsAndEnsureGreen(numReplicasIndex1, 100, indexName1); |
| 735 | + |
| 736 | + createRepositoryWithSettings(null, repoName); |
| 737 | + takeSnapshot(client, snapshotName, repoName, indexName1); |
| 738 | + deleteIndicesAndEnsureGreen(client, indexName1); |
| 739 | + |
| 740 | + internalCluster().ensureAtLeastNumSearchNodes(numReplicasIndex1 + 1); |
| 741 | + |
| 742 | + // set "index.store.type" to "remote_snapshot" in index settings of restore API and assert appropriate exception with error message |
| 743 | + // is thrown. |
| 744 | + final SnapshotRestoreException error = expectThrows( |
| 745 | + SnapshotRestoreException.class, |
| 746 | + () -> client.admin() |
| 747 | + .cluster() |
| 748 | + .prepareRestoreSnapshot(repoName, snapshotName) |
| 749 | + .setRenamePattern("(.+)") |
| 750 | + .setRenameReplacement("$1-copy") |
| 751 | + .setIndexSettings( |
| 752 | + Settings.builder() |
| 753 | + .put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), RestoreSnapshotRequest.StorageType.REMOTE_SNAPSHOT) |
| 754 | + ) |
| 755 | + .setWaitForCompletion(true) |
| 756 | + .execute() |
| 757 | + .actionGet() |
| 758 | + ); |
| 759 | + assertThat( |
| 760 | + error.getMessage(), |
| 761 | + containsString( |
| 762 | + "cannot restore remote snapshot with index settings \"index.store.type\" set to \"remote_snapshot\". Instead use \"storage_type\": \"remote_snapshot\" as argument to restore." |
| 763 | + ) |
| 764 | + ); |
| 765 | + } |
| 766 | + |
725 | 767 | /**
|
726 | 768 | * Asserts the cache folder count to match the number of shards and the number of indices within the cache folder
|
727 | 769 | * as provided.
|
|
0 commit comments