Replaced empty hashmaps with {} in allocator tests. Review: https://reviews.apache.org/r/44334/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/65670296 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/65670296 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/65670296 Branch: refs/heads/master Commit: 656702960f1ec9d59c89d054c1ca7ef4751e2cd9 Parents: 2a9e769 Author: Alexander Rukletsov <ruklet...@gmail.com> Authored: Wed Apr 13 11:35:48 2016 +0200 Committer: Alexander Rukletsov <al...@apache.org> Committed: Wed Apr 13 11:35:48 2016 +0200 ---------------------------------------------------------------------- src/tests/hierarchical_allocator_tests.cpp | 329 +++++++----------------- 1 file changed, 92 insertions(+), 237 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/65670296/src/tests/hierarchical_allocator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp index 1db4635..03064da 100644 --- a/src/tests/hierarchical_allocator_tests.cpp +++ b/src/tests/hierarchical_allocator_tests.cpp @@ -178,7 +178,7 @@ protected: flags.allocation_interval, offerCallback.get(), inverseOfferCallback.get(), - hashmap<string, double>()); + {}); } SlaveInfo createSlaveInfo(const string& resources) @@ -302,17 +302,14 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - // Total cluster resources will become cpus=2, mem=1024. SlaveInfo slave1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), {}); // framework1 will be offered all of slave1's resources since it is // the only framework running so far. FrameworkInfo framework1 = createFrameworkInfo("role1"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -323,8 +320,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // framework1 share = 1 FrameworkInfo framework2 = createFrameworkInfo("role2"); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Total cluster resources will become cpus=3, mem=1536: // role1 share = 0.66 (cpus=2, mem=1024) @@ -332,7 +328,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0 // framework2 share = 0 SlaveInfo slave2 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), {}); // framework2 will be offered all of slave2's resources since role2 // has the lowest user share, and framework2 is its only framework. @@ -352,7 +348,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.16 (cpus=1, mem=512) // framework2 share = 1 SlaveInfo slave3 = createSlaveInfo("cpus:3;mem:2048;disk:0"); - allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), {}); // framework2 will be offered all of slave3's resources since role2 // has the lowest share. @@ -367,8 +363,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // framework2 share = 1 FrameworkInfo framework3 = createFrameworkInfo("role1"); - allocator->addFramework( - framework3.id(), framework3, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework3.id(), framework3, {}); // Total cluster resources will become cpus=10, mem=7680: // role1 share = 0.2 (cpus=2, mem=1024) @@ -377,7 +372,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.4 (cpus=4, mem=2560) // framework2 share = 1 SlaveInfo slave4 = createSlaveInfo("cpus:4;mem:4096;disk:0"); - allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), {}); // framework3 will be offered all of slave4's resources since role1 // has the lowest user share, and framework3 has the lowest share of @@ -394,8 +389,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // framework2 share = 1 FrameworkInfo framework4 = createFrameworkInfo("role1"); - allocator->addFramework( - framework4.id(), framework4, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework4.id(), framework4, {}); // Total cluster resources will become cpus=11, mem=8192 // role1 share = 0.63 (cpus=6, mem=5120) @@ -405,7 +399,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.36 (cpus=4, mem=2560) // framework2 share = 1 SlaveInfo slave5 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(slave5.id(), slave5, None(), slave5.resources(), EMPTY); + allocator->addSlave(slave5.id(), slave5, None(), slave5.resources(), {}); // Even though framework4 doesn't have any resources, role2 has a // lower share than role1, so framework2 receives slave5's resources. @@ -426,17 +420,14 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave1 = createSlaveInfo( "cpus:1;mem:512;disk:0;" "cpus(role1):100;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), {}); // framework1 will be offered all of the resources. FrameworkInfo framework1 = createFrameworkInfo("role1"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -444,12 +435,11 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) EXPECT_EQ(slave1.resources(), Resources::sum(allocation.get().resources)); FrameworkInfo framework2 = createFrameworkInfo("role2"); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // framework2 will be allocated the new resources. SlaveInfo slave2 = createSlaveInfo("cpus:2;mem:512;disk:0"); - allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -459,7 +449,7 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) // Since `framework1` has more resources allocated to it than `framework2`, // We expect `framework2` to receive this agent's resources. SlaveInfo slave3 = createSlaveInfo("cpus:2;mem:512;disk:0"); - allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -471,12 +461,11 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) // expect framework3 to receive the next allocation of role1 // resources. FrameworkInfo framework3 = createFrameworkInfo("role1"); - allocator->addFramework( - framework3.id(), framework3, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework3.id(), framework3, {}); SlaveInfo slave4 = createSlaveInfo( "cpus(role1):2;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -498,25 +487,15 @@ TEST_F(HierarchicalAllocatorTest, OfferFilter) // have had separate roles; this should not influence the test. const string ROLE{"role"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); FrameworkInfo framework1 = createFrameworkInfo(ROLE); SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addSlave( - agent1.id(), - agent1, - None(), - agent1.resources(), - EMPTY); + allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), {}); // `framework1` will be offered all of `agent1` resources // because it is the only framework in the cluster. @@ -588,8 +567,6 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) // have had separate roles; this should not influence the test. const string ROLE{"role"}; - hashmap<FrameworkID, Resources> EMPTY; - // Explicitly set the allocation interval to make sure // it is greater than the offer filter timeout. master::Flags flags_; @@ -602,15 +579,9 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addFramework( - framework2.id(), - framework2, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); allocator->addSlave( agent1.id(), @@ -631,12 +602,7 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) // Add one more agent with some free resources. SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave( - agent2.id(), - agent2, - None(), - agent2.resources(), - EMPTY); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // Process the allocation triggered by the agent addition. Clock::settle(); @@ -739,17 +705,13 @@ TEST_F(HierarchicalAllocatorTest, MaintenanceInverseOffers) initialize(); - // No initial resources. - hashmap<FrameworkID, Resources> EMPTY; - // Create an agent. SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(agent.id(), agent, None(), agent.resources(), EMPTY); + allocator->addSlave(agent.id(), agent, None(), agent.resources(), {}); // This framework will be offered all of the resources. FrameworkInfo framework1 = createFrameworkInfo("*"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); // Check that the resources go to the framework. Future<Allocation> allocation = allocations.get(); @@ -796,20 +758,17 @@ TEST_F(HierarchicalAllocatorTest, CoarseGrained) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), {}); SlaveInfo slave2 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), {}); // Once framework1 is added, an allocation will occur. Return the // resources so that we can test what happens when there are 2 // frameworks and 2 slaves to consider during allocation. FrameworkInfo framework1 = createFrameworkInfo("role1"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -831,8 +790,7 @@ TEST_F(HierarchicalAllocatorTest, CoarseGrained) // Now add the second framework, we expect there to be 2 subsequent // allocations, each framework being allocated a full slave. FrameworkInfo framework2 = createFrameworkInfo("role2"); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); hashmap<FrameworkID, Allocation> frameworkAllocations; @@ -868,18 +826,14 @@ TEST_F(HierarchicalAllocatorTest, SameShareFairness) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - FrameworkInfo framework1 = createFrameworkInfo("*"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); FrameworkInfo framework2 = createFrameworkInfo("*"); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); SlaveInfo slave = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Ensure that the slave's resources are alternated between both // frameworks. @@ -915,27 +869,24 @@ TEST_F(HierarchicalAllocatorTest, Reservations) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave1 = createSlaveInfo( "cpus(role1):2;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), {}); SlaveInfo slave2 = createSlaveInfo( "cpus(role2):2;mem(role2):1024;cpus:1;mem:1024;disk:0"); - allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), {}); // This slave's resources should never be allocated, since there // is no framework for role3. SlaveInfo slave3 = createSlaveInfo( "cpus(role3):1;mem(role3):1024;disk(role3):0"); - allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), {}); // framework1 should get all the resources from slave1, and the // unreserved resources from slave2. FrameworkInfo framework1 = createFrameworkInfo("role1"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -948,8 +899,7 @@ TEST_F(HierarchicalAllocatorTest, Reservations) // framework2 should get all of its reserved resources on slave2. FrameworkInfo framework2 = createFrameworkInfo("role2"); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -968,17 +918,14 @@ TEST_F(HierarchicalAllocatorTest, RecoverResources) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo( "cpus(role1):1;mem(role1):200;" "cpus:1;mem:200;disk:0"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Initially, all the resources are allocated. FrameworkInfo framework1 = createFrameworkInfo("role1"); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -1035,24 +982,21 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) initialize(); FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); - - hashmap<FrameworkID, Resources> EMPTY; + allocator->addFramework(framework.id(), framework, {}); // Not enough memory or cpu to be considered allocatable. SlaveInfo slave1 = createSlaveInfo( "cpus:" + stringify(MIN_CPUS / 2) + ";" "mem:" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), {}); // Enough cpus to be considered allocatable. SlaveInfo slave2 = createSlaveInfo( "cpus:" + stringify(MIN_CPUS) + ";" "mem:" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -1066,7 +1010,7 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) "cpus:" + stringify(MIN_CPUS / 2) + ";" "mem:" + stringify((MIN_MEM).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -1083,7 +1027,7 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) "cpus(role1):" + stringify(MIN_CPUS / 1.5) + ";" "mem(role1):" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), {}); allocation = allocations.get(); AWAIT_READY(allocation); @@ -1102,15 +1046,12 @@ TEST_F(HierarchicalAllocatorTest, UpdateAllocation) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Initially, all the resources are allocated. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -1174,10 +1115,8 @@ TEST_F(HierarchicalAllocatorTest, UpdateAvailableSuccess) { initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Construct an offer operation for the framework's allocation. Resources unreserved = Resources::parse("cpus:25;mem:50").get(); @@ -1192,8 +1131,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateAvailableSuccess) // Expect to receive the updated available resources. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -1219,15 +1157,12 @@ TEST_F(HierarchicalAllocatorTest, UpdateAvailableFail) { initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Expect to receive the all of the available resources. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -1257,18 +1192,15 @@ TEST_F(HierarchicalAllocatorTest, UpdateSlave) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Add a framework that can accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); framework.add_capabilities()->set_type( FrameworkInfo::Capability::REVOCABLE_RESOURCES); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); // Initially, all the resources are allocated. Future<Allocation> allocation = allocations.get(); @@ -1315,15 +1247,12 @@ TEST_F(HierarchicalAllocatorTest, OversubscribedNotAllocated) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Add a framework that does *not* accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); // Initially, all the resources are allocated. Future<Allocation> allocation = allocations.get(); @@ -1351,18 +1280,15 @@ TEST_F(HierarchicalAllocatorTest, RecoverOversubscribedResources) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); // Add a framework that can accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); framework.add_capabilities()->set_type( FrameworkInfo::Capability::REVOCABLE_RESOURCES); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); // Initially, all the resources are allocated. Future<Allocation> allocation = allocations.get(); @@ -1408,14 +1334,11 @@ TEST_F(HierarchicalAllocatorTest, Whitelist) allocator->updateWhitelist(whitelist); - hashmap<FrameworkID, Resources> EMPTY; - SlaveInfo slave = createSlaveInfo("cpus:2;mem:1024"); - allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), {}); FrameworkInfo framework = createFrameworkInfo("*"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); @@ -1474,22 +1397,18 @@ TEST_F(HierarchicalAllocatorTest, QuotaProvidesGuarantee) const string QUOTA_ROLE{"quota-role"}; const string NO_QUOTA_ROLE{"no-quota-role"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); // Create `framework1` and set quota for its role. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); const Quota quota1 = createQuota(QUOTA_ROLE, "cpus:2;mem:1024"); allocator->setQuota(QUOTA_ROLE, quota1); // Create `framework2` in a non-quota'ed role. FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -1497,7 +1416,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaProvidesGuarantee) Clock::settle(); SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), EMPTY); + allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), {}); // `framework1` will be offered all of `agent1`'s resources because it is // the only framework in the only role with unsatisfied quota. @@ -1513,7 +1432,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaProvidesGuarantee) // framework2 share = 0 SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), EMPTY); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // `framework1` will again be offered all of `agent2`'s resources // because it is the only framework in the only role with unsatisfied @@ -1604,15 +1523,9 @@ TEST_F(HierarchicalAllocatorTest, RemoveQuota) // Notify allocator of agents, frameworks, quota and current allocations. allocator->setQuota(QUOTA_ROLE, quota1); - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addFramework( - framework2.id(), - framework2, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); allocator->addSlave( agent1.id(), @@ -1699,22 +1612,18 @@ TEST_F(HierarchicalAllocatorTest, MultipleFrameworksInRoleWithQuota) const string QUOTA_ROLE{"quota-role"}; const string NO_QUOTA_ROLE{"no-quota-role"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); // Create `framework1a` and set quota for its role. FrameworkInfo framework1a = createFrameworkInfo(QUOTA_ROLE); - allocator->addFramework( - framework1a.id(), framework1a, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1a.id(), framework1a, {}); const Quota quota1 = createQuota(QUOTA_ROLE, "cpus:4;mem:2048"); allocator->setQuota(QUOTA_ROLE, quota1); // Create `framework2` in a non-quota'ed role. FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -1722,7 +1631,7 @@ TEST_F(HierarchicalAllocatorTest, MultipleFrameworksInRoleWithQuota) Clock::settle(); SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), EMPTY); + allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), {}); // `framework1a` will be offered all of `agent1`'s resources because // it is the only framework in the only role with unsatisfied quota. @@ -1739,11 +1648,10 @@ TEST_F(HierarchicalAllocatorTest, MultipleFrameworksInRoleWithQuota) // Create `framework1b` in the quota'ed role. FrameworkInfo framework1b = createFrameworkInfo(QUOTA_ROLE); - allocator->addFramework( - framework1b.id(), framework1b, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1b.id(), framework1b, {}); SlaveInfo agent2 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), EMPTY); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // `framework1b` will be offered all of `agent2`'s resources // (coarse-grained allocation) because its share is 0 and it belongs @@ -1761,7 +1669,7 @@ TEST_F(HierarchicalAllocatorTest, MultipleFrameworksInRoleWithQuota) // framework2 share = 0 SlaveInfo agent3 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(agent3.id(), agent3, None(), agent3.resources(), EMPTY); + allocator->addSlave(agent3.id(), agent3, None(), agent3.resources(), {}); // `framework1a` will be offered all of `agent3`'s resources because // its share is less than `framework1b`'s and `QUOTA_ROLE` still @@ -1820,14 +1728,11 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationGranularity) const string QUOTA_ROLE{"quota-role"}; const string NO_QUOTA_ROLE{"no-quota-role"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); // Create `framework1` and set quota for its role. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); // Set quota to be less than the agent resources. const Quota quota1 = createQuota(QUOTA_ROLE, "cpus:0.5;mem:200"); @@ -1835,8 +1740,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationGranularity) // Create `framework2` in a non-quota'ed role. FrameworkInfo framework2 = createFrameworkInfo(NO_QUOTA_ROLE); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -1844,7 +1748,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationGranularity) Clock::settle(); SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), EMPTY); + allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), {}); // `framework1` will be offered all of `agent1`'s resources because // it is the only framework in the only role with unsatisfied quota @@ -1889,15 +1793,9 @@ TEST_F(HierarchicalAllocatorTest, DRFWithQuota) // Notify allocator of agents, frameworks, quota and current allocations. allocator->setQuota(QUOTA_ROLE, quota1); - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addFramework( - framework2.id(), - framework2, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -1975,12 +1873,7 @@ TEST_F(HierarchicalAllocatorTest, DRFWithQuota) // framework2 share = 1 SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave( - agent2.id(), - agent2, - None(), - agent2.resources(), - hashmap<FrameworkID, Resources>()); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // `framework2` will be offered all of `agent2`'s resources (coarse-grained // allocation). `framework1` does not receive them even though it has a @@ -2022,15 +1915,9 @@ TEST_F(HierarchicalAllocatorTest, QuotaAgainstStarvation) SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512;disk:0"); // Notify allocator of agents, frameworks, and current allocations. - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addFramework( - framework2.id(), - framework2, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); allocator->addSlave( agent1.id(), @@ -2050,12 +1937,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAgainstStarvation) // NO_QUOTA_ROLE share = 0 // framework2 share = 0 - allocator->addSlave( - agent2.id(), - agent2, - None(), - agent2.resources(), - hashmap<FrameworkID, Resources>()); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // Free cluster resources on `agent2` will be allocated to `framework2` // because its share is 0. @@ -2138,8 +2020,6 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) const string QUOTA_ROLE{"quota-role"}; const string NO_QUOTA_ROLE{"no-quota-role"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); // Set quota for the quota'ed role. This role isn't registered with @@ -2149,8 +2029,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) // Add `framework` in the non-quota'ed role. FrameworkInfo framework = createFrameworkInfo(NO_QUOTA_ROLE); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); // Process all triggered allocation events. // @@ -2171,8 +2050,8 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework) // NOTE: The second event-based allocation for `agent2` takes into account // that `agent1`'s resources are laid away for `QUOTA_ROLE`'s quota and // hence freely allocates for the non-quota'ed `NO_QUOTA_ROLE` role. - allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), EMPTY); - allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), EMPTY); + allocator->addSlave(agent1.id(), agent1, None(), agent1.resources(), {}); + allocator->addSlave(agent2.id(), agent2, None(), agent2.resources(), {}); // `framework` can only be allocated resources on `agent2`. This // is due to the coarse-grained nature of the allocations. All the @@ -2216,13 +2095,11 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaAbsentFrameworks) const string QUOTA_ROLE1{"quota-role-1"}; const string QUOTA_ROLE2{"quota-role-2"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); SlaveInfo agent = createSlaveInfo("cpus:2;mem:2048;disk:0"); - allocator->addSlave(agent.id(), agent, None(), agent.resources(), EMPTY); + allocator->addSlave(agent.id(), agent, None(), agent.resources(), {}); // Set quota for both roles. const Quota quota1 = createQuota(QUOTA_ROLE1, "cpus:1;mem:1024"); @@ -2233,8 +2110,7 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaAbsentFrameworks) // Add a framework in the `QUOTA_ROLE2` role. FrameworkInfo framework = createFrameworkInfo(QUOTA_ROLE2); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); // Due to the coarse-grained nature of the allocations, `framework` will // get all `agent`'s resources. @@ -2261,8 +2137,6 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) const string QUOTA_ROLE1{"quota-role-1"}; const string QUOTA_ROLE2{"quota-role-2"}; - hashmap<FrameworkID, Resources> EMPTY; - initialize(); SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:1024;disk:0"); @@ -2277,13 +2151,11 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) // Add `framework1` in the `QUOTA_ROLE1` role. FrameworkInfo framework1 = createFrameworkInfo(QUOTA_ROLE1); - allocator->addFramework( - framework1.id(), framework1, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); // Add `framework2` in the `QUOTA_ROLE2` role. FrameworkInfo framework2 = createFrameworkInfo(QUOTA_ROLE2); - allocator->addFramework( - framework2.id(), framework2, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -2316,12 +2188,7 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks) SlaveInfo agent3 = createSlaveInfo("cpus:2;mem:2048"); - allocator->addSlave( - agent3.id(), - agent3, - None(), - agent3.resources(), - EMPTY); + allocator->addSlave(agent3.id(), agent3, None(), agent3.resources(), {}); // `framework2` will get all agent3's resources because its role is under // quota, while other roles' quotas are satisfied. @@ -2359,15 +2226,9 @@ TEST_F(HierarchicalAllocatorTest, ReservationWithinQuota) // Notify allocator of agents, frameworks, quota and current allocations. allocator->setQuota(QUOTA_ROLE, quota); - allocator->addFramework( - framework1.id(), - framework1, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework1.id(), framework1, {}); - allocator->addFramework( - framework2.id(), - framework2, - hashmap<SlaveID, Resources>()); + allocator->addFramework(framework2.id(), framework2, {}); // Process all triggered allocation events. // @@ -2424,17 +2285,14 @@ TEST_F(HierarchicalAllocatorTest, DeactivateAndReactivateFramework) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - // Total cluster resources will become cpus=2, mem=1024. SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(agent.id(), agent, None(), agent.resources(), EMPTY); + allocator->addSlave(agent.id(), agent, None(), agent.resources(), {}); // Framework will be offered all of the agent's resources since it is // the only framework running so far. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation); @@ -3049,17 +2907,14 @@ TEST_F(HierarchicalAllocatorTest, ReviveOffers) initialize(); - hashmap<FrameworkID, Resources> EMPTY; - // Total cluster resources will become cpus=2, mem=1024. SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(agent.id(), agent, None(), agent.resources(), EMPTY); + allocator->addSlave(agent.id(), agent, None(), agent.resources(), {}); // Framework will be offered all of agent's resources since it is // the only framework running so far. FrameworkInfo framework = createFrameworkInfo("role1"); - allocator->addFramework( - framework.id(), framework, hashmap<SlaveID, Resources>()); + allocator->addFramework(framework.id(), framework, {}); Future<Allocation> allocation = allocations.get(); AWAIT_READY(allocation);