@Test
  public void testTwoServers() {
    final LocatorLoadSnapshot sn = new LocatorLoadSnapshot();
    final ServerLocation l1 = new ServerLocation("localhost", 1);
    final ServerLocation l2 = new ServerLocation("localhost", 2);
    final ServerLoad ld1 = new ServerLoad(3, 1, 1.01f, 1);
    final ServerLoad ld2 = new ServerLoad(5, .2f, 1f, .2f);
    final String uniqueId1 = new InternalDistributedMember("localhost", 1).getUniqueId();
    final String uniqueId2 = new InternalDistributedMember("localhost", 2).getUniqueId();
    sn.addServer(l1, uniqueId1, new String[0], ld1, LOAD_POLL_INTERVAL);
    sn.addServer(l2, uniqueId2, new String[0], ld2, LOAD_POLL_INTERVAL);

    Map<ServerLocation, ServerLoad> expectedLoad = new HashMap<>();
    expectedLoad.put(l1, ld1);
    expectedLoad.put(l2, ld2);
    assertThat(sn.getLoadMap()).isEqualTo(expectedLoad);

    assertThat(sn.getServerForConnection("group", Collections.emptySet())).isNull();
    assertThat(sn.getServersForQueue("group", Collections.emptySet(), 5))
        .isEqualTo(Collections.EMPTY_LIST);

    assertThat(sn.getServerForConnection(null, Collections.emptySet())).isEqualTo(l1);
    assertThat(sn.getServerForConnection(null, Collections.emptySet())).isEqualTo(l1);
    // the load should be equal here, so we don't know which server to expect
    sn.getServerForConnection(null, Collections.emptySet());
    sn.getServerForConnection(null, Collections.emptySet());

    assertThat(sn.getServerForConnection(null, Collections.emptySet())).isEqualTo(l2);
    assertThat(sn.getServerForConnection(null, Collections.emptySet())).isEqualTo(l2);

    assertThat(sn.getServersForQueue(null, Collections.emptySet(), 1))
        .isEqualTo(Collections.singletonList(l2));
    assertThat(sn.getServersForQueue(null, Collections.emptySet(), 1))
        .isEqualTo(Collections.singletonList(l1));
    assertThat(sn.getServersForQueue(null, Collections.emptySet(), 1))
        .isEqualTo(Collections.singletonList(l2));

    assertThat(sn.getServersForQueue(null, Collections.emptySet(), 5))
        .isEqualTo(Arrays.asList(l2, l1));
    assertThat(sn.getServersForQueue(null, Collections.emptySet(), -1))
        .isEqualTo(Arrays.asList(l2, l1));
  }
Test a snapshot with two servers. The servers are initialized with unequal load, and then and
then we test that after several requests, the load balancer starts sending connections to the
second server.
geode-core/src/test/java/org/apache/geode/distributed/internal/LocatorLoadSnapshotTest.java