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/02 03:49:41 UTC
[mesos] 02/02: Added a test that driver re-registration does not
unsuppress offers.
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 285a1b1896a9feb3095b266ab9bbda300103e6eb
Author: Andrei Sekretenko <as...@mesosphere.io>
AuthorDate: Mon Jul 1 23:40:24 2019 -0400
Added a test that driver re-registration does not unsuppress offers.
Review: https://reviews.apache.org/r/70982/
---
src/tests/scheduler_driver_tests.cpp | 57 +++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/src/tests/scheduler_driver_tests.cpp b/src/tests/scheduler_driver_tests.cpp
index 46af8d2..d88e1a1 100644
--- a/src/tests/scheduler_driver_tests.cpp
+++ b/src/tests/scheduler_driver_tests.cpp
@@ -40,7 +40,7 @@
#include <stout/uuid.hpp>
#include "master/allocator/mesos/allocator.hpp"
-
+#include "master/detector/standalone.hpp"
#include "master/master.hpp"
#include "tests/containerizer.hpp"
@@ -379,6 +379,61 @@ TEST_F(MesosSchedulerDriverTest, ExplicitAcknowledgementsMasterGeneratedUpdate)
}
+// This test ensures that re-registration preserves suppression of offers.
+TEST_F(MesosSchedulerDriverTest, ReregisterAfterSuppress)
+{
+ mesos::internal::master::Flags masterFlags = CreateMasterFlags();
+ Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
+ ASSERT_SOME(master);
+
+ ::mesos::master::detector::StandaloneMasterDetector detector;
+ detector.appoint(master.get()->pid);
+
+ MockScheduler sched;
+ TestingMesosSchedulerDriver driver(&sched, &detector, DEFAULT_FRAMEWORK_INFO);
+
+ Future<Nothing> registered;
+ EXPECT_CALL(sched, registered(&driver, _, _))
+ .WillOnce(FutureSatisfy(®istered));
+
+ // Sanity check: the re-registration should occur once.
+ EXPECT_CALL(sched, reregistered(&driver, _))
+ .Times(1);
+
+ // We should never get offers, despite of the re-registration.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .Times(AtMost(0));
+
+ driver.start();
+
+ // Driver might take a different path if suppressOffers() is called in a
+ // disconnected state. We choose a typical path by waiting for registration.
+ AWAIT_READY(registered);
+
+ driver.suppressOffers();
+ Clock::pause();
+ Clock::settle();
+ Clock::resume();
+
+ // Add a slave to get offers if they are not suppressed.
+ Try<Owned<cluster::Slave>> slave = StartSlave(&detector);
+ ASSERT_SOME(slave);
+
+ // Trigger re-registration.
+ detector.appoint(None());
+ detector.appoint(master.get()->pid);
+
+ // Trigger allocation to ensure that offers are still suppressed.
+ Clock::pause();
+ Clock::settle();
+ Clock::advance(masterFlags.allocation_interval);
+ Clock::settle();
+
+ driver.stop();
+ driver.join();
+}
+
+
// This test ensures that the driver handles an empty slave id
// in an acknowledgement message by dropping it. The driver will
// log an error in this case (but we don't test for that). We