Skip to content

Commit 034c765

Browse files
authored
[Zen2] Reduce cluster scope in NodeDisconnectIT (#36168)
This test suite can stop all the shared master-eligible nodes, which breaks the cluster since any non-shared master-eligible nodes are stopped first in the reset process between tests. Since this test suite can leave the cluster in this somewhat broken state, it seems best that it uses a new cluster for each test.
1 parent c01aecb commit 034c765

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

server/src/test/java/org/elasticsearch/client/transport/NodeDisconnectIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.elasticsearch.common.settings.Settings;
2323
import org.elasticsearch.common.transport.TransportAddress;
2424
import org.elasticsearch.test.ESIntegTestCase;
25+
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
26+
import org.elasticsearch.test.ESIntegTestCase.Scope;
2527
import org.elasticsearch.transport.MockTransportClient;
2628
import org.elasticsearch.transport.TransportService;
2729

@@ -33,6 +35,7 @@
3335

3436
import static org.elasticsearch.client.transport.TransportClient.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL;
3537

38+
@ClusterScope(scope = Scope.TEST)
3639
public class NodeDisconnectIT extends ESIntegTestCase {
3740

3841
public void testNotifyOnDisconnect() throws IOException {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
165165
import static org.hamcrest.Matchers.not;
166166
import static org.junit.Assert.assertThat;
167+
import static org.junit.Assert.assertTrue;
167168
import static org.junit.Assert.fail;
168169

169170
/**
@@ -1070,6 +1071,9 @@ private synchronized void reset(boolean wipeData) throws IOException {
10701071
wipePendingDataDirectories();
10711072
}
10721073

1074+
assertTrue("expected at least one master-eligible node left in " + nodes,
1075+
nodes.isEmpty() || nodes.values().stream().anyMatch(NodeAndClient::isMasterEligible));
1076+
10731077
final int prevNodeCount = nodes.size();
10741078

10751079
// start any missing node

0 commit comments

Comments
 (0)