|
22 | 22 | import java.util.stream.Collectors;
|
23 | 23 |
|
24 | 24 | import static org.elasticsearch.cluster.coordination.AbstractCoordinatorTestCase.Cluster.DEFAULT_DELAY_VARIABILITY;
|
| 25 | +import static org.elasticsearch.cluster.coordination.AbstractCoordinatorTestCase.Cluster.EXTREME_DELAY_VARIABILITY; |
25 | 26 | import static org.elasticsearch.cluster.coordination.Coordinator.Mode.CANDIDATE;
|
26 | 27 | import static org.elasticsearch.cluster.coordination.ElectionSchedulerFactory.ELECTION_INITIAL_TIMEOUT_SETTING;
|
27 | 28 | import static org.elasticsearch.cluster.coordination.Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION;
|
@@ -488,4 +489,35 @@ public void testClusterUUIDLogging() {
|
488 | 489 | mockAppender.assertAllExpectationsMatched();
|
489 | 490 | }
|
490 | 491 | }
|
| 492 | + |
| 493 | + public void testDiscoveryUsesNodesFromLastClusterState() { |
| 494 | + |
| 495 | + // This test only applies when using proper majority-based voting configurations. If we permit non-overlapping configurations then |
| 496 | + // the isolated node can form a one-node cluster when it is healed, and the other nodes won't know be able to discover it without a |
| 497 | + // proper discovery config since it wasn't in their last cluster states. |
| 498 | + // |
| 499 | + // (if we wanted this to work without a proper discovery config then we could e.g. record the master's publish address in the |
| 500 | + // heartbeat blob, but we can assume that discovery is properly configured when using an atomic-register coordinator, and therefore |
| 501 | + // there's no need for this extra complexity) |
| 502 | + |
| 503 | + try (Cluster cluster = new Cluster(randomIntBetween(3, 5))) { |
| 504 | + cluster.runRandomly(); |
| 505 | + cluster.stabilise(); |
| 506 | + |
| 507 | + final Cluster.ClusterNode partitionedNode = cluster.getAnyNode(); |
| 508 | + if (randomBoolean()) { |
| 509 | + logger.info("--> blackholing {}", partitionedNode); |
| 510 | + partitionedNode.blackhole(); |
| 511 | + } else { |
| 512 | + logger.info("--> disconnecting {}", partitionedNode); |
| 513 | + partitionedNode.disconnect(); |
| 514 | + } |
| 515 | + cluster.setEmptySeedHostsList(); |
| 516 | + cluster.stabilise(); |
| 517 | + |
| 518 | + partitionedNode.heal(); |
| 519 | + cluster.runRandomly(false, true, EXTREME_DELAY_VARIABILITY); |
| 520 | + cluster.stabilise(); |
| 521 | + } |
| 522 | + } |
491 | 523 | }
|
0 commit comments