Restructured comments in allocator tests for clarity. We now describe the cluster state **after** we induce such a state, rather than before.
Review: https://reviews.apache.org/r/42658/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c2c41e46 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c2c41e46 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c2c41e46 Branch: refs/heads/master Commit: c2c41e46358163243e3b4a66bfbccfdbc0302e0c Parents: d85412e Author: Alexander Rukletsov <[email protected]> Authored: Tue Feb 9 18:37:41 2016 +0100 Committer: Benjamin Mahler <[email protected]> Committed: Tue Feb 9 20:00:42 2016 +0100 ---------------------------------------------------------------------- src/tests/hierarchical_allocator_tests.cpp | 102 +++++++++++------------- 1 file changed, 48 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/c2c41e46/src/tests/hierarchical_allocator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp index 8183135..f09517d 100644 --- a/src/tests/hierarchical_allocator_tests.cpp +++ b/src/tests/hierarchical_allocator_tests.cpp @@ -544,12 +544,6 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) initialize(flags_); - // We start with the following cluster setup. - // Total cluster resources (1 agent): cpus=1, mem=512. - // ROLE1 share = 1 (cpus=1, mem=512) - // framework1 share = 1 (cpus=1, mem=512) - // framework2 share = 0 - FrameworkInfo framework1 = createFrameworkInfo(ROLE); FrameworkInfo framework2 = createFrameworkInfo(ROLE); @@ -577,6 +571,11 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) // NOTE: No allocations happen because there are no resources to allocate. Clock::settle(); + // Total cluster resources (1 agent): cpus=1, mem=512. + // ROLE1 share = 1 (cpus=1, mem=512) + // framework1 share = 1 (cpus=1, mem=512) + // framework2 share = 0 + // Add one more agent with some free resources. SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); allocator->addSlave( @@ -1549,13 +1548,6 @@ TEST_F(HierarchicalAllocatorTest, RemoveQuota) initialize(); - // We start with the following cluster setup. - // Total cluster resources (2 identical agents): cpus=2, mem=1024. - // QUOTA_ROLE share = 1 (cpus=2, mem=1024) [quota: cpus=2, mem=1024] - // framework1 share = 1 - // NO_QUOTA_ROLE share = 0 - // framework2 share = 0 - // Create framework and agent descriptions. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE); FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); @@ -1592,6 +1584,12 @@ TEST_F(HierarchicalAllocatorTest, RemoveQuota) agent2.resources(), {std::make_pair(framework1.id(), agent2.resources())}); + // Total cluster resources (2 identical agents): cpus=2, mem=1024. + // QUOTA_ROLE share = 1 (cpus=2, mem=1024) [quota: cpus=2, mem=1024] + // framework1 share = 1 + // NO_QUOTA_ROLE share = 0 + // framework2 share = 0 + // All cluster resources are now being used by `framework1` as part of // its role quota, no further allocations are expected. However, once the // quota is removed, quota guarantee does not apply any more and released @@ -1820,13 +1818,6 @@ TEST_F(HierarchicalAllocatorTest, DRFWithQuota) initialize(); - // We start with the following cluster setup. - // Total cluster resources (1 agent): cpus=1, mem=512. - // QUOTA_ROLE share = 0.25 (cpus=0.25, mem=128) [quota: cpus=0.25, mem=128] - // framework1 share = 1 - // NO_QUOTA_ROLE share = 0 - // framework2 share = 0 - // Create framework and agent descriptions. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE); FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); @@ -1860,6 +1851,12 @@ TEST_F(HierarchicalAllocatorTest, DRFWithQuota) agent1.resources(), {std::make_pair(framework1.id(), Resources(quota1.info.guarantee()))}); + // Total cluster resources (1 agent): cpus=1, mem=512. + // QUOTA_ROLE share = 0.25 (cpus=0.25, mem=128) [quota: cpus=0.25, mem=128] + // framework1 share = 1 + // NO_QUOTA_ROLE share = 0 + // framework2 share = 0 + // Some resources on `agent1` are now being used by `framework1` as part // of its role quota. All quotas are satisfied, all available resources // should be allocated according to fair shares of roles and frameworks. @@ -1918,13 +1915,6 @@ TEST_F(HierarchicalAllocatorTest, QuotaAgainstStarvation) initialize(); - // We start with the following cluster setup. - // Total cluster resources (2 identical agents): cpus=2, mem=1024. - // QUOTA_ROLE share = 0.5 (cpus=1, mem=512) - // framework1 share = 1 - // NO_QUOTA_ROLE share = 0 - // framework2 share = 0 - // Create framework and agent descriptions. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE); FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); @@ -1955,6 +1945,12 @@ TEST_F(HierarchicalAllocatorTest, QuotaAgainstStarvation) // NOTE: No allocations happen because all resources are already allocated. Clock::settle(); + // Total cluster resources (1 agent): cpus=1, mem=512. + // QUOTA_ROLE share = 1 (cpus=1, mem=512) + // framework1 share = 1 + // NO_QUOTA_ROLE share = 0 + // framework2 share = 0 + allocator->addSlave( agent2.id(), agent2, @@ -2047,13 +2043,6 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) initialize(); - // We start with the following cluster setup. - // Total cluster resources (2 agents): cpus=3, mem=1536. - // QUOTA_ROLE share = 0 [quota: cpus=2, mem=1024] - // no frameworks - // NO_QUOTA_ROLE share = 0 - // framework share = 1 - // Set quota for the quota'ed role. This role isn't registered with // the allocator yet. const Quota quota1 = createQuota(QUOTA_ROLE, "cpus:2;mem:1024"); @@ -2072,6 +2061,12 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) SlaveInfo agent1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); + // Total cluster resources (0 agents): 0. + // QUOTA_ROLE share = 0 [quota: cpus=2, mem=1024] + // no frameworks + // NO_QUOTA_ROLE share = 0 + // framework share = 0 + // Each `addSlave()` triggers an event-based allocation. // // NOTE: The second event-based allocation for `agent2` takes into account @@ -2080,13 +2075,6 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), EMPTY); allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), EMPTY); - // Total cluster resources (2 agents): cpus=3, mem=1536. - // QUOTA_ROLE share = 0 [quota: cpus=2, mem=1024], but - // some resources (cpus=2, mem=1024) are laid away - // no frameworks - // NO_QUOTA_ROLE share = 0.33 - // framework share = 1 (cpus=1, mem=512) - // `framework` can only be allocated resources on `agent2`. This // is due to the coarse-grained nature of the allocations. All the // free resources on `agent1` would be considered to construct an @@ -2101,6 +2089,13 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) AWAIT_READY(allocation); EXPECT_EQ(framework.id(), allocation.get().frameworkId); EXPECT_EQ(agent2.resources(), Resources::sum(allocation.get().resources)); + + // Total cluster resources (2 agents): cpus=3, mem=1536. + // QUOTA_ROLE share = 0 [quota: cpus=2, mem=1024], but + // (cpus=2, mem=1024) are laid away + // no frameworks + // NO_QUOTA_ROLE share = 0.33 + // framework share = 1 (cpus=1, mem=512) } @@ -2171,13 +2166,6 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) initialize(); - // We start with the following cluster setup. - // Total cluster resources (2 identical agents): cpus=2, mem=2048. - // QUOTA_ROLE1 share = 0.5 (cpus=1, mem=1024) [quota: cpus=1, mem=200] - // framework1 share = 1 - // QUOTA_ROLE2 share = 0.5 (cpus=1, mem=1024) [quota: cpus=2, mem=2000] - // framework2 share = 1 - SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:1024;disk:0"); SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:1024;disk:0"); @@ -2217,6 +2205,12 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) agent2.resources(), {std::make_pair(framework2.id(), agent2.resources())}); + // Total cluster resources (2 identical agents): cpus=2, mem=2048. + // QUOTA_ROLE1 share = 0.5 (cpus=1, mem=1024) [quota: cpus=1, mem=200] + // framework1 share = 1 + // QUOTA_ROLE2 share = 0.5 (cpus=1, mem=1024) [quota: cpus=2, mem=2000] + // framework2 share = 1 + // Quota for the `QUOTA_ROLE1` role is satisfied, while `QUOTA_ROLE2` is // under quota. Hence resources of the newly added agent should be offered // to the framework in `QUOTA_ROLE2`. @@ -2230,18 +2224,18 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) agent3.resources(), EMPTY); - // Total cluster resources (3 agents): cpus=4, mem=4096. - // QUOTA_ROLE1 share = 0.25 (cpus=1, mem=1024) [quota: cpus=1, mem=200] - // framework1 share = 1 - // QUOTA_ROLE2 share = 0.75 (cpus=3, mem=3072) [quota: cpus=2, mem=2000] - // framework2 share = 1 - // `framework2` will get all agent3's resources because its role is under // quota, while other roles' quotas are satisfied. Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); EXPECT_EQ(framework2.id(), allocation.get().frameworkId); EXPECT_EQ(agent3.resources(), Resources::sum(allocation.get().resources)); + + // Total cluster resources (3 agents): cpus=4, mem=4096. + // QUOTA_ROLE1 share = 0.25 (cpus=1, mem=1024) [quota: cpus=1, mem=200] + // framework1 share = 1 + // QUOTA_ROLE2 share = 0.75 (cpus=3, mem=3072) [quota: cpus=2, mem=2000] + // framework2 share = 1 }
