@Test
  public void testRetryLimitInSecondWhenAllGetFailed() throws Exception {
    // Make sure we are work on a simple blob
    blobSize = maxChunkSize - 1;
    doPut();
    int retryLimitInSeconds = 10;
    RouterConfig originalConfig = routerConfig;
    Properties props = getDefaultNonBlockingRouterProperties(true);
    props.setProperty(RouterConfig.ROUTER_GET_BLOB_RETRY_LIMIT_COUNT, "10");
    props.setProperty(RouterConfig.ROUTER_GET_BLOB_RETRY_LIMIT_IN_SEC, String.valueOf(retryLimitInSeconds));
    routerConfig = new RouterConfig(new VerifiableProperties(props));
    try {
      for (MockServer server : mockServerLayout.getMockServers()) {
        server.setServerErrorForAllRequests(ServerErrorCode.ReplicaUnavailable);
      }
      long retryCountBefore = routerMetrics.getBlobRetryCount.getCount();
      GetBlobOperation op = createOperation(routerConfig, null);
      boolean sleeped = false;
      while (!op.isOperationComplete()) {
        op.poll(requestRegistrationCallback);
        List<ResponseInfo> responses = sendAndWaitForResponses(requestRegistrationCallback.getRequestsToSend());
        for (ResponseInfo responseInfo : responses) {
          GetResponse getResponse = responseInfo.getError() == null ? GetResponse.readFrom(
              new NettyByteBufDataInputStream(responseInfo.content()), mockClusterMap) : null;
          op.handleResponse(responseInfo, getResponse);
          responseInfo.release();
        }
        if (!sleeped && !op.isOperationComplete() && routerMetrics.getBlobRetryCount.getCount() != retryCountBefore) {
          // Sleep so that we only retry once
          time.sleep(TimeUnit.SECONDS.toMillis(retryLimitInSeconds));
          sleeped = true;
        }
      }
      assertFailureAndCheckErrorCode(op, RouterErrorCode.AmbryUnavailable);
      assertEquals(1, routerMetrics.getBlobRetryCount.getCount() - retryCountBefore);
    } finally {
      routerConfig = originalConfig;
    }
  }
Test the case where all requests time out within the SocketNetworkClient.
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/GetBlobOperationTest.java