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 8394526126646fe7590e3462491973256216d2ef
Author: Andrei Sekretenko <[email protected]>
AuthorDate: Wed Jul 3 17:01:04 2019 -0400

    Added a test for removing a role from both roles and suppressed roles.
    
    Review: https://reviews.apache.org/r/70966/
---
 src/tests/master/update_framework_tests.cpp | 63 +++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/src/tests/master/update_framework_tests.cpp 
b/src/tests/master/update_framework_tests.cpp
index 9e3cbe0..dda09fc 100644
--- a/src/tests/master/update_framework_tests.cpp
+++ b/src/tests/master/update_framework_tests.cpp
@@ -662,6 +662,69 @@ TEST_F(UpdateFrameworkTest, AddSuppressedRole)
 }
 
 
+// Helper action for RemoveAndUnsuppress.
+ACTION_P(SendSubscribeWithAllRolesSuppressed, framework)
+{
+  Call call;
+  call.set_type(Call::SUBSCRIBE);
+  *call.mutable_subscribe()->mutable_framework_info() = framework;
+  *call.mutable_subscribe()->mutable_suppressed_roles() = framework.roles();
+
+  arg0->send(call);
+}
+
+
+// This test ensures that it is possible to remove roles both from the roles
+// set and the suppressed roles set.
+TEST_F(UpdateFrameworkTest, RemoveAndUnsuppress)
+{
+  mesos::internal::master::Flags masterFlags = CreateMasterFlags();
+  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
+  ASSERT_SOME(master);
+
+  Owned<MasterDetector> detector = master->get()->createDetector();
+
+  mesos::internal::slave::Flags slaveFlags = CreateSlaveFlags();
+  Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
+  ASSERT_SOME(slave);
+
+  auto scheduler = std::make_shared<MockHTTPScheduler>();
+
+  Future<Nothing> connected;
+  EXPECT_CALL(*scheduler, connected(_))
+    .WillOnce(SendSubscribeWithAllRolesSuppressed(DEFAULT_FRAMEWORK_INFO));
+
+  EXPECT_CALL(*scheduler, heartbeat(_))
+    .WillRepeatedly(Return()); // Ignore heartbeats.
+
+  Future<Event::Subscribed> subscribed;
+
+  EXPECT_CALL(*scheduler, subscribed(_, _))
+    .WillOnce(FutureArg<1>(&subscribed));
+
+  // Expect that the framework gets no offers.
+  EXPECT_CALL(*scheduler, offers(_, _))
+    .Times(AtMost(0));
+
+  TestMesos mesos(master->get()->pid, ContentType::PROTOBUF, scheduler);
+
+  AWAIT_READY(subscribed);
+
+  // Remove suppressed roles while unsuppressing them.
+  FrameworkInfo update = DEFAULT_FRAMEWORK_INFO;
+  *update.mutable_id() = subscribed->framework_id();
+  update.clear_roles();
+
+  AWAIT_READY(callUpdateFramework(&mesos, update, {}));
+
+  // Trigger allocation to ensure that nothing happens.
+  Clock::pause();
+  Clock::settle();
+  Clock::advance(masterFlags.allocation_interval);
+  Clock::settle();
+}
+
+
 } // namespace scheduler {
 } // namespace v1 {
 

Reply via email to