|
8 | 8 |
|
9 | 9 | package org.opensearch.cluster.routing.allocation.decider; |
10 | 10 |
|
11 | | -import org.apache.lucene.tests.util.LuceneTestCase; |
| 11 | +import org.opensearch.action.admin.indices.flush.FlushRequest; |
12 | 12 | import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest; |
13 | 13 | import org.opensearch.action.support.clustermanager.AcknowledgedResponse; |
14 | 14 | import org.opensearch.cluster.ClusterState; |
|
19 | 19 | import org.opensearch.test.OpenSearchIntegTestCase; |
20 | 20 | import org.junit.Before; |
21 | 21 |
|
| 22 | +import java.util.Arrays; |
22 | 23 | import java.util.HashMap; |
23 | 24 | import java.util.List; |
24 | 25 | import java.util.Map; |
25 | 26 |
|
26 | 27 | import static org.opensearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider.CLUSTER_TOTAL_PRIMARY_SHARDS_PER_NODE_SETTING; |
27 | 28 | import static org.opensearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider.INDEX_TOTAL_PRIMARY_SHARDS_PER_NODE_SETTING; |
28 | 29 |
|
29 | | -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/17693") |
30 | 30 | @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) |
31 | 31 | public class ShardsLimitAllocationDeciderRemoteStoreEnabledIT extends RemoteStoreBaseIntegTestCase { |
32 | 32 | @Before |
@@ -101,6 +101,7 @@ public void testIndexPrimaryShardLimit() throws Exception { |
101 | 101 | assertTrue("No node should have more than 1 primary shard of test1", count <= 1); |
102 | 102 | } |
103 | 103 | }); |
| 104 | + cleanUp(new String[] { "test1", "test2" }); |
104 | 105 | } |
105 | 106 |
|
106 | 107 | public void testUpdatingIndexPrimaryShardLimit() throws Exception { |
@@ -170,6 +171,7 @@ public void testUpdatingIndexPrimaryShardLimit() throws Exception { |
170 | 171 | assertTrue("No node should have more than 1 primary shard of test1", count <= 1); |
171 | 172 | } |
172 | 173 | }); |
| 174 | + cleanUp(new String[] { "test1" }); |
173 | 175 | } |
174 | 176 |
|
175 | 177 | public void testClusterPrimaryShardLimitss() throws Exception { |
@@ -224,6 +226,7 @@ public void testClusterPrimaryShardLimitss() throws Exception { |
224 | 226 | assertTrue("No node should have more than 1 primary shard", count <= 1); |
225 | 227 | } |
226 | 228 | }); |
| 229 | + cleanUp(new String[] { "test1" }); |
227 | 230 | } |
228 | 231 |
|
229 | 232 | public void testCombinedIndexAndClusterPrimaryShardLimits() throws Exception { |
@@ -313,9 +316,27 @@ public void testCombinedIndexAndClusterPrimaryShardLimits() throws Exception { |
313 | 316 | assertTrue("No node should have more than 3 primary shards total", count <= 3); |
314 | 317 | } |
315 | 318 | }); |
| 319 | + cleanUp(new String[] { "test1", "test2" }); |
316 | 320 | } |
317 | 321 |
|
318 | 322 | private void updateClusterSetting(String setting, int value) { |
319 | 323 | client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(setting, value)).get(); |
320 | 324 | } |
| 325 | + |
| 326 | + private void cleanUp(String[] indices) throws Exception { |
| 327 | + logger.info(">>> Starting custom tearDown in ShardsLimitAllocationDeciderRemoteStoreEnabledIT"); |
| 328 | + try { |
| 329 | + // Synchronization: Force flush relevant indices. |
| 330 | + logger.info("Attempting to flush indices {} to help sync remote store before cleanup...", Arrays.toString(indices)); |
| 331 | + |
| 332 | + FlushRequest flushRequest = new FlushRequest(indices); |
| 333 | + flushRequest.force(true); // Force even if no changes detected |
| 334 | + flushRequest.waitIfOngoing(true); // Wait if flush already in progress |
| 335 | + client().admin().indices().flush(flushRequest).actionGet(); // Use actionGet() or get() to wait |
| 336 | + logger.info("Flush request for {} completed.", Arrays.toString(indices)); |
| 337 | + |
| 338 | + } catch (Exception e) { |
| 339 | + logger.error("Exception during pre-teardown synchronization flush: {} - {}", e.getClass().getName(), e.getMessage(), e); |
| 340 | + } |
| 341 | + } |
321 | 342 | } |
0 commit comments