@Test
  public void testIntersectingServerGroups() throws Exception {
    final Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    VM vm3 = host.getVM(3);

    String hostName = NetworkUtils.getServerHostName();
    int locatorPort = vm0.invoke("Start Locator", () -> startLocator(hostName, ""));
    String locators = getLocatorString(hostName, locatorPort);

    int serverPort1 =
        vm1.invoke("Start BridgeServer", () -> startBridgeServer(new String[] {"a"}, locators));
    vm2.invoke("Start BridgeServer", () -> startBridgeServer(new String[] {"a", "b"}, locators));
    vm3.invoke("Start BridgeServer", () -> startBridgeServer(new String[] {"b"}, locators));

    PoolFactoryImpl pf = new PoolFactoryImpl(null);
    pf.addLocator(NetworkUtils.getServerHostName(host), locatorPort);
    pf.setMinConnections(12);
    pf.setSubscriptionEnabled(false);
    pf.setServerGroup("a");
    pf.setIdleTimeout(-1);
    startBridgeClient(pf.getPoolAttributes(), new String[] {REGION_NAME});
    waitForPrefilledConnections(12);

    vm1.invoke("Check Connection Count", () -> checkConnectionCount(6));
    vm2.invoke("Check Connection Count", () -> checkConnectionCount(6));
    vm3.invoke("Check Connection Count", () -> checkConnectionCount(0));

    LogWriterUtils.getLogWriter().info("pool1 prefilled");

    PoolFactoryImpl pf2 = (PoolFactoryImpl) PoolManager.createFactory();
    pf2.init(pf.getPoolAttributes());
    pf2.setServerGroup("b");
    PoolImpl pool2 = (PoolImpl) pf2.create("testPool2");
    waitForPrefilledConnections(12, "testPool2");

    // The load will not be perfect, because we created all of the connections
    // for group A first.
    vm1.invoke("Check Connection Count", () -> checkConnectionCount(6));
    vm2.invoke("Check Connection Count", () -> checkConnectionCount(9));
    vm3.invoke("Check Connection Count", () -> checkConnectionCount(9));

    LogWriterUtils.getLogWriter().info("pool2 prefilled");

    ServerLocation location1 =
        new ServerLocation(NetworkUtils.getServerHostName(host), serverPort1);
    PoolImpl pool1 = (PoolImpl) PoolManager.getAll().get(POOL_NAME);
    Assert.assertEquals("a", pool1.getServerGroup());

    // Use up all of the pooled connections on pool1, and acquire 3 more
    for (int i = 0; i < 15; i++) {
      pool1.acquireConnection();
    }

    LogWriterUtils.getLogWriter().info("aquired 15 connections in pool1");

    // now the load should be equal
    vm1.invoke("Check Connection Count", () -> checkConnectionCount(9));
    vm2.invoke("Check Connection Count", () -> checkConnectionCount(9));
    vm3.invoke("Check Connection Count", () -> checkConnectionCount(9));

    // use up all of the pooled connections on pool2
    for (int i = 0; i < 12; i++) {
      pool2.acquireConnection();
    }

    LogWriterUtils.getLogWriter().info("aquired 12 connections in pool2");

    // interleave creating connections in both pools
    for (int i = 0; i < 6; i++) {
      pool1.acquireConnection();
      pool2.acquireConnection();
    }

    LogWriterUtils.getLogWriter()
        .info("interleaved 6 connections from pool1 with 6 connections from pool2");

    // The load should still be balanced
    vm1.invoke("Check Connection Count", () -> checkConnectionCount(13));
    vm2.invoke("Check Connection Count", () -> checkConnectionCount(13));
    vm3.invoke("Check Connection Count", () -> checkConnectionCount(13));

  }
Test that the locator balances load between three servers with intersecting server groups.
Server: 1 2 3 Groups: a a,b b
geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/LocatorLoadBalancingDUnitTest.java