@Test
  public void requestPerformanceEvaluationTest() throws Exception {
    long BANDWIDTH_THRESHOLD = 500L;
    long TIME_TO_FIRST_BYTE_THRESHOLD = 30L;
    String content = "@@randomContent@@@";
    MockNettyRequest.inboundBytes = content.length();
    Properties properties = new Properties();
    properties.put("performance.success.post.average.bandwidth.threshold", Long.toString(BANDWIDTH_THRESHOLD));
    properties.put("performance.success.get.average.bandwidth.threshold", Long.toString(BANDWIDTH_THRESHOLD));
    properties.put("performance.success.get.time.to.first.byte.threshold", Long.toString(TIME_TO_FIRST_BYTE_THRESHOLD));
    properties.put(PerformanceConfig.NON_SUCCESS_REST_REQUEST_TOTAL_TIME_THRESHOLD_STR,
        "{\"PUT\": \"35\",\"GET\": \"35\",\"POST\": \"35\",\"HEAD\": \"35\",\"DELETE\": \"35\"}");
    properties.put(PerformanceConfig.SUCCESS_REST_REQUEST_TOTAL_TIME_THRESHOLD_STR,
        "{\"PUT\": \"35\",\"GET\": \"35\",\"POST\": \"35\",\"HEAD\": \"35\",\"DELETE\": \"35\"}");
    PerformanceConfig config = new PerformanceConfig(new VerifiableProperties(properties));
    MockNettyMessageProcessor.useMockNettyRequest = true;
    MockNettyMessageProcessor.PERFORMANCE_CONFIG = config;

    // test "Satisfied" requests
    MockNettyRequest.roundTripTime = 30L;
    MockNettyRequest.timeToFirstByte = 25L;
    verifySatisfactionOfRequests(content, true);

    // test "Unsatisfied" requests
    MockNettyRequest.roundTripTime = 40L;
    MockNettyRequest.timeToFirstByte = 36L;
    verifySatisfactionOfRequests(content, false);

    // use OPTIONS request as an example, which should skip evaluation and mark as satisfied directly
    HttpRequest httpRequest =
        RestTestUtils.createFullRequest(HttpMethod.OPTIONS, TestingUri.ImmediateResponseComplete.toString(), null,
            TestUtils.getRandomBytes(18));
    sendRequestAndEvaluateResponsePerformance(httpRequest, null, HttpResponseStatus.OK, true);
  }
Tests that requests can be correctly evaluated based on their performance (i.e. latency, bandwidth)
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyResponseChannelTest.java