You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2019/07/03 21:07:41 UTC
[mesos] 02/03: Added a test for adding a role in a suppressed state.
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 3d8fcaba6428d7865f5de230ab7ab59377c585cf
Author: Andrei Sekretenko <as...@mesosphere.io>
AuthorDate: Wed Jul 3 17:00:45 2019 -0400
Added a test for adding a role in a suppressed state.
Review: https://reviews.apache.org/r/70965/
---
src/tests/master/update_framework_tests.cpp | 62 ++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/src/tests/master/update_framework_tests.cpp b/src/tests/master/update_framework_tests.cpp
index 6ee7b20..9e3cbe0 100644
--- a/src/tests/master/update_framework_tests.cpp
+++ b/src/tests/master/update_framework_tests.cpp
@@ -72,6 +72,8 @@ using process::Promise;
using recordio::Decoder;
+using google::protobuf::RepeatedPtrField;
+
using std::string;
using std::vector;
@@ -190,7 +192,8 @@ class UpdateFrameworkTest : public MesosTest {};
static Future<APIResult> callUpdateFramework(
Mesos* mesos,
- const FrameworkInfo& info)
+ const FrameworkInfo& info,
+ const vector<string>& suppressedRoles = {})
{
CHECK(info.has_id());
@@ -198,6 +201,8 @@ static Future<APIResult> callUpdateFramework(
call.set_type(Call::UPDATE_FRAMEWORK);
*call.mutable_framework_id() = info.id();
*call.mutable_update_framework()->mutable_framework_info() = info;
+ *call.mutable_update_framework()->mutable_suppressed_roles() =
+ RepeatedPtrField<string>(suppressedRoles.begin(), suppressedRoles.end());
return mesos->call(call);
}
@@ -602,6 +607,61 @@ TEST_F(UpdateFrameworkTest, RescindOnRemovingRoles)
}
+// This test ensures that it is possible to add
+// a suppressed role via UPDATE_FRAMEWORK.
+TEST_F(UpdateFrameworkTest, AddSuppressedRole)
+{
+ 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>();
+
+ // Initially, the framework subscribes with no roles.
+ FrameworkInfo initialFrameworkInfo = DEFAULT_FRAMEWORK_INFO;
+ initialFrameworkInfo.clear_roles();
+
+ Future<Nothing> connected;
+ EXPECT_CALL(*scheduler, connected(_))
+ .WillOnce(SendSubscribe(initialFrameworkInfo));
+
+ 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 before update.
+ EXPECT_CALL(*scheduler, offers(_, _))
+ .Times(AtMost(0));
+
+ TestMesos mesos(master->get()->pid, ContentType::PROTOBUF, scheduler);
+
+ AWAIT_READY(subscribed);
+
+ // Add a suppressed role.
+ FrameworkInfo update = initialFrameworkInfo;
+ *update.mutable_id() = subscribed->framework_id();
+ update.add_roles("new_role");
+
+ AWAIT_READY(callUpdateFramework(&mesos, update, {"new_role"}));
+
+ // Trigger allocation to ensure that offers are not generated.
+ Clock::pause();
+ Clock::settle();
+ Clock::advance(masterFlags.allocation_interval);
+ Clock::settle();
+}
+
+
} // namespace scheduler {
} // namespace v1 {