@Test
  public void bootstrapBasicTest() throws Exception {
    CountDownLatch stateModelLatch = new CountDownLatch(1);
    // the listener latch is to ensure state change listener in ReplicationManager or StorageManager is invoked before
    // moving forward to rest tests.
    mockHelixParticipant.listenerLatch = new CountDownLatch(1);
    mockHelixParticipant.registerMockStateChangeListeners();
    // create a new thread and trigger BOOTSTRAP -> STANDBY transition
    Utils.newThread(() -> {
      stateModel.onBecomeStandbyFromBootstrap(mockMessage, null);
      stateModelLatch.countDown();
    }, false).start();
    assertTrue("State change listener didn't get invoked within 1 sec.",
        mockHelixParticipant.listenerLatch.await(1, TimeUnit.SECONDS));
    assertEquals("current replica should be in BOOTSTRAP state", ReplicaState.BOOTSTRAP,
        mockHelixParticipant.replicaState);
    assertFalse("Catchup shouldn't complete on current replica", replicaSyncUpService.isSyncUpComplete(currentReplica));
    ReplicaId localPeer1 = localDcPeerReplicas.get(0);
    ReplicaId localPeer2 = localDcPeerReplicas.get(1);
    ReplicaId remotePeer1 = remoteDcPeerReplicas.get(0);
    ReplicaId remotePeer2 = remoteDcPeerReplicas.get(1);
    // make current replica catch up with one peer replica in local DC
    assertFalse("Catchup shouldn't complete on current replica because only one peer replica is caught up",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer1, 50L, ReplicaState.STANDBY));
    // update lag between current replica and one remote DC peer replica but lag is still > acceptable threshold (100L)
    assertFalse("Catchup shouldn't complete on current replica because only one peer replica is caught up",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, remotePeer1, 110L,
            ReplicaState.STANDBY));
    // make current replica catch up with second peer replica in local DC and one more remote DC replica
    assertTrue("Catch up should be complete on current replica because it has caught up at least 2 peer replicas",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer2, 10L, ReplicaState.STANDBY));
    assertFalse("Catchup is completed by previous update not this one",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, remotePeer2, 10L,
            ReplicaState.STANDBY));
    // make current replica fall behind first peer replica in local DC again (update lag to 150 > 100)
    assertFalse("Catchup is completed by previous update. Current update should return false.",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer1, 150L,
            ReplicaState.STANDBY));
    assertTrue("Bootstrap-To-Standby transition didn't complete within 1 sec.",
        stateModelLatch.await(1, TimeUnit.SECONDS));
    // reset ReplicaSyncUpManager
    replicaSyncUpService.reset();
  }
Test workflow:
1. bootstrap is initiated by state model transition
2. current replica has caught up with one local DC peer (sync up is still in progress)
3. current replica is still behind one remote DC peer for more than acceptable threshold
4. current replica has caught up with another two peer replicas (sync up is complete)
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/AmbryReplicaSyncUpManagerTest.java