@Test
  public void testLeadFailureAndCoordShutdown() throws Exception {
    String locators = hostName + "[" + port1 + "]," + hostName + "[" + port2 + "]";

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

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

    vm3.invoke(() -> {
      Locator loc = Locator.startLocatorAndDS(port2, null, properties);
      system = (InternalDistributedSystem) loc.getDistributedSystem();
      MembershipManagerHelper.inhibitForcedDisconnectLogging(true);
    });

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

    DistributedMember mem1 = vm1.invoke(() -> getDistributedMember(properties));
    DistributedMember mem2 = vm2.invoke(() -> getDistributedMember(properties));

    assertThat(mem1).isEqualTo(MembershipManagerHelper.getLeadMember(system));

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

    MembershipManagerHelper.inhibitForcedDisconnectLogging(true);

    // crash the lead vm. Should be okay
    vm1.invoke(() -> {
      addIgnoredException("service failure");
      addIgnoredException(ForcedDisconnectException.class);
      MembershipManagerHelper.crashDistributedSystem(system);
    });

    waitUntilTheSystemIsConnected(vm2, vm3);
    // stop the locator normally. This should also be okay
    locator.stop();

    await()
        .until(() -> {
          assertThat(Locator.getLocator()).describedAs("locator is not stopped").isNull();
          return true;
        });

    checkSystemConnectedInVMs(vm2, vm3);

    // the remaining non-locator member should now be the lead member
    assertEquals(
        "This test sometimes fails.  If the log contains "
            + "'failed to collect all ACKs' it is a false failure.",
        mem2, vm2.invoke(LocatorDUnitTest::getLeadMember));

    // disconnect the first vm and demonstrate that the third vm and the
    // locator notice the failure and exit
    vm2.invoke(LocatorDUnitTest::disconnectDistributedSystem);
    vm3.invoke(LocatorDUnitTest::stopLocator);
  }
test lead member failure and normal coordinator shutdown with network partition detection
enabled.
<p>
Start two locators with admin distributed systems, then start two regular distributed members.
<p>
We kill the lead member and demonstrate that the other members continue to operate normally.
<p>
We then shut down the group coordinator and observe the second locator pick up the job and the
remaining member continues to operate normally.
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java