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:21 UTC
[mesos] 03/04: Added a test to ensure that ancestor roles are
exposed in /roles.
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 f99e181d34a78ef304f9072a6685f33be99ea07f
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Mon Jul 15 17:07:58 2019 -0400
Added a test to ensure that ancestor roles are exposed in /roles.
This adds a test for MESOS-9890, to ensure that ancestor roles with
no objects directly associated with them get exposed in /roles.
Review: https://reviews.apache.org/r/71077
---
src/tests/role_tests.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
diff --git a/src/tests/role_tests.cpp b/src/tests/role_tests.cpp
index 5a6a01a..7a6c8a6 100644
--- a/src/tests/role_tests.cpp
+++ b/src/tests/role_tests.cpp
@@ -949,6 +949,105 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesReservations)
}
+// This test ensures that ancestor roles are exposed when
+// there are no direct objects associated with them.
+//
+// TODO(bmahler): This currently only tests the reservation
+// case, but we should also test the allocation, framework
+// subsription, and quota/weight configuration cases.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesAncestors)
+{
+ 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(ancestor/child):1;mem(ancestor/child):10;";
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), agentFlags);
+
+ AWAIT_READY(agentAdded);
+
+ // Check that the /roles endpoint contains the role and
+ // its ancestor.
+ {
+ 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\": \"ancestor\","
+ " \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"quota\": {"
+ " \"consumed\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"guarantee\": {},"
+ " \"limit\": {},"
+ " \"role\": \"ancestor\""
+ " },"
+ " \"weight\": 1.0"
+ " },"
+ " {"
+ " \"frameworks\": [],"
+ " \"name\": \"ancestor/child\","
+ " \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"quota\": {"
+ " \"consumed\": {"
+ " \"cpus\": 1.0,"
+ " \"mem\": 10.0"
+ " },"
+ " \"guarantee\": {},"
+ " \"limit\": {},"
+ " \"role\": \"ancestor/child\""
+ " },"
+ " \"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
// a multi-role framework when it registers/terminates.
TEST_F_TEMP_DISABLED_ON_WINDOWS(