|
21 | 21 | import org.elasticsearch.core.TimeValue; |
22 | 22 | import org.elasticsearch.test.ESIntegTestCase; |
23 | 23 | import org.elasticsearch.test.disruption.BlockMasterServiceOnMaster; |
24 | | -import org.elasticsearch.test.disruption.IntermittentLongGCDisruption; |
25 | 24 | import org.elasticsearch.test.disruption.NetworkDisruption; |
26 | 25 | import org.elasticsearch.test.disruption.NetworkDisruption.TwoPartitions; |
27 | 26 | import org.elasticsearch.test.disruption.ServiceDisruptionScheme; |
28 | | -import org.elasticsearch.test.disruption.SingleNodeDisruption; |
29 | 27 | import org.elasticsearch.xcontent.XContentType; |
30 | 28 |
|
31 | | -import java.util.ArrayList; |
32 | | -import java.util.HashSet; |
33 | 29 | import java.util.List; |
34 | | -import java.util.Set; |
35 | 30 |
|
36 | 31 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
37 | 32 | import static org.hamcrest.Matchers.equalTo; |
38 | | -import static org.hamcrest.Matchers.not; |
39 | 33 |
|
40 | 34 | /** |
41 | 35 | * Tests relating to the loss of the master. |
42 | 36 | */ |
43 | 37 | @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) |
44 | 38 | public class MasterDisruptionIT extends AbstractDisruptionTestCase { |
45 | 39 |
|
46 | | - /** |
47 | | - * Test that cluster recovers from a long GC on master that causes other nodes to elect a new one |
48 | | - */ |
49 | | - public void testMasterNodeGCs() throws Exception { |
50 | | - List<String> nodes = startCluster(3); |
51 | | - // NOTE: this assume must happen after starting the cluster, so that cleanup will have something to cleanup. |
52 | | - assumeFalse("jdk20 removed thread suspend/resume", Runtime.version().feature() >= 20); |
53 | | - |
54 | | - String oldMasterNode = internalCluster().getMasterName(); |
55 | | - // a very long GC, but it's OK as we remove the disruption when it has had an effect |
56 | | - SingleNodeDisruption masterNodeDisruption = new IntermittentLongGCDisruption(random(), oldMasterNode, 100, 200, 30000, 60000); |
57 | | - internalCluster().setDisruptionScheme(masterNodeDisruption); |
58 | | - masterNodeDisruption.startDisrupting(); |
59 | | - |
60 | | - Set<String> oldNonMasterNodesSet = new HashSet<>(nodes); |
61 | | - oldNonMasterNodesSet.remove(oldMasterNode); |
62 | | - |
63 | | - List<String> oldNonMasterNodes = new ArrayList<>(oldNonMasterNodesSet); |
64 | | - |
65 | | - logger.info("waiting for nodes to de-elect master [{}]", oldMasterNode); |
66 | | - for (String node : oldNonMasterNodesSet) { |
67 | | - assertDifferentMaster(node, oldMasterNode); |
68 | | - } |
69 | | - |
70 | | - logger.info("waiting for nodes to elect a new master"); |
71 | | - ensureStableCluster(2, oldNonMasterNodes.get(0)); |
72 | | - |
73 | | - // restore GC |
74 | | - masterNodeDisruption.stopDisrupting(); |
75 | | - final TimeValue waitTime = new TimeValue(DISRUPTION_HEALING_OVERHEAD.millis() + masterNodeDisruption.expectedTimeToHeal().millis()); |
76 | | - ensureStableCluster(3, waitTime, false, oldNonMasterNodes.get(0)); |
77 | | - |
78 | | - // make sure all nodes agree on master |
79 | | - String newMaster = internalCluster().getMasterName(); |
80 | | - assertThat(newMaster, not(equalTo(oldMasterNode))); |
81 | | - assertMaster(newMaster, nodes); |
82 | | - } |
83 | | - |
84 | 40 | /** |
85 | 41 | * This test isolates the master from rest of the cluster, waits for a new master to be elected, restores the partition |
86 | 42 | * and verifies that all node agree on the new cluster state |
|
0 commit comments