Benno Evers created MESOS-9494:
----------------------------------

             Summary: Add a unit test for the interaction between request 
batching and response compression
                 Key: MESOS-9494
                 URL: https://issues.apache.org/jira/browse/MESOS-9494
             Project: Mesos
          Issue Type: Improvement
            Reporter: Benno Evers


As discussed in https://reviews.apache.org/r/69064/ , we should try to add a 
unit test that verifies that simultaneous requests with different accept 
encoding headers produce different responses.

It could look like this:
{noformat}
TEST_F(MasterLoadTest, AcceptEncoding)
{
  MockAuthorizer authorizer;
  prepareCluster(&authorizer);

  Headers authHeaders = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
  Headers acceptGzipHeaders = {{"Accept-Encoding", "gzip"}};
  Headers acceptRawHeaders  = {{"Accept-Encoding", "raw"}};

  RequestDescriptor descriptor1;
  descriptor1.endpoint = "/state";
  descriptor1.headers = authHeaders + acceptGzipHeaders;

  RequestDescriptor descriptor2 = descriptor1;
  descriptor2.headers = authHeaders + acceptRawHeaders;

  auto responses = launchSimultaneousRequests({descriptor1, descriptor2});

  foreachpair (
      const RequestDescriptor& request,
      Future<Response>& response,
      responses)
  {
    AWAIT_READY(response);

    ASSERT_SOME(request.headers.get("Accept-Encoding"));
    if (request.headers.get("Accept-Encoding").get() == "gzip") {
      ASSERT_SOME(response->headers.get("Content-Encoding"));
      EXPECT_EQ(response->headers.get("Content-Encoding").get(), "gzip");
    } else {
      EXPECT_NONE(response->headers.get("Content-Encoding"));
    }
  }

  // Ensure that we actually hit the metrics code path while executing
  // the test.
  JSON::Object metrics = Metrics();
  ASSERT_TRUE(metrics.values["master/http_cache_hits"].is<JSON::Number>());
  ASSERT_GT(
      metrics.values["master/http_cache_hits"].as<JSON::Number>().as<size_t>(),
      0u);
}
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to