@Test
  public void trackerUpdateBetweenHasNextAndNextTest() throws InterruptedException {
    primeTracker(localColoTracker, MIN_DATA_POINTS_REQUIRED, LOCAL_COLO_LATENCY_RANGE);
    primeTracker(crossColoTracker, MIN_DATA_POINTS_REQUIRED, CROSS_COLO_LATENCY_RANGE);
    double localColoCutoff = localColoTracker.getSnapshot().getValue(1);

    OperationTracker ot = getOperationTracker(createRouterConfig(false, 1, 1, 6, null, true), mockPartition);
    // 3-0-0-0
    sendRequests(ot, 1);
    // 2-1-0-0
    // sleep for a time greater than cutoff
    time.sleep((long) localColoCutoff + 2);

    // now get an iterator and call hasNext() on it
    Iterator<ReplicaId> replicaIterator = ot.getReplicaIterator();
    assertTrue("There should be a replica to send to", replicaIterator.hasNext());
    // now insert a value in the tracker such that it is the max value. However, the return value of hasNext() must
    // not change even though the tracker has changed its return value for getSnapshot().getValue(1).
    long valueToInsert = 2 * (long) localColoCutoff;
    localColoTracker.update(valueToInsert);
    assertEquals("Tracker's snapshot should return the max value", valueToInsert,
        (long) localColoTracker.getSnapshot().getValue(1));
    // hasNext() should not change it's return value
    assertTrue("There should be a replica to send to", replicaIterator.hasNext());

    sendRequests(ot, 1);
    // 1-2-0-0
    ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.SUCCESS);
    // 1-1-1-0
    assertTrue("Operation should have succeeded", ot.hasSucceeded());
    // past due counter should be 1
    assertEquals("Past due counter is inconsistent", 1, pastDueCounter.getCount());
  }
Tests the case where the tracker is updated b/w the {@link Iterator#hasNext()} and {@link Iterator#next()} calls.
@throws InterruptedException
ambry-router/src/test/java/com/github/ambry/router/AdaptiveOperationTrackerTest.java