You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/12/01 23:17:50 UTC
[2/3] mesos git commit: Fixed 'NoOffersWithAllRolesSuppressed' test.
Fixed 'NoOffersWithAllRolesSuppressed' test.
Review: https://reviews.apache.org/r/63830
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3711233f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3711233f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3711233f
Branch: refs/heads/master
Commit: 3711233fcec761be8625af6a028a228fe9d8dc5a
Parents: 5d9209e
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Nov 10 12:15:37 2017 -0800
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Fri Dec 1 15:11:23 2017 -0800
----------------------------------------------------------------------
src/tests/scheduler_tests.cpp | 46 ++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3711233f/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 45fc9c0..566ffb3 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -45,12 +45,13 @@
#include "internal/devolve.hpp"
#include "internal/evolve.hpp"
+#include "master/constants.hpp"
+#include "master/master.hpp"
+
#include "master/allocator/mesos/allocator.hpp"
#include "master/detector/standalone.hpp"
-#include "master/master.hpp"
-
#include "tests/containerizer.hpp"
#include "tests/mesos.hpp"
@@ -1450,9 +1451,9 @@ TEST_P(SchedulerTest, Suppress)
}
-// TODO(alexr): Re-enable this test after MESOS-8200 is resolved and the test
-// itself is fixed as well, see MESOS-7996.
-TEST_P(SchedulerTest, DISABLED_NoOffersWithAllRolesSuppressed)
+// This test verifies that when a framework registers with all roles
+// suppressing offers, it does not receive offers.
+TEST_P(SchedulerTest, NoOffersWithAllRolesSuppressed)
{
master::Flags flags = CreateMasterFlags();
@@ -1460,9 +1461,17 @@ TEST_P(SchedulerTest, DISABLED_NoOffersWithAllRolesSuppressed)
ASSERT_SOME(master);
Owned<MasterDetector> detector = master.get()->createDetector();
+
+ Future<SlaveRegisteredMessage> slaveRegisteredMessage =
+ FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
+
Try<Owned<cluster::Slave>> slave = StartSlave(detector.get());
ASSERT_SOME(slave);
+ AWAIT_READY(slaveRegisteredMessage);
+
+ Clock::pause();
+
auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
@@ -1482,12 +1491,15 @@ TEST_P(SchedulerTest, DISABLED_NoOffersWithAllRolesSuppressed)
EXPECT_CALL(*scheduler, subscribed(_, _))
.WillOnce(FutureArg<1>(&subscribed));
+ Future<Nothing> heartbeat;
EXPECT_CALL(*scheduler, heartbeat(_))
- .WillRepeatedly(Return()); // Ignore heartbeats.
+ .WillOnce(FutureSatisfy(&heartbeat));
+ // The framework will subscribe with its role being suppressed so no
+ // offers should be received by the framework.
Future<Event::Offers> offers;
EXPECT_CALL(*scheduler, offers(_, _))
- .Times(0); // No offers extended since all roles are suppressed.
+ .Times(0);
{
Call call;
@@ -1502,19 +1514,25 @@ TEST_P(SchedulerTest, DISABLED_NoOffersWithAllRolesSuppressed)
mesos.send(call);
}
- // Since the framework is subscribed with its role being suppressed, no
- // offers should be received by the framework.
- Clock::pause();
- Clock::advance(flags.allocation_interval);
- Clock::resume();
-
AWAIT_READY(subscribed);
+ AWAIT_READY(heartbeat);
+
+ // We use an additional heartbeat as a synchronization mechanism to make
+ // sure an offer would be received by the scheduler if one was ever extended.
+ // Note that Clock::settle() wouldn't be sufficient here.
+ EXPECT_CALL(*scheduler, heartbeat(_))
+ .WillOnce(FutureSatisfy(&heartbeat))
+ .WillRepeatedly(Return()); // Ignore additional heartbeats.
+
+ Clock::advance(master::DEFAULT_HEARTBEAT_INTERVAL);
+ AWAIT_READY(heartbeat);
+
v1::FrameworkID frameworkId(subscribed->framework_id());
+ // On revival the scheduler should get an offer.
EXPECT_CALL(*scheduler, offers(_, _))
.WillOnce(FutureArg<1>(&offers));
- // On revival the scheduler should get an offer.
{
Call call;
call.mutable_framework_id()->CopyFrom(frameworkId);