static void setServerErrorCodes(ServerErrorCode[] serverErrorCodesInOrder, PartitionId partition,
      MockServerLayout serverLayout, String originatingDcName) {
    List<? extends ReplicaId> replicas = partition.getReplicaIds();
    if (serverErrorCodesInOrder.length > replicas.size()) {
      throw new IllegalArgumentException("More server error codes provided than replicas in partition");
    }
    // Assume number of nodes in each dc is 3 and do serverErrorCodes assignment based on Operation Tracker logic.
    // TODO: Use a shared queue among all mock servers to avoid assumption above.
    int numOfNodesEachDatacenter = 3;
    List<ServerErrorCode> serverErrorInLocalDC =
        Arrays.asList(serverErrorCodesInOrder).subList(0, numOfNodesEachDatacenter);
    List<ServerErrorCode> serverErrorInOtherDCs =
        Arrays.asList(serverErrorCodesInOrder).subList(numOfNodesEachDatacenter, serverErrorCodesInOrder.length);

    List<MockServer> serversInLocalDc = new ArrayList<>();
    List<MockServer> serversInRemoteDc = new ArrayList<>();

    for (int i = 0; i < partition.getReplicaIds().size(); i++) {
      DataNodeId node = partition.getReplicaIds().get(i).getDataNodeId();
      MockServer mockServer = serverLayout.getMockServer(node.getHostname(), node.getPort());
      if (mockServer.getDataCenter().equals(originatingDcName)) {
        serversInLocalDc.add(mockServer);
      } else {
        serversInRemoteDc.add(mockServer);
      }
    }

    assertEquals(serversInLocalDc.size(), serverErrorInLocalDC.size());
    assertEquals(serversInRemoteDc.size(), serverErrorInOtherDCs.size());
    for (int i = 0; i < serverErrorInLocalDC.size(); i++) {
      serversInLocalDc.get(i).setServerErrorForAllRequests(serverErrorInLocalDC.get(i));
    }
    for (int i = 0; i < serverErrorInOtherDCs.size(); i++) {
      serversInRemoteDc.get(i).setServerErrorForAllRequests(serverErrorInOtherDCs.get(i));
    }
  }
Set the servers containing the specified partition to respond with the designated error codes.
@param serverErrorCodesInOrder The error codes to set in the order of the servers returned by
                               {@link PartitionId#getReplicaIds()}. If there are fewer error codes in this array
                               than there are servers containing the partition, the rest of the servers are set to
                               {@link ServerErrorCode#NoError}
@param partition The partition contained by the servers to set error codes on.
@param serverLayout A {@link MockServerLayout} that is used to find the {@link MockServer}s to set error codes on.
@param originatingDcName originating DC name.
@throws IllegalArgumentException If there are more error codes in the input array then there are servers.
ambry-router/src/test/java/com/github/ambry/router/RouterTestHelpers.java