@Test
  public void testConcurrentLocatorStartup() throws Exception {
    List<AvailablePort.Keeper> portKeepers =
        AvailablePortHelper.getRandomAvailableTCPPortKeepers(4);
    StringBuilder sb = new StringBuilder(100);
    for (int i = 0; i < portKeepers.size(); i++) {
      AvailablePort.Keeper keeper = portKeepers.get(i);
      sb.append("localhost[").append(keeper.getPort()).append("]");
      if (i < portKeepers.size() - 1) {
        sb.append(',');
      }
    }
    String locators = sb.toString();

    Properties dsProps = getClusterProperties(locators, "false");

    List<AsyncInvocation<Object>> asyncInvocations = new ArrayList<>(portKeepers.size());

    for (int i = 0; i < portKeepers.size(); i++) {
      AvailablePort.Keeper keeper = portKeepers.get(i);
      int port = keeper.getPort();
      keeper.release();
      AsyncInvocation<Object> startLocator = getVM(i).invokeAsync("start locator " + i, () -> {
        DUnitBlackboard blackboard = getBlackboard();
        blackboard.signalGate("" + port);
        blackboard.waitForGate("startLocators", 5, MINUTES);
        startLocatorBase(dsProps, port);
        assertTrue(isSystemConnected());
        System.out.println("Locator startup completed");
      });
      asyncInvocations.add(startLocator);
      getBlackboard().waitForGate("" + port, 5, MINUTES);
    }

    getBlackboard().signalGate("startLocators");
    int expectedCount = asyncInvocations.size() - 1;
    for (AsyncInvocation<Object> asyncInvocation : asyncInvocations) {
      asyncInvocation.await();
    }
    for (int i = 0; i < asyncInvocations.size(); i++) {
      assertTrue(getVM(i).invoke("assert all in same cluster", () -> CacheFactory
          .getAnyInstance().getDistributedSystem().getAllOtherMembers().size() == expectedCount));
    }
  }
Tests starting one locator in a remote VM and having multiple members of the distributed system
join it. This ensures that members start up okay, and that handling of a stopped locator is
correct. It then restarts the locator to demonstrate that it can connect to and function as the
group coordinator
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java