Skip to content

Commit 70a31d9

Browse files
committed
Add basic IT
1 parent 9f62854 commit 70a31d9

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Licensed to Elasticsearch under one or more contributor
11+
* license agreements. See the NOTICE file distributed with
12+
* this work for additional information regarding copyright
13+
* ownership. Elasticsearch licenses this file to you under
14+
* the Apache License, Version 2.0 (the "License"); you may
15+
* not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing,
21+
* software distributed under the License is distributed on an
22+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
* KIND, either express or implied. See the License for the
24+
* specific language governing permissions and limitations
25+
* under the License.
26+
*/
27+
28+
/*
29+
* Modifications Copyright OpenSearch Contributors. See
30+
* GitHub history for details.
31+
*/
32+
33+
package org.opensearch.index;
34+
35+
import org.opensearch.action.admin.indices.get.GetIndexRequest;
36+
import org.opensearch.action.admin.indices.get.GetIndexResponse;
37+
import org.opensearch.cluster.metadata.IndexMetadata;
38+
import org.opensearch.common.settings.Settings;
39+
import org.opensearch.core.index.Index;
40+
import org.opensearch.indices.IndicesService;
41+
import org.opensearch.snapshots.AbstractSnapshotIntegTestCase;
42+
import org.opensearch.test.OpenSearchIntegTestCase;
43+
import org.junit.Before;
44+
45+
import java.util.ArrayList;
46+
import java.util.List;
47+
import java.util.concurrent.ExecutionException;
48+
49+
import static org.opensearch.indices.IndicesService.CLUSTER_DEFAULT_INDEX_MAX_MERGE_AT_ONCE_SETTING;
50+
51+
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 2)
52+
public class ClusterMaxMergesAtOnceIT extends AbstractSnapshotIntegTestCase {
53+
54+
@Override
55+
public Settings indexSettings() {
56+
return Settings.builder().put(super.indexSettings()).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1).build();
57+
}
58+
59+
@Override
60+
@Before
61+
public void setUp() throws Exception {
62+
super.setUp();
63+
internalCluster().startClusterManagerOnlyNode();
64+
}
65+
66+
public void testClusterLevelDefaultUpdatesMergePolicy() throws ExecutionException, InterruptedException {
67+
String clusterManagerName = internalCluster().getClusterManagerName();
68+
List<String> dataNodes = new ArrayList<>(internalCluster().getDataNodeNames());
69+
70+
String indexName = "log-myindex-1";
71+
createIndex(indexName);
72+
ensureYellowAndNoInitializingShards(indexName);
73+
ensureGreen(indexName);
74+
GetIndexResponse getIndexResponse = client(clusterManagerName).admin().indices().getIndex(new GetIndexRequest()).get();
75+
IndicesService indicesService = internalCluster().getInstance(IndicesService.class, randomFrom(dataNodes));
76+
String uuid = getIndexResponse.getSettings().get(indexName).get(IndexMetadata.SETTING_INDEX_UUID);
77+
IndexService indexService = indicesService.indexService(new Index(indexName, uuid));
78+
assertEquals(30, ((OpenSearchTieredMergePolicy) indexService.getIndexSettings().getMergePolicy(true)).getMaxMergeAtOnce());
79+
80+
client(clusterManagerName).admin()
81+
.cluster()
82+
.prepareUpdateSettings()
83+
.setTransientSettings(Settings.builder().put(CLUSTER_DEFAULT_INDEX_MAX_MERGE_AT_ONCE_SETTING.getKey(), 20))
84+
.get();
85+
86+
indexName = "log-myindex-2";
87+
createIndex(indexName);
88+
ensureYellowAndNoInitializingShards(indexName);
89+
ensureGreen(indexName);
90+
getIndexResponse = client(clusterManagerName).admin().indices().getIndex(new GetIndexRequest()).get();
91+
indicesService = internalCluster().getInstance(IndicesService.class, randomFrom(dataNodes));
92+
uuid = getIndexResponse.getSettings().get(indexName).get(IndexMetadata.SETTING_INDEX_UUID);
93+
IndexService newIndexService = indicesService.indexService(new Index(indexName, uuid));
94+
assertEquals(20, ((OpenSearchTieredMergePolicy) indexService.getIndexSettings().getMergePolicy(true)).getMaxMergeAtOnce());
95+
assertEquals(20, ((OpenSearchTieredMergePolicy) newIndexService.getIndexSettings().getMergePolicy(true)).getMaxMergeAtOnce());
96+
}
97+
}

0 commit comments

Comments
 (0)