@Test
  public void getOperationWithReplicaStateTest() {
    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")));
    mockPartition = new MockPartitionId();
    for (ReplicaState state : EnumSet.of(ReplicaState.BOOTSTRAP, ReplicaState.STANDBY, ReplicaState.LEADER,
        ReplicaState.INACTIVE, ReplicaState.OFFLINE)) {
      populateReplicaList(1, state);
    }
    localDcName = datanodes.get(0).getDatacenterName();
    mockClusterMap = new MockClusterMap(false, datanodes, 1, Collections.singletonList(mockPartition), localDcName);
    // 1. include down replicas (OFFLINE replicas are eligible for GET)
    OperationTracker ot = getOperationTrackerForGetOrPut(true, 1, 1, RouterOperation.GetBlobOperation, true);
    // make sure 4 requests fails and last one succeeds. (This is to verify operation tracker adds offline replica into replica pool as well)
    ReplicaId inflightReplica;
    for (int i = 0; i < 4; ++i) {
      sendRequests(ot, 1, false);
      inflightReplica = inflightReplicas.poll();
      // verify that the first 4 replicas are not OFFLINE replica. (OFFLINE replica should be added to the end of queue)
      assertNotSame("Replica state should not be OFFLINE ", mockPartition.replicaAndState.get(inflightReplica),
          ReplicaState.OFFLINE);
      ot.onResponse(inflightReplica, TrackedRequestFinalState.FAILURE);
      assertFalse("Operation should not complete", ot.isDone());
    }
    sendRequests(ot, 1, false);
    inflightReplica = inflightReplicas.poll();
    assertEquals("The last replica should be OFFLINE", ReplicaState.OFFLINE,
        mockPartition.replicaAndState.get(inflightReplica));
    ot.onResponse(inflightReplica, TrackedRequestFinalState.SUCCESS);
    assertTrue("Operation should be done", ot.isDone());

    // 2. exclude down replicas
    repetitionTracker.clear();
    ot = getOperationTrackerForGetOrPut(true, 1, 1, RouterOperation.GetBlobOperation, false);
    for (int i = 0; i < 4; ++i) {
      sendRequests(ot, 1, false);
      inflightReplica = inflightReplicas.poll();
      // verify that none of these replicas is OFFLINE replica.
      assertNotSame("Replica state should not be OFFLINE ", mockPartition.replicaAndState.get(inflightReplica),
          ReplicaState.OFFLINE);
      ot.onResponse(inflightReplica, TrackedRequestFinalState.FAILURE);
      if (i < 3) {
        assertFalse("Operation should not complete", ot.isDone());
      } else {
        assertTrue("Operation should complete", ot.isDone());
      }
    }
  }
Test GET operation is able to try on OFFLINE replicas if routerOperationTrackerIncludeDownReplicas is true.
ambry-router/src/test/java/com/github/ambry/router/OperationTrackerTest.java