@Test
  public void testLeadAndCoordFailure() throws Exception {
    addIgnoredException("Possible loss of quorum due");

    String locators = hostName + "[" + port1 + "]," + hostName + "[" + port2 + "]";

    Properties properties = getClusterProperties(locators, "true");
    addDSProps(properties);

    Locator locator = Locator.startLocatorAndDS(port1, null, properties);
    system = (InternalDistributedSystem) locator.getDistributedSystem();

    addIgnoredException(ConnectException.class);
    MembershipManagerHelper.inhibitForcedDisconnectLogging(true);
    startLocator(vm3, properties, port2);

    assertThat(MembershipManagerHelper.getLeadMember(system)).isNull();

    DistributedMember mem1 = vm1.invoke(() -> getDistributedMember(properties));
    vm2.invoke(() -> getDistributedMember(properties));
    waitForMemberToBecomeLeadMemberOfDistributedSystem(mem1, system);

    assertThat(system.getDistributedMember())
        .isEqualTo(MembershipManagerHelper.getCoordinator(system));

    // crash the second vm and the locator. Should be okay
    DistributedTestUtils.crashDistributedSystem(vm2);
    vm3.invoke(() -> {
      Locator loc = Locator.getLocator();
      MembershipManagerHelper.crashDistributedSystem(loc.getDistributedSystem());
      loc.stop();
    });

    assertThat(vm1.invoke(LocatorDUnitTest::isSystemConnected))
        .describedAs("Distributed system should not have disconnected").isTrue();

    // ensure quorumLost is properly invoked
    DistributionManager dm = system.getDistributionManager();
    MyMembershipListener listener = new MyMembershipListener();
    dm.addMembershipListener(listener);
    // ensure there is an unordered reader thread for the member
    new HighPriorityAckedMessage().send(Collections.singleton(mem1), false);

    // disconnect the first vm and demonstrate that the third vm and the
    // locator notice the failure and exit
    DistributedTestUtils.crashDistributedSystem(vm1);

    /*
     * This vm is watching vm1, which is watching vm2 which is watching locatorVM. It will take 3
     * (3 member-timeout) milliseconds to detect the full failure and eject the lost members from
     * the view.
     */

    logger.info("waiting for my distributed system to disconnect due to partition detection");

    await().until(() -> !system.isConnected());

    if (system.isConnected()) {
      fail(
          "Distributed system did not disconnect as expected - network partition detection is broken");
    }
    // quorumLost should be invoked if we get a ForcedDisconnect in this situation
    assertThat(listener.quorumLostInvoked).describedAs("expected quorumLost to be invoked")
        .isTrue();
    assertThat(listener.suspectReasons.contains(Connection.INITIATING_SUSPECT_PROCESSING))
        .describedAs("expected suspect processing initiated by TCPConduit").isTrue();
  }
test lead member and coordinator failure with network partition detection enabled. It would be
nice for this test to have more than two "server" vms, to demonstrate that they all exit when
the leader and potential- coordinator both disappear in the loss-correlation-window, but there
are only four vms available for DUnit testing.
<p>
So, we start two locators with admin distributed systems, then start two regular distributed
members.
<p>
We kill the second locator (which is not the view coordinator) and then kill the non-lead
member. That should be okay - the lead and remaining locator continue to run.
<p>
We then kill the lead member and demonstrate that the original locator (which is now the sole
remaining member) shuts itself down.
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java