@Test
  public void failureWithIneligibleNodesTest() {
    assumeTrue(replicasStateEnabled);
    List<Port> portList = Collections.singletonList(new Port(PORT, PortType.PLAINTEXT));
    List<String> mountPaths = Collections.singletonList("mockMountPath");
    datanodes = new ArrayList<>(Arrays.asList(new MockDataNodeId(portList, mountPaths, "dc-0"),
        new MockDataNodeId(portList, mountPaths, "dc-1"), new MockDataNodeId(portList, mountPaths, "dc-2"),
        new MockDataNodeId(portList, mountPaths, "dc-3")));
    mockPartition = new MockPartitionId();
    populateReplicaList(8, ReplicaState.STANDBY);
    populateReplicaList(4, ReplicaState.INACTIVE);
    localDcName = datanodes.get(0).getDatacenterName();
    mockClusterMap = new MockClusterMap(false, datanodes, 1, Collections.singletonList(mockPartition), localDcName);
    // Now any of the failure would fail the operation

    UndeleteOperationTracker tracker = getOperationTracker(2);

    sendRequests(tracker, 2);
    tracker.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.SUCCESS);
    assertFalse("Operation should not have failed", tracker.hasFailed());
    assertFalse("Operation should not have succeeded", tracker.hasSucceeded());
    assertFalse("Operation should not be done", tracker.isDone());

    tracker.onResponse(inflightReplicas.poll(), TrackedRequestFinalState.FAILURE);
    assertTrue("Operation should have failed", tracker.hasFailed());
    assertFalse("Operation should not have succeeded", tracker.hasSucceeded());
    assertTrue("Operation should be done", tracker.isDone());
  }
Tests when there are ineligible hosts.
ambry-router/src/test/java/com/github/ambry/router/UndeleteOperationTrackerTest.java