You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2016/01/14 11:38:18 UTC
mesos git commit: Cleaned up assertions in test cases around JSON
HTTP responses.
Repository: mesos
Updated Branches:
refs/heads/master 3141660b7 -> d75826e39
Cleaned up assertions in test cases around JSON HTTP responses.
Used `AWAIT_EXPECT_RESPONSE_HEADER_EQ()` to check the "Content-Type" of
the response, rather than accessing the "headers" field directly, and
used the symbol `APPLICATION_JSON` rather than a string literal. Also
added "Content-Type" checks to a few places that had neglected to make
them, and cleaned up some whitespace style.
Review: https://reviews.apache.org/r/41806/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d75826e3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d75826e3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d75826e3
Branch: refs/heads/master
Commit: d75826e39f77df5aa30ecb382c1a932079f459be
Parents: 3141660
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Jan 14 02:06:56 2016 -0800
Committer: Adam B <ad...@mesosphere.io>
Committed: Thu Jan 14 02:06:56 2016 -0800
----------------------------------------------------------------------
src/tests/executor_http_api_tests.cpp | 16 ++-
src/tests/fault_tolerance_tests.cpp | 10 +-
src/tests/master_tests.cpp | 147 ++++++++++---------------
src/tests/metrics_tests.cpp | 12 +-
src/tests/monitor_tests.cpp | 24 +---
src/tests/repair_tests.cpp | 6 +-
src/tests/scheduler_driver_tests.cpp | 5 +-
src/tests/scheduler_http_api_tests.cpp | 12 +-
src/tests/slave_tests.cpp | 64 +++++------
src/tests/status_update_manager_tests.cpp | 6 +-
src/tests/utils.cpp | 8 +-
11 files changed, 117 insertions(+), 193 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/executor_http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/executor_http_api_tests.cpp b/src/tests/executor_http_api_tests.cpp
index 952aacb..36a042e 100644
--- a/src/tests/executor_http_api_tests.cpp
+++ b/src/tests/executor_http_api_tests.cpp
@@ -391,7 +391,7 @@ TEST_P(ExecutorHttpApiTest, DefaultAccept)
stringify(contentType));
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ(APPLICATION_JSON, response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Shutdown();
}
@@ -471,7 +471,7 @@ TEST_P(ExecutorHttpApiTest, NoAcceptHeader)
stringify(contentType));
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ(APPLICATION_JSON, response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Shutdown();
}
@@ -759,23 +759,21 @@ TEST_P(ExecutorHttpApiTest, Subscribe)
// Retrieve the parameter passed as content type to this test.
const ContentType contentType = GetParam();
+ const string contentTypeString = stringify(contentType);
process::http::Headers headers;
- headers["Accept"] = stringify(contentType);
+ headers["Accept"] = contentTypeString;
Future<Response> response = process::http::streaming::post(
slave.get(),
"api/v1/executor",
headers,
serialize(contentType, call),
- stringify(contentType));
+ contentTypeString);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ(stringify(contentType),
- response.get().headers.get("Content-Type"));
-
- EXPECT_SOME_EQ("chunked",
- response.get().headers.get("Transfer-Encoding"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ("chunked", "Transfer-Encoding", response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(contentTypeString, "Content-Type", response);
ASSERT_EQ(Response::PIPE, response.get().type);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/fault_tolerance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fault_tolerance_tests.cpp b/src/tests/fault_tolerance_tests.cpp
index fd1c3c9..982468f 100644
--- a/src/tests/fault_tolerance_tests.cpp
+++ b/src/tests/fault_tolerance_tests.cpp
@@ -68,6 +68,7 @@ using process::Owned;
using process::PID;
using process::Promise;
using process::UPID;
+
using process::http::OK;
using process::http::Response;
@@ -168,10 +169,10 @@ TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks)
// Verify master/slave have 0 completed/running frameworks.
Future<Response> masterState = process::http::get(master.get(), "state");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, masterState);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, masterState);
AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
+ APPLICATION_JSON,
"Content-Type",
masterState);
@@ -1903,9 +1904,8 @@ TEST_F(FaultToleranceTest, UpdateFrameworkInfoOnSchedulerFailover)
AWAIT_READY(sched1Error);
- Future<process::http::Response> response = process::http::get(
- master.get(), "state.json");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ Future<Response> response = process::http::get(master.get(), "state.json");
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
Try<JSON::Object> parse =
JSON::parse<JSON::Object>(response.get().body);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 223b9d2..9638fb8 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -81,6 +81,9 @@ using process::Future;
using process::PID;
using process::Promise;
+using process::http::OK;
+using process::http::Response;
+
using std::shared_ptr;
using std::string;
using std::vector;
@@ -279,9 +282,10 @@ TEST_F(MasterTest, ShutdownFrameworkWhileTaskRunning)
Clock::resume();
// Request master state.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state");
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
// These checks are not essential for the test, but may help
// understand what went wrong.
@@ -1629,17 +1633,12 @@ TEST_F(MasterTest, SlavesEndpointWithoutSlaves)
ASSERT_SOME(master);
// Query the master.
- Future<process::http::Response> response =
- process::http::get(master.get(), "slaves");
+ Future<Response> response = process::http::get(master.get(), "slaves");
- AWAIT_READY(response);
-
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
- const Try<JSON::Value> parse =
- JSON::parse(response.get().body);
+ const Try<JSON::Value> parse = JSON::parse(response.get().body);
ASSERT_SOME(parse);
Try<JSON::Value> expected = JSON::parse(
@@ -1678,14 +1677,10 @@ TEST_F(MasterTest, SlavesEndpointTwoSlaves)
AWAIT_READY(slave2RegisteredMessage);
// Query the master.
- Future<process::http::Response> response =
- process::http::get(master.get(), "slaves");
+ Future<Response> response = process::http::get(master.get(), "slaves");
- AWAIT_READY(response);
-
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
const Try<JSON::Object> parse =
JSON::parse<JSON::Object>(response.get().body);
@@ -2270,13 +2265,10 @@ TEST_F(MasterTest, OrphanTasks)
EXPECT_EQ(TASK_RUNNING, status.get().state());
// Get the master's state.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2338,11 +2330,9 @@ TEST_F(MasterTest, OrphanTasks)
// Get the master's state.
response = process::http::get(master.get(), "state");
- AWAIT_READY(response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2373,11 +2363,9 @@ TEST_F(MasterTest, OrphanTasks)
// Get the master's state.
response = process::http::get(master.get(), "state");
- AWAIT_READY(response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2838,14 +2826,10 @@ TEST_F(MasterTest, StateEndpoint)
Try<PID<Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ Future<Response> response = process::http::get(master.get(), "state");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2935,7 +2919,7 @@ TEST_F(MasterTest, StateSummaryEndpoint)
EXPECT_CALL(sched, registered(&driver, _, _))
.Times(1);
- Future<vector<Offer> > offers;
+ Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
@@ -2984,14 +2968,10 @@ TEST_F(MasterTest, StateSummaryEndpoint)
EXPECT_CALL(exec, shutdown(_))
.Times(AtMost(1));
- Future<process::http::Response> response =
- process::http::get(master.get(), "state-summary");
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ Future<Response> response = process::http::get(master.get(), "state-summary");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3044,9 +3024,8 @@ TEST_F(MasterTest, FrameworkWebUIUrlandCapabilities)
AWAIT_READY(registered);
- Future<process::http::Response> masterState =
- process::http::get(master.get(), "state");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, masterState);
+ Future<Response> masterState = process::http::get(master.get(), "state");
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, masterState);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(masterState.get().body);
ASSERT_SOME(parse);
@@ -3151,13 +3130,10 @@ TEST_F(MasterTest, TaskLabels)
AWAIT_READY(update);
// Verify label key and value in the master's state endpoint.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3253,13 +3229,10 @@ TEST_F(MasterTest, TaskStatusLabels)
AWAIT_READY(status);
// Verify label key and value in master state.json.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state.json");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state.json");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3348,13 +3321,10 @@ TEST_F(MasterTest, TaskStatusContainerStatus)
EXPECT_EQ(slaveIPAddress, containerStatus.network_infos(0).ip_address());
// Now do the same validation with state endpoint.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state.json");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state.json");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3433,9 +3403,10 @@ TEST_F(MasterTest, SlaveActiveEndpoint)
AWAIT_READY(slaveRegisteredMessage);
// Verify slave is active.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state");
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3555,13 +3526,10 @@ TEST_F(MasterTest, TaskDiscoveryInfo)
AWAIT_READY(update);
// Verify label key and value in the master's state endpoint.
- Future<process::http::Response> response =
- process::http::get(master.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(master.get(), "state");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3839,9 +3807,10 @@ TEST_F(MasterTest, FrameworkInfoLabels)
AWAIT_READY(registered);
- Future<process::http::Response> response =
- process::http::get(master.get(), "state.json");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ Future<Response> response = process::http::get(master.get(), "state.json");
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3884,13 +3853,10 @@ TEST_F(MasterTest, FrameworksEndpointWithoutFrameworks)
Try<PID<Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- Future<process::http::Response> response =
- process::http::get(master.get(), "frameworks");
+ Future<Response> response = process::http::get(master.get(), "frameworks");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -3933,9 +3899,10 @@ TEST_F(MasterTest, FrameworksEndpointOneFramework)
AWAIT_READY(registered);
- Future<process::http::Response> response =
- process::http::get(master.get(), "frameworks");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ Future<Response> response = process::http::get(master.get(), "frameworks");
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/metrics_tests.cpp b/src/tests/metrics_tests.cpp
index f081fb9..106bea5 100644
--- a/src/tests/metrics_tests.cpp
+++ b/src/tests/metrics_tests.cpp
@@ -45,11 +45,9 @@ TEST_F(MetricsTest, Master)
process::Future<process::http::Response> response =
process::http::get(upid, "snapshot");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -163,11 +161,9 @@ TEST_F(MetricsTest, Slave)
process::Future<process::http::Response> response =
process::http::get(upid, "snapshot");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/monitor_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/monitor_tests.cpp b/src/tests/monitor_tests.cpp
index a848d14..2226458 100644
--- a/src/tests/monitor_tests.cpp
+++ b/src/tests/monitor_tests.cpp
@@ -96,13 +96,9 @@ TEST(MonitorTest, Statistics)
UPID upid("monitor", process::address());
Future<http::Response> response = http::get(upid, "statistics");
- AWAIT_READY(response);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
- "Content-Type",
- response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
JSON::Array expected;
JSON::Object usage;
@@ -130,13 +126,9 @@ TEST(MonitorTest, NoExecutor)
UPID upid("monitor", process::address());
Future<http::Response> response = http::get(upid, "statistics");
- AWAIT_READY(response);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
- "Content-Type",
- response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
AWAIT_EXPECT_RESPONSE_BODY_EQ("[]", response);
}
@@ -171,13 +163,9 @@ TEST(MonitorTest, MissingStatistics)
UPID upid("monitor", process::address());
Future<http::Response> response = http::get(upid, "statistics");
- AWAIT_READY(response);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
- "Content-Type",
- response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
AWAIT_EXPECT_RESPONSE_BODY_EQ("[]", response);
}
@@ -235,13 +223,9 @@ TEST_F(MonitorIntegrationTest, RunningExecutor)
UPID upid("monitor", process::address());
Future<http::Response> response = http::get(upid, "statistics");
- AWAIT_READY(response);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
- "Content-Type",
- response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
// Verify that the statistics in the response contains the proper
// resource limits for the container.
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/repair_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/repair_tests.cpp b/src/tests/repair_tests.cpp
index 63ec889..bb10456 100644
--- a/src/tests/repair_tests.cpp
+++ b/src/tests/repair_tests.cpp
@@ -82,16 +82,16 @@ string stringify(const JsonResponse& response)
#define VALIDATE_GOOD_RESPONSE(response, jsonResponse) \
AWAIT_READY(response); \
AWAIT_EXPECT_RESPONSE_HEADER_EQ( \
- "application/json", \
+ APPLICATION_JSON, \
"Content-Type", \
- response); \
+ response); \
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response); \
AWAIT_EXPECT_RESPONSE_BODY_EQ(jsonResponse, response);
TEST_F(HealthTest, ObserveEndpoint)
{
- Try<PID<Master> > master = StartMaster();
+ Try<PID<Master>> master = StartMaster();
ASSERT_SOME(master);
// Empty get to the observe endpoint.
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/scheduler_driver_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_driver_tests.cpp b/src/tests/scheduler_driver_tests.cpp
index 1365d21..f35c495 100644
--- a/src/tests/scheduler_driver_tests.cpp
+++ b/src/tests/scheduler_driver_tests.cpp
@@ -97,10 +97,7 @@ TEST_F(MesosSchedulerDriverTest, MetricsEndpoint)
process::http::get(MetricsProcess::instance()->self(), "/snapshot");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
-
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/scheduler_http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_http_api_tests.cpp b/src/tests/scheduler_http_api_tests.cpp
index 4d23a5a..143bd41 100644
--- a/src/tests/scheduler_http_api_tests.cpp
+++ b/src/tests/scheduler_http_api_tests.cpp
@@ -286,7 +286,7 @@ TEST_P(SchedulerHttpApiTest, Subscribe)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ("chunked", "Transfer-Encoding", response);
ASSERT_EQ(Response::PIPE, response.get().type);
Option<Pipe::Reader> reader = response.get().reader;
@@ -481,7 +481,7 @@ TEST_P(SchedulerHttpApiTest, UpdatePidToHttpScheduler)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ("chunked", "Transfer-Encoding", response);
ASSERT_EQ(Response::PIPE, response.get().type);
Option<Pipe::Reader> reader = response.get().reader;
@@ -547,7 +547,7 @@ TEST_P(SchedulerHttpApiTest, UpdateHttpToPidScheduler)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ("chunked", "Transfer-Encoding", response);
ASSERT_EQ(Response::PIPE, response.get().type);
Option<Pipe::Reader> reader = response.get().reader;
@@ -644,7 +644,7 @@ TEST_P(SchedulerHttpApiTest, UpdatePidToHttpSchedulerWithoutForce)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ("chunked", "Transfer-Encoding", response);
ASSERT_EQ(Response::PIPE, response.get().type);
Option<Pipe::Reader> reader = response.get().reader;
@@ -744,7 +744,7 @@ TEST_P(SchedulerHttpApiTest, NoAcceptHeader)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ(APPLICATION_JSON, response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
}
@@ -778,7 +778,7 @@ TEST_P(SchedulerHttpApiTest, DefaultAccept)
contentType);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
- EXPECT_SOME_EQ(APPLICATION_JSON, response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index eb47b53..076660d 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -71,6 +71,9 @@ using process::PID;
using process::Promise;
using process::UPID;
+using process::http::OK;
+using process::http::Response;
+
using std::map;
using std::shared_ptr;
using std::string;
@@ -100,10 +103,10 @@ class SlaveTest : public MesosTest {};
// immediately and rescinds any offers.
TEST_F(SlaveTest, Shutdown)
{
- Try<PID<Master> > master = StartMaster();
+ Try<PID<Master>> master = StartMaster();
ASSERT_SOME(master);
- Try<PID<Slave> > slave = StartSlave();
+ Try<PID<Slave>> slave = StartSlave();
ASSERT_SOME(slave);
MockScheduler sched;
@@ -112,7 +115,7 @@ TEST_F(SlaveTest, Shutdown)
EXPECT_CALL(sched, registered(&driver, _, _));
- Future<vector<Offer> > offers;
+ Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
@@ -1178,14 +1181,10 @@ TEST_F(SlaveTest, StateEndpoint)
Try<PID<Slave>> slave = StartSlave(&containerizer, flags);
ASSERT_SOME(slave);
- Future<process::http::Response> response =
- process::http::get(slave.get(), "state");
+ Future<Response> response = process::http::get(slave.get(), "state");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
@@ -1294,10 +1293,7 @@ TEST_F(SlaveTest, StateEndpoint)
response = http::get(slave.get(), "state");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
-
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2229,11 +2225,10 @@ TEST_F(SlaveTest, DiscoveryInfoAndPorts)
AWAIT_READY(launchTask);
// Verify label key and value in slave state.json.
- Future<process::http::Response> response =
- process::http::get(slave.get(), "state.json");
+ Future<Response> response = process::http::get(slave.get(), "state.json");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
- EXPECT_SOME_EQ(APPLICATION_JSON, response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2337,13 +2332,10 @@ TEST_F(SlaveTest, TaskLabels)
AWAIT_READY(update);
// Verify label key and value in slave state endpoint.
- Future<process::http::Response> response =
- process::http::get(slave.get(), "state");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(slave.get(), "state");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2439,13 +2431,10 @@ TEST_F(SlaveTest, TaskStatusLabels)
AWAIT_READY(status);
// Verify label key and value in master state.json.
- Future<process::http::Response> response =
- process::http::get(slave.get(), "state.json");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(slave.get(), "state.json");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2536,13 +2525,10 @@ TEST_F(SlaveTest, TaskStatusContainerStatus)
status.get().container_status().network_infos(0).ip_address());
// Now do the same validation with state endpoint.
- Future<process::http::Response> response =
- process::http::get(slave.get(), "state.json");
- AWAIT_READY(response);
+ Future<Response> response = process::http::get(slave.get(), "state.json");
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
ASSERT_SOME(parse);
@@ -2874,7 +2860,7 @@ TEST_F(SlaveTest, HTTPSchedulerLiveUpgrade)
// master (instead of directly to the scheduler!).
TEST_F(SlaveTest, HTTPSchedulerSlaveRestart)
{
- Try<PID<Master> > master = this->StartMaster();
+ Try<PID<Master>> master = this->StartMaster();
ASSERT_SOME(master);
slave::Flags flags = this->CreateSlaveFlags();
@@ -2886,7 +2872,7 @@ TEST_F(SlaveTest, HTTPSchedulerSlaveRestart)
ASSERT_SOME(containerizer);
- Try<PID<Slave> > slave = this->StartSlave(containerizer.get(), flags);
+ Try<PID<Slave>> slave = this->StartSlave(containerizer.get(), flags);
ASSERT_SOME(slave);
// Enable checkpointing for the framework.
@@ -2901,7 +2887,7 @@ TEST_F(SlaveTest, HTTPSchedulerSlaveRestart)
EXPECT_CALL(sched, registered(_, _, _))
.WillOnce(SaveArg<1>(&frameworkId));
- Future<vector<Offer> > offers;
+ Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(_, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/status_update_manager_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/status_update_manager_tests.cpp b/src/tests/status_update_manager_tests.cpp
index bd34b97..24302d8 100644
--- a/src/tests/status_update_manager_tests.cpp
+++ b/src/tests/status_update_manager_tests.cpp
@@ -926,11 +926,7 @@ TEST_F(StatusUpdateManagerTest, DuplicatedTerminalStatusUpdate)
process::http::get(master.get(), "tasks");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, tasks);
-
- AWAIT_EXPECT_RESPONSE_HEADER_EQ(
- "application/json",
- "Content-Type",
- tasks);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", tasks);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(tasks.get().body);
ASSERT_SOME(parse);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d75826e3/src/tests/utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.cpp b/src/tests/utils.cpp
index 877139e..22bf3a8 100644
--- a/src/tests/utils.cpp
+++ b/src/tests/utils.cpp
@@ -16,6 +16,8 @@
#include <gtest/gtest.h>
+#include <mesos/http.hpp>
+
#include <process/future.hpp>
#include <process/gtest.hpp>
#include <process/http.hpp>
@@ -37,11 +39,9 @@ JSON::Object Metrics()
process::Future<process::http::Response> response =
process::http::get(upid, "snapshot");
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
- EXPECT_SOME_EQ(
- "application/json",
- response.get().headers.get("Content-Type"));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
CHECK_SOME(parse);