Search in sources :

Example 1 with IntermittentLongGCDisruption

use of org.elasticsearch.test.disruption.IntermittentLongGCDisruption in project elasticsearch by elastic.

the class DiscoveryWithServiceDisruptionsIT method testMasterNodeGCs.

/**
     * Test that cluster recovers from a long GC on master that causes other nodes to elect a new one
     */
public void testMasterNodeGCs() throws Exception {
    List<String> nodes = startCluster(3, -1);
    String oldMasterNode = internalCluster().getMasterName();
    // a very long GC, but it's OK as we remove the disruption when it has had an effect
    SingleNodeDisruption masterNodeDisruption = new IntermittentLongGCDisruption(random(), oldMasterNode, 100, 200, 30000, 60000);
    internalCluster().setDisruptionScheme(masterNodeDisruption);
    masterNodeDisruption.startDisrupting();
    Set<String> oldNonMasterNodesSet = new HashSet<>(nodes);
    oldNonMasterNodesSet.remove(oldMasterNode);
    List<String> oldNonMasterNodes = new ArrayList<>(oldNonMasterNodesSet);
    logger.info("waiting for nodes to de-elect master [{}]", oldMasterNode);
    for (String node : oldNonMasterNodesSet) {
        assertDifferentMaster(node, oldMasterNode);
    }
    logger.info("waiting for nodes to elect a new master");
    ensureStableCluster(2, oldNonMasterNodes.get(0));
    logger.info("waiting for any pinging to stop");
    assertDiscoveryCompleted(oldNonMasterNodes);
    // restore GC
    masterNodeDisruption.stopDisrupting();
    ensureStableCluster(3, new TimeValue(DISRUPTION_HEALING_OVERHEAD.millis() + masterNodeDisruption.expectedTimeToHeal().millis()), false, oldNonMasterNodes.get(0));
    // make sure all nodes agree on master
    String newMaster = internalCluster().getMasterName();
    assertThat(newMaster, not(equalTo(oldMasterNode)));
    assertMaster(newMaster, nodes);
}
Also used : ArrayList(java.util.ArrayList) SingleNodeDisruption(org.elasticsearch.test.disruption.SingleNodeDisruption) IntermittentLongGCDisruption(org.elasticsearch.test.disruption.IntermittentLongGCDisruption) TimeValue(org.elasticsearch.common.unit.TimeValue) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 TimeValue (org.elasticsearch.common.unit.TimeValue)1 IntermittentLongGCDisruption (org.elasticsearch.test.disruption.IntermittentLongGCDisruption)1 SingleNodeDisruption (org.elasticsearch.test.disruption.SingleNodeDisruption)1