@Test
  public void putOperationFailureTest() throws Exception {
    primeTracker(putLocalColoTracker, MIN_DATA_POINTS_REQUIRED, LOCAL_COLO_LATENCY_RANGE);
    double localColoCutoff = putLocalColoTracker.getSnapshot().getValue(QUANTILE);
    OperationTracker ot =
        getOperationTracker(createRouterConfig(true, 2, 2, 6, null, true), mockPartition, RouterOperation.PutOperation);
    sendRequests(ot, 2);
    // sleep for less than the cutoff
    time.sleep((long) localColoCutoff - 2);
    sendRequests(ot, 0);

    // Acknowledging one failure would immediately trigger another send
    ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.FAILURE);
    sendRequests(ot, 1);
    // push it over the edge
    time.sleep(5);
    // Put only has 3 nodes
    sendRequests(ot, 0);

    ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.SUCCESS);
    ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.SUCCESS);

    // two success, one failure
    assertTrue("Operation should be done", ot.isDone());
    assertTrue("Operation should have succeeded", ot.hasSucceeded());
  }
Test that PutOperation can use adaptive operation tracker when there is a failure response.
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/AdaptiveOperationTrackerTest.java