@Test
  public void failureWithOriginatingDcTest() {
    initialize();
    originatingDcName = datanodes.get(datanodes.size() - 1).getDatacenterName();
    UndeleteOperationTracker tracker = getOperationTracker(3);
    sendRequests(tracker, 3);
    // First three requests should target at local datacenter, and request 4 to 6 should target at originating datacenter.
    for (int i = 0; i < 3; i++) {
      ReplicaId replicaId = inflightReplicas.poll();
      assertEquals(replicaId.getDataNodeId().getDatacenterName(), localDcName);
      tracker.onResponse(replicaId, TrackedRequestFinalState.SUCCESS);
    }
    assertFalse("Operation should not be done", tracker.isDone());
    assertFalse("Operation should not have succeeded", tracker.hasSucceeded());

    sendRequests(tracker, 3);
    for (int i = 0; i < 2; i++) {
      ReplicaId replicaId = inflightReplicas.poll();
      assertEquals(replicaId.getDataNodeId().getDatacenterName(), originatingDcName);
      tracker.onResponse(replicaId, TrackedRequestFinalState.FAILURE);
    }

    assertTrue("Operation should have failed", tracker.hasFailed());
    assertTrue("Operation should be done", tracker.isDone());
    assertFalse("Operation should not have succeeded", tracker.hasSucceeded());
  }
Tests when there are two failures in originating datacenter.
ambry-router/src/test/java/com/github/ambry/router/UndeleteOperationTrackerTest.java