@Test
  public void testMultipleLocatorsRestartingAtSameTime() {
    String locators =
        hostName + "[" + port1 + "]," + hostName + "[" + port2 + "]," + hostName + "[" + port3
            + "]";

    Properties dsProps = getBasicProperties(locators);
    dsProps.setProperty(LOG_LEVEL, logger.getLevel().name());
    dsProps.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
    addDSProps(dsProps);

    startLocator(vm0, dsProps, port1);
    startLocator(vm1, dsProps, port2);
    startLocator(vm2, dsProps, port3);

    vm3.invoke(() -> {
      getConnectedDistributedSystem(dsProps);
    });
    vm4.invoke(() -> {
      getConnectedDistributedSystem(dsProps);
    });

    system = getConnectedDistributedSystem(dsProps);

    await().until(() -> system.getDM().getViewMembers().size() == 6);

    // three applications plus
    assertThat(system.getDM().getViewMembers().size()).isEqualTo(6);

    vm0.invoke(LocatorDUnitTest::stopLocator);
    vm1.invoke(LocatorDUnitTest::stopLocator);
    vm2.invoke(LocatorDUnitTest::stopLocator);

    await()
        .until(() -> system.getDM().getDistribution().getView().size() <= 3);

    String newLocators = hostName + "[" + port2 + "]," + hostName + "[" + port3 + "]";
    dsProps.setProperty(LOCATORS, newLocators);

    InternalDistributedMember currentCoordinator = getCreator();
    DistributedMember vm3ID = vm3.invoke(() -> system.getDM().getDistributionManagerId());
    assertEquals(
        "View is " + system.getDM().getDistribution().getView() + " and vm3's ID is "
            + vm3ID,
        vm3ID, vm3.invoke(
            () -> system.getDistributionManager().getDistribution().getView().getCreator()));

    startLocator(vm1, dsProps, port2);
    startLocator(vm2, dsProps, port3);

    await()
        .until(() -> !getCreator().equals(currentCoordinator)
            && system.getDM().getAllHostedLocators().size() == 2);

    vm1.invoke("waitUntilLocatorBecomesCoordinator", this::waitUntilLocatorBecomesCoordinator);
    vm2.invoke("waitUntilLocatorBecomesCoordinator", this::waitUntilLocatorBecomesCoordinator);
    vm3.invoke("waitUntilLocatorBecomesCoordinator", this::waitUntilLocatorBecomesCoordinator);
    vm4.invoke("waitUntilLocatorBecomesCoordinator", this::waitUntilLocatorBecomesCoordinator);

    int netViewId = vm1.invoke("Checking ViewCreator", () -> getView().getViewId());
    assertThat((int) vm2.invoke("checking ViewID", () -> getView().getViewId()))
        .isEqualTo(netViewId);
    assertThat((int) vm3.invoke("checking ViewID", () -> getView().getViewId()))
        .isEqualTo(netViewId);
    assertThat((int) vm4.invoke("checking ViewID", () -> getView().getViewId()))
        .isEqualTo(netViewId);
    assertThat((boolean) vm4
        .invoke("Checking ViewCreator",
            () -> system.getDistributedMember().equals(getView().getCreator()))).isFalse();
    // Given the start up order of servers, this server is the elder server
    assertFalse(vm3
        .invoke("Checking ViewCreator",
            () -> system.getDistributedMember().equals(getView().getCreator())));
    if (vm1.invoke(() -> system.getDistributedMember().equals(getView().getCreator()))) {
      assertThat((boolean) vm2.invoke("Checking ViewCreator",
          () -> system.getDistributedMember().equals(getView().getCreator())))
              .isFalse();
    } else {
      assertThat((boolean) vm2.invoke("Checking ViewCreator",
          () -> system.getDistributedMember().equals(getView().getCreator())))
              .isTrue();
    }
  }
Tests starting multiple locators at the same time and ensuring that the locators end up only
have 1 master. GEODE-870
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java