This is an automated email from the ASF dual-hosted git repository. asekretenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push: new 9bd3ea4 Introduced test for `addSlave()` with maintenance and unknown framework. 9bd3ea4 is described below commit 9bd3ea4665402943af070e64327e8d7dc341e301 Author: Andrei Sekretenko <asekrete...@apache.org> AuthorDate: Fri Apr 3 14:42:40 2020 +0200 Introduced test for `addSlave()` with maintenance and unknown framework. This is a regression test for MESOS-10109. It ensures that allocator continues to work after adding an agent that has an unavailability schedule and resources used by a framework not yet known to allocator. Review: https://reviews.apache.org/r/72315 --- src/tests/hierarchical_allocator_tests.cpp | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp index af99539..d294522 100644 --- a/src/tests/hierarchical_allocator_tests.cpp +++ b/src/tests/hierarchical_allocator_tests.cpp @@ -1056,6 +1056,65 @@ TEST_F(HierarchicalAllocatorTest, SmallOfferFilterTimeout) } +// Tests that allocator continues to work after adding an agent +// that has both maintenance schedule and resources used by not yet known +// frameworks. This is a regression test for MESOS-10109. +TEST_F(HierarchicalAllocatorTest, AddAgentWithUnknownFrameworkAndMaintenance) +{ + // 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(); + + initialize(); + + // Create a fully used agent which is about to enter maintenance + // in a distant future, with resources used by some unknown framework. + const SlaveInfo agent1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); + const FrameworkInfo unknown = createFrameworkInfo({"role"}); + const hashmap<FrameworkID, Resources> used{ + {unknown.id(), agent1.resources()}}; + + allocator->addSlave( + agent1.id(), + agent1, + AGENT_CAPABILITIES(), + protobuf::maintenance::createUnavailability(Clock::now() + Days(365)), + agent1.resources(), + used); + + const FrameworkInfo framework = createFrameworkInfo({"role"}); + allocator->addFramework(framework.id(), framework, {}, true, {}); + + // Create an empty agent. + SlaveInfo agent2 = createSlaveInfo("cpus:2;mem:1024;disk:0"); + allocator->addSlave( + agent2.id(), + agent2, + AGENT_CAPABILITIES(), + None(), + agent2.resources(), + {}); + + // Check that resources of agent2 go to the framework. + const Allocation expected = + Allocation(framework.id(), {{"role", {{agent2.id(), agent2.resources()}}}}); + + AWAIT_EXPECT_EQ(expected, allocations.get()); + + // Add agent2 unavailability to trigger inverse offer generation. + allocator->updateUnavailability( + agent2.id(), + protobuf::maintenance::createUnavailability(Clock::now() + Seconds(60)); + + // Check that resources of agent2 get inverse offered. + Future<Deallocation> deallocation = deallocations.get(); + AWAIT_READY(deallocation); + EXPECT_EQ(framework.id(), deallocation->frameworkId); + EXPECT_TRUE(deallocation->resources.contains(agent2.id())); +} + + // This test ensures that agents which are scheduled for maintenance are // properly sent inverse offers after they have accepted or reserved resources. // It also verifies that the frameworks declined the offer should get no