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

    Properties properties = new Properties();
    properties.setProperty(MCAST_PORT, "0");
    properties.setProperty(LOCATORS, locators);
    properties.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
    properties.setProperty(DISABLE_AUTO_RECONNECT, "true");
    properties.setProperty(MEMBER_TIMEOUT, "2000");
    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();
    });

    SerializableRunnable crashSystem = new SerializableRunnable("Crash system") {
      @Override
      public void run() {
        addIgnoredException("service failure");
        addIgnoredException("Possible loss of quorum");
        addIgnoredException(ForcedDisconnectException.class);

        hook = new TestHook();
        MembershipManagerHelper.addTestHook(system, hook);
        try {
          MembershipManagerHelper.crashDistributedSystem(system);
        } finally {
          hook.reset();
        }
      }
    };

    assertNull(MembershipManagerHelper.getLeadMember(system));

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

    assertEquals(mem1, MembershipManagerHelper.getLeadMember(system));

    assertEquals(system.getDistributedMember(), MembershipManagerHelper.getCoordinator(system));

    assertTrue("Distributed system should not have disconnected", isSystemConnected());

    assertTrue("Distributed system should not have disconnected",
        vm2.invoke(LocatorDUnitTest::isSystemConnected));

    assertTrue("Distributed system should not have disconnected",
        vm3.invoke(LocatorDUnitTest::isSystemConnected));

    vm2.invokeAsync(crashSystem);

    // request member removal for first peer from second peer.
    vm2.invoke(new SerializableRunnable("Request Member Removal") {

      @Override
      public void run() {
        Distribution mmgr = MembershipManagerHelper.getDistribution(system);

        // check for shutdown cause in Distribution. Following call should
        // throw DistributedSystemDisconnectedException which should have cause as
        // ForceDisconnectException.
        await().until(() -> !mmgr.getMembership().isConnected());
        await().untilAsserted(() -> {
          Throwable cause = mmgr.getShutdownCause();
          assertThat(cause).isInstanceOf(ForcedDisconnectException.class);
        });
        try (IgnoredException i = addIgnoredException("Membership: requesting removal of")) {
          mmgr.requestMemberRemoval((InternalDistributedMember) mem1, "test reasons");
          fail("It should have thrown exception in requestMemberRemoval");
        } catch (DistributedSystemDisconnectedException e) {
          // expected
          assertThat(e.getCause()).isInstanceOf(ForcedDisconnectException.class);
        } finally {
          hook.reset();
        }
      }
    });
  }
test lead member failure and normal coordinator shutdown with network partition detection
enabled.
<p>
Start one 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