private void doTestSuccessInThePresenceOfVariousErrors(String dcWherePutHappened) throws Exception {
    ArrayList<MockServer> mockServers = new ArrayList<>(mockServerLayout.getMockServers());
    ArrayList<ServerErrorCode> serverErrors = new ArrayList<>(Arrays.asList(ServerErrorCode.values()));
    // set the status to various server level or partition level errors (not Blob_Deleted or Blob_Expired - as they
    // are final), except for one of the servers in the datacenter where the put happened (we do this as puts only go
    // to the local dc, whereas gets go cross colo).
    serverErrors.remove(ServerErrorCode.BlobDeleted);
    serverErrors.remove(ServerErrorCode.BlobExpired);
    serverErrors.remove(ServerErrorCode.NoError);
    serverErrors.remove(ServerErrorCode.BlobAuthorizationFailure);
    boolean goodServerMarked = false;
    boolean notFoundSetInOriginalDC = false;
    for (MockServer mockServer : mockServers) {
      ServerErrorCode code = serverErrors.get(random.nextInt(serverErrors.size()));
      // make sure in the original dc, we don't set Blob_Not_Found twice.
      if (mockServer.getDataCenter().equals(dcWherePutHappened)) {
        if (!goodServerMarked) {
          mockServer.setServerErrorForAllRequests(ServerErrorCode.NoError);
          goodServerMarked = true;
        } else {
          if (!notFoundSetInOriginalDC) {
            mockServer.setServerErrorForAllRequests(code);
            notFoundSetInOriginalDC = code == ServerErrorCode.BlobNotFound;
          } else {
            while (code == ServerErrorCode.BlobNotFound) {
              code = serverErrors.get(random.nextInt(serverErrors.size()));
            }
            mockServer.setServerErrorForAllRequests(code);
          }
        }
      } else {
        mockServer.setServerErrorForAllRequests(code);
      }
    }
    getAndAssertSuccess();
  }
Helper method to simulate errors from the servers. Only one node in the datacenter where the put happened will
return success. No matter what order the servers are contacted, as long as one of them returns success, the whole
operation should succeed.
@param dcWherePutHappened the datacenter where the put happened.
ambry-router/src/test/java/com/github/ambry/router/GetBlobOperationTest.java