You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2019/07/15 22:48:20 UTC
[mesos] 02/04: Added a test to ensure that roles with only
reservations are exposed.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit d4cb3a34ce00aa6177f6d206c552e309ad250598
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Mon Jul 15 16:47:02 2019 -0400
Added a test to ensure that roles with only reservations are exposed.
This adds a test for MESOS-9888, to ensure that if a role has only
reservations associated with it, it gets exposed from /roles.
Review: https://reviews.apache.org/r/71074
---
src/tests/role_tests.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/src/tests/role_tests.cpp b/src/tests/role_tests.cpp
index 5066e41..5a6a01a 100644
--- a/src/tests/role_tests.cpp
+++ b/src/tests/role_tests.cpp
@@ -34,6 +34,8 @@
#include "tests/mesos.hpp"
#include "tests/resources_utils.hpp"
+#include "tests/master/mock_master_api_subscriber.hpp"
+
using mesos::internal::master::Master;
using mesos::internal::slave::Slave;
@@ -870,7 +872,81 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesQuotas)
EXPECT_EQ(*expected, *parse)
<< "expected " << stringify(*expected)
- << " vs actual " << stringify(*parse);}
+ << " vs actual " << stringify(*parse);
+}
+
+
+// This test ensures that roles with only reservations are
+// included in the /roles endpoint.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesReservations)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ v1::MockMasterAPISubscriber subscriber;
+
+ AWAIT_READY(subscriber.subscribe(master.get()->pid));
+
+ Future<Nothing> agentAdded;
+ EXPECT_CALL(subscriber, agentAdded(_))
+ .WillOnce(FutureSatisfy(&agentAdded));
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ slave::Flags agentFlags = CreateSlaveFlags();
+ agentFlags.resources = "cpus(role):1;mem(role):10";
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), agentFlags);
+
+ AWAIT_READY(agentAdded);
+
+ // Check that the /roles endpoint contains the role.
+ {
+ Future<Response> response = process::http::get(
+ master.get()->pid,
+ "roles",
+ None(),
+ createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+
+ Try<JSON::Value> parse = JSON::parse(response->body);
+ ASSERT_SOME(parse);
+
+ Try<JSON::Value> expected = JSON::parse(
+ "{"
+ " \"roles\": ["
+ " {"
+ " \"frameworks\": [],"
+ " \"name\": \"role\","
+ " \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"quota\": {"
+ " \"consumed\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"guarantee\": {},"
+ " \"limit\": {},"
+ " \"role\": \"role\""
+ " },"
+ " \"weight\": 1.0"
+ " }"
+ " ]"
+ "}");
+
+ ASSERT_SOME(expected);
+
+ EXPECT_EQ(*expected, *parse)
+ << "expected " << stringify(*expected)
+ << " vs actual " << stringify(*parse);
+ }
+}
// This test ensures that master adds/removes all roles of