|
47 | 47 | import org.opensearch.node.Node;
|
48 | 48 | import org.opensearch.repositories.fs.FsRepository;
|
49 | 49 | import org.hamcrest.MatcherAssert;
|
| 50 | +import org.junit.After; |
50 | 51 |
|
51 | 52 | import java.io.IOException;
|
52 | 53 | import java.nio.file.Files;
|
|
62 | 63 |
|
63 | 64 | import static org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest.Metric.FS;
|
64 | 65 | import static org.opensearch.core.common.util.CollectionUtils.iterableAsArrayList;
|
| 66 | +import static org.opensearch.index.store.remote.filecache.FileCacheSettings.DATA_TO_FILE_CACHE_SIZE_RATIO_SETTING; |
| 67 | +import static org.opensearch.test.NodeRoles.clusterManagerOnlyNode; |
| 68 | +import static org.opensearch.test.NodeRoles.dataNode; |
| 69 | +import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; |
65 | 70 | import static org.hamcrest.Matchers.contains;
|
66 | 71 | import static org.hamcrest.Matchers.containsString;
|
67 | 72 | import static org.hamcrest.Matchers.equalTo;
|
@@ -939,6 +944,52 @@ public void testRelocateSearchableSnapshotIndex() throws Exception {
|
939 | 944 | assertSearchableSnapshotIndexDirectoryExistence(searchNode2, index, false);
|
940 | 945 | }
|
941 | 946 |
|
| 947 | + public void testCreateSearchableSnapshotWithSpecifiedRemoteDataRatio() throws Exception { |
| 948 | + final String snapshotName = "test-snap"; |
| 949 | + final String repoName = "test-repo"; |
| 950 | + final String indexName1 = "test-idx-1"; |
| 951 | + final String restoredIndexName1 = indexName1 + "-copy"; |
| 952 | + final String indexName2 = "test-idx-2"; |
| 953 | + final String restoredIndexName2 = indexName2 + "-copy"; |
| 954 | + final int numReplicasIndex1 = 1; |
| 955 | + final int numReplicasIndex2 = 1; |
| 956 | + |
| 957 | + Settings clusterManagerNodeSettings = clusterManagerOnlyNode(); |
| 958 | + internalCluster().startNodes(2, clusterManagerNodeSettings); |
| 959 | + Settings dateNodeSettings = dataNode(); |
| 960 | + internalCluster().startNodes(2, dateNodeSettings); |
| 961 | + createIndexWithDocsAndEnsureGreen(numReplicasIndex1, 100, indexName1); |
| 962 | + createIndexWithDocsAndEnsureGreen(numReplicasIndex2, 100, indexName2); |
| 963 | + |
| 964 | + final Client client = client(); |
| 965 | + assertAcked( |
| 966 | + client.admin() |
| 967 | + .cluster() |
| 968 | + .prepareUpdateSettings() |
| 969 | + .setTransientSettings(Settings.builder().put(DATA_TO_FILE_CACHE_SIZE_RATIO_SETTING.getKey(), 5)) |
| 970 | + ); |
| 971 | + |
| 972 | + createRepositoryWithSettings(null, repoName); |
| 973 | + takeSnapshot(client, snapshotName, repoName, indexName1, indexName2); |
| 974 | + |
| 975 | + internalCluster().ensureAtLeastNumSearchNodes(Math.max(numReplicasIndex1, numReplicasIndex2) + 1); |
| 976 | + restoreSnapshotAndEnsureGreen(client, snapshotName, repoName); |
| 977 | + |
| 978 | + assertDocCount(restoredIndexName1, 100L); |
| 979 | + assertDocCount(restoredIndexName2, 100L); |
| 980 | + assertIndexDirectoryDoesNotExist(restoredIndexName1, restoredIndexName2); |
| 981 | + } |
| 982 | + |
| 983 | + @After |
| 984 | + public void cleanup() throws Exception { |
| 985 | + assertAcked( |
| 986 | + client().admin() |
| 987 | + .cluster() |
| 988 | + .prepareUpdateSettings() |
| 989 | + .setTransientSettings(Settings.builder().putNull(DATA_TO_FILE_CACHE_SIZE_RATIO_SETTING.getKey())) |
| 990 | + ); |
| 991 | + } |
| 992 | + |
942 | 993 | private void assertSearchableSnapshotIndexDirectoryExistence(String nodeName, Index index, boolean exists) throws Exception {
|
943 | 994 | final Node node = internalCluster().getInstance(Node.class, nodeName);
|
944 | 995 | final ShardId shardId = new ShardId(index, 0);
|
|
0 commit comments