You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/10/17 00:44:22 UTC
[03/14] mesos git commit: Replaced unnecessary future chaining in
api_tests.cpp.
Replaced unnecessary future chaining in api_tests.cpp.
Instead of chaining response code check on a response future,
leverage `AWAIT_EXPECT_RESPONSE_STATUS_EQ` macro.
Review: https://reviews.apache.org/r/63007
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d7931559
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d7931559
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d7931559
Branch: refs/heads/master
Commit: d79315594ef14dd854c1b7a18875d9c84eff890a
Parents: e9edc91
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Oct 11 20:04:15 2017 -0700
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Mon Oct 16 17:02:48 2017 -0700
----------------------------------------------------------------------
src/tests/api_tests.cpp | 64 +++++++++++++-------------------------------
1 file changed, 19 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d7931559/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 3d0db3b..706dd9a 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -1326,20 +1326,14 @@ TEST_P(MasterAPITest, GetMaintenanceStatus)
v1UpdateScheduleCall.mutable_update_maintenance_schedule();
maintenanceSchedule->mutable_schedule()->CopyFrom(v1Schedule);
- Future<Nothing> v1UpdateScheduleResponse = http::post(
+ Future<http::Response> v1UpdateScheduleResponse = http::post(
master.get()->pid,
"api/v1",
headers,
serialize(contentType, v1UpdateScheduleCall),
- stringify(contentType))
- .then([](const http::Response& response) -> Future<Nothing> {
- if (response.status != http::OK().status) {
- return Failure("Unexpected response status " + response.status);
- }
- return Nothing();
- });
+ stringify(contentType));
- AWAIT_READY(v1UpdateScheduleResponse);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, v1UpdateScheduleResponse);
// Query maintenance status.
v1::master::Call v1GetStatusCall;
@@ -3012,20 +3006,16 @@ TEST_P(MasterAPITest, CreateAndDestroyVolumes)
http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
headers["Accept"] = stringify(contentType);
- Future<Nothing> v1CreateVolumesResponse = http::post(
+ Future<http::Response> v1CreateVolumesResponse = http::post(
master.get()->pid,
"api/v1",
headers,
serialize(contentType, v1CreateVolumesCall),
- stringify(contentType))
- .then([](const http::Response& response) -> Future<Nothing> {
- if (response.status != http::Accepted().status) {
- return Failure("Unexpected response status " + response.status);
- }
- return Nothing();
- });
+ stringify(contentType));
- AWAIT_READY(v1CreateVolumesResponse);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::Accepted().status,
+ v1CreateVolumesResponse);
FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
frameworkInfo.set_role("role1");
@@ -3084,20 +3074,16 @@ TEST_P(MasterAPITest, CreateAndDestroyVolumes)
destroyVolumes->mutable_agent_id()->CopyFrom(evolve(slaveId));
destroyVolumes->add_volumes()->CopyFrom(evolve(volume));
- Future<Nothing> v1DestroyVolumesResponse = http::post(
+ Future<http::Response> v1DestroyVolumesResponse = http::post(
master.get()->pid,
"api/v1",
headers,
serialize(contentType, v1DestroyVolumesCall),
- stringify(contentType))
- .then([](const http::Response& response) -> Future<Nothing> {
- if (response.status != http::Accepted().status) {
- return Failure("Unexpected response status " + response.status);
- }
- return Nothing();
- });
+ stringify(contentType));
- AWAIT_READY(v1DestroyVolumesResponse);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::Accepted().status,
+ v1DestroyVolumesResponse);
EXPECT_CALL(exec, shutdown(_))
.Times(AtMost(1));
@@ -3164,20 +3150,14 @@ TEST_P(MasterAPITest, UpdateWeights)
http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
headers["Accept"] = stringify(contentType);
- Future<Nothing> updateResponse = http::post(
+ Future<http::Response> updateResponse = http::post(
master.get()->pid,
"api/v1",
headers,
serialize(contentType, updateCall),
- stringify(contentType))
- .then([](const http::Response& response) -> Future<Nothing> {
- if (response.status != http::OK().status) {
- return Failure("Unexpected response status " + response.status);
- }
- return Nothing();
- });
+ stringify(contentType));
- AWAIT_READY(updateResponse);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, updateResponse);
getResponse = post(master.get()->pid, getCall, contentType);
@@ -4045,20 +4025,14 @@ TEST_P(AgentAPITest, SetLoggingLevel)
http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
headers["Accept"] = stringify(contentType);
- Future<Nothing> v1Response = http::post(
+ Future<http::Response> v1Response = http::post(
slave.get()->pid,
"api/v1",
headers,
serialize(contentType, v1Call),
- stringify(contentType))
- .then([](const http::Response& response) -> Future<Nothing> {
- if (response.status != http::OK().status) {
- return Failure("Unexpected response status " + response.status);
- }
- return Nothing();
- });
+ stringify(contentType));
- AWAIT_READY(v1Response);
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, v1Response);
ASSERT_EQ(toggleLevel, static_cast<uint32_t>(FLAGS_v));
// Speedup the logging level revert.