private void testHealthCheckRequest(HttpMethod httpMethod, boolean isServiceUp, boolean keepAlive)
      throws IOException {
    EmbeddedChannel channel = createChannel();
    for (int i = 0; i < 2; i++) {
      if (isServiceUp) {
        restServerState.markServiceUp();
      }
      HttpRequest request = RestTestUtils.createRequest(httpMethod, healthCheckUri, null);
      HttpUtil.setKeepAlive(request, keepAlive);
      FullHttpResponse response = sendRequestAndGetResponse(channel, request);
      HttpResponseStatus httpResponseStatus =
          (isServiceUp) ? HttpResponseStatus.OK : HttpResponseStatus.SERVICE_UNAVAILABLE;
      assertEquals("Unexpected response status", httpResponseStatus, response.status());
      String expectedStr = (isServiceUp) ? goodStr : badStr;
      assertEquals("Unexpected content", expectedStr, RestTestUtils.getContentString(response));
      restServerState.markServiceDown();
      if (keepAlive && isServiceUp) {
        Assert.assertTrue("Channel should not be closed ", channel.isOpen());
      } else {
        Assert.assertFalse("Channel should have been closed by now ", channel.isOpen());
        channel = createChannel();
      }
    }
    channel.close();
  }
Does a test to see that a health check request results in expected response from the health check handler
@param httpMethod the {@link HttpMethod} for the request.
@param keepAlive true if keep alive has to be set in the request, false otherwise
@throws IOException
ambry-rest/src/test/java/com/github/ambry/rest/HealthCheckHandlerTest.java