Skip to content

Commit 5f22370

Browse files
Fix ShrinkIndexIT (#44214) (#44223)
* Fix ShrinkIndexIT * Move this test suit to cluster scope. Currently, `testShrinkThenSplitWithFailedNode` stops a random node which randomly turns out to be the only shared master node so the cluster reset fails on account of the fact that no shared master node survived. * Closes #44164
1 parent c82d9c5 commit 5f22370

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import static org.hamcrest.Matchers.equalTo;
7676
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
7777

78-
@ESIntegTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/44164")
7978
public class ShrinkIndexIT extends ESIntegTestCase {
8079

8180
@Override
@@ -559,16 +558,15 @@ public void testShrinkCommitsMergeOnIdle() throws Exception {
559558
}
560559

561560
public void testShrinkThenSplitWithFailedNode() throws Exception {
562-
internalCluster().ensureAtLeastNumDataNodes(3);
561+
internalCluster().ensureAtLeastNumDataNodes(2);
562+
final String shrinkNode = internalCluster().startDataOnlyNode();
563563

564564
final int shardCount = between(2, 5);
565565
prepareCreate("original").setSettings(Settings.builder().put(indexSettings())
566566
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
567567
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, shardCount)).get();
568568
client().admin().indices().prepareFlush("original").get();
569569
ensureGreen();
570-
final String shrinkNode
571-
= client().admin().cluster().prepareNodesInfo("data:true").clear().get().getNodes().get(0).getNode().getName();
572570
client().admin().indices().prepareUpdateSettings("original")
573571
.setSettings(Settings.builder()
574572
.put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), shrinkNode)

test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,13 @@ public synchronized void stopRandomNode(final Predicate<Settings> filter) throws
16321632
ensureOpen();
16331633
NodeAndClient nodeAndClient = getRandomNodeAndClient(nc -> filter.test(nc.node.settings()));
16341634
if (nodeAndClient != null) {
1635+
if (nodeAndClient.nodeAndClientId() < sharedNodesSeeds.length && nodeAndClient.isMasterEligible() && autoManageMasterNodes
1636+
&& nodes.values().stream()
1637+
.filter(NodeAndClient::isMasterEligible)
1638+
.filter(n -> n.nodeAndClientId() < sharedNodesSeeds.length)
1639+
.count() == 1) {
1640+
throw new AssertionError("Tried to stop the only master eligible shared node");
1641+
}
16351642
logger.info("Closing filtered random node [{}] ", nodeAndClient.name);
16361643
stopNodesAndClient(nodeAndClient);
16371644
}

0 commit comments

Comments
 (0)