You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/06/13 22:34:32 UTC
[3/4] mesos git commit: Added a test for hierarchical reservation.
Added a test for hierarchical reservation.
Review: https://reviews.apache.org/r/58510/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d2e26564
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d2e26564
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d2e26564
Branch: refs/heads/master
Commit: d2e26564d5c7ebcbf84ed0c1de328371fcbf6db0
Parents: 61ea8bb
Author: Jay Guo <gu...@gmail.com>
Authored: Tue Jun 13 12:20:20 2017 -0700
Committer: Michael Park <mc...@gmail.com>
Committed: Tue Jun 13 15:34:17 2017 -0700
----------------------------------------------------------------------
src/tests/hierarchical_allocator_tests.cpp | 63 +++++++++++++++++++++++++
1 file changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d2e26564/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index 631e800..d6c5904 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -4498,6 +4498,69 @@ TEST_F(HierarchicalAllocatorTest, DisproportionateQuotaVsAllocation)
}
+// This test ensures that resources reserved to ancestor roles can be offered
+// to their descendants. Since both quota and fair-share stages perform
+// reservation allocations, we use a quota'd role to test both cases.
+TEST_F(HierarchicalAllocatorTest, OfferAncestorReservationsToDescendantChild)
+{
+ // Pausing the clock is not necessary, but ensures that the test
+ // doesn't rely on the batch allocation in the allocator, which
+ // would slow down the test.
+ Clock::pause();
+
+ const string ROLE{"a/b/c"};
+
+ initialize();
+
+ const Quota quota = createQuota(ROLE, "cpus:1;mem:512");
+ allocator->setQuota(ROLE, quota);
+
+ FrameworkInfo framework = createFrameworkInfo({ROLE});
+ allocator->addFramework(framework.id(), framework, {}, true, {});
+
+ SlaveInfo agent1 = createSlaveInfo("cpus(a):1;mem(a):512;disk(a):0;");
+ allocator->addSlave(
+ agent1.id(),
+ agent1,
+ AGENT_CAPABILITIES(),
+ None(),
+ agent1.resources(),
+ {});
+
+ {
+ // All the resources of agent1 are offered, and this
+ // should satisfy the quota of ROLE.
+ Allocation expected = Allocation(
+ framework.id(),
+ {{ROLE, {{agent1.id(), agent1.resources()}}}});
+
+ AWAIT_EXPECT_EQ(expected, allocations.get());
+ }
+
+
+ SlaveInfo agent2 = createSlaveInfo(
+ "cpus:2;mem:1024;disk:0;"
+ "cpus(a/b):4;mem(a/b):2048;disk(a/b):0");
+ allocator->addSlave(
+ agent2.id(),
+ agent2,
+ AGENT_CAPABILITIES(),
+ None(),
+ agent2.resources(),
+ {});
+
+ {
+ // Since quota of ROLE is already satisfied by agent1,
+ // we expect only reserved resource of agent2 is offered.
+ Allocation expected = Allocation(
+ framework.id(),
+ {{ROLE, {{agent2.id(), Resources(agent2.resources()).reserved()}}}});
+
+ AWAIT_EXPECT_EQ(expected, allocations.get());
+ }
+}
+
+
// This test checks that quota guarantees work as expected when a
// nested role is created as a child of an existing quota'd role.
TEST_F(HierarchicalAllocatorTest, NestedRoleQuota)