@Test
  public void localPutWithReplicaStateTest() {
    assumeTrue(operationTrackerType.equals(SIMPLE_OP_TRACKER));
    List<Port> portList = Collections.singletonList(new Port(PORT, PortType.PLAINTEXT));
    List<String> mountPaths = Collections.singletonList("mockMountPath");
    datanodes = Collections.singletonList(new MockDataNodeId(portList, mountPaths, "dc-0"));
    mockPartition = new MockPartitionId();
    // test that if there are only 2 eligible replicas, the success target should use routerConfig.routerPutSuccessTarget
    populateReplicaList(2, ReplicaState.STANDBY);
    localDcName = datanodes.get(0).getDatacenterName();
    mockClusterMap = new MockClusterMap(false, datanodes, 1, Collections.singletonList(mockPartition), localDcName);
    OperationTracker ot = getOperationTrackerForGetOrPut(true, 1, 2, RouterOperation.PutOperation, true);
    assertFalse("Operation should not have been done.", ot.isDone());
    sendRequests(ot, 2, false);
    // make one requests succeed, the other fail
    ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.SUCCESS);
    ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.FAILURE);
    assertFalse("Operation should fail", ot.hasSucceeded());
    assertTrue("Operation should be done", ot.isDone());

    // add one more replica in INACTIVE state, now we have 2 STANDBY and 1 INACTIVE replicas
    populateReplicaList(1, ReplicaState.INACTIVE);
    repetitionTracker.clear();
    ot = getOperationTrackerForGetOrPut(true, 1, 3, RouterOperation.PutOperation, true);
    // issue PUT request
    sendRequests(ot, replicasStateEnabled ? 2 : 3, false);
    // make first request fail and rest requests succeed
    ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.FAILURE);
    while (!inflightReplicas.isEmpty()) {
      ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.SUCCESS);
    }
    if (replicasStateEnabled) {
      assertFalse("Operation should fail because only 2 replicas eligible and 1 has failed", ot.hasSucceeded());
    } else {
      assertTrue("Operation should succeed when there are 2 success", ot.hasSucceeded());
    }

    // add three more replicas: one in LEADER state, the other two in STANDBY state
    populateReplicaList(1, ReplicaState.LEADER);
    populateReplicaList(2, ReplicaState.STANDBY);
    // now we have 6 replicas: 1 LEADER, 4 STANDBY and 1 INACTIVE. Number of eligible replicas = 1 + 4 = 5
    repetitionTracker.clear();
    ot = getOperationTrackerForGetOrPut(true, 1, 5, RouterOperation.PutOperation, true);
    // issue PUT request, parallelism should be 5 when replicaState is enabled.
    sendRequests(ot, 5, false);
    // remaining test is for replicaState enabled operation tracker
    if (replicasStateEnabled) {
      // make first 3 requests succeed
      for (int i = 0; i < 3; i++) {
        ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.SUCCESS);
        // success target should be 4 when replicaState is enabled for operation tracker, so operation is not done yet
        // even though it has succeeded on 3 replicas.
        assertFalse("Operation should not be done", ot.isDone());
      }
      // make last 2 requests fail, then operation should be done and result should be failure
      for (int i = 0; i < 2; i++) {
        ot.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.FAILURE);
      }
      assertFalse("Operation should fail", ot.hasSucceeded());
      assertTrue("Operation should be done", ot.isDone());
    }
  }
Test put operation in local dc when replicasStateEnabled is enabled/disabled.
Test steps:
Case1: Only 2 STANDBY replicas in local dc;
       Make 1 succeed and the other fail (both current and replicaState enabled tracker should fail)
Case2: 2 STANDBY, 1 INACTIVE replicas in local dc
       Make 1 fail and 2 succeed (replicaState enabled operation tracker should fail)
Case3: 1 LEADER, 4 STANDBY and 1 INACTIVE in local dc
       Make 3 succeed and 2 fail (replicaState enabled operation tracker should fail)
ambry-router/src/test/java/com/github/ambry/router/OperationTrackerTest.java