@Test
  public void deactivationBasicTest() 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 STANDBY -> INACTIVE transition
    Utils.newThread(() -> {
      stateModel.onBecomeInactiveFromStandby(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 INACTIVE state", ReplicaState.INACTIVE,
        mockHelixParticipant.replicaState);
    assertFalse("Catchup shouldn't complete on current replica", replicaSyncUpService.isSyncUpComplete(currentReplica));
    ReplicaId localPeer1 = localDcPeerReplicas.get(0);
    ReplicaId localPeer2 = localDcPeerReplicas.get(1);
    // make localPeer1 catch up with current replica but localPeer2 still falls behind.
    assertFalse("Catchup shouldn't complete on current replica because only one peer replica has caught up",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer1, 0L, ReplicaState.INACTIVE));
    assertFalse("Catchup shouldn't complete on current replica because only one peer replica has caught up",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer2, 5L, ReplicaState.INACTIVE));
    // make localPeer2 catch up with current replica.
    assertTrue("Sync up should be complete on current replica because 2 peer replicas have caught up with it",
        replicaSyncUpService.updateReplicaLagAndCheckSyncStatus(currentReplica, localPeer2, 0L, ReplicaState.INACTIVE));
    assertTrue("Standby-To-Inactive transition didn't complete within 1 sec.",
        stateModelLatch.await(1, TimeUnit.SECONDS));
    // reset ReplicaSyncUpManager
    replicaSyncUpService.reset();
  }
Basic tests for deactivation process (STANDBY -> INACTIVE transition)
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/AmbryReplicaSyncUpManagerTest.java