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 2015/05/14 01:59:28 UTC
[4/4] mesos git commit: Moved the slave shutdown test into
slave_tests.cpp.
Moved the slave shutdown test into slave_tests.cpp.
Review: https://reviews.apache.org/r/33152
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/085c75cb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/085c75cb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/085c75cb
Branch: refs/heads/master
Commit: 085c75cb7447d594a1418e048c877601de75131e
Parents: 288e588
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Apr 13 17:32:22 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Wed May 13 16:45:30 2015 -0700
----------------------------------------------------------------------
src/tests/fault_tolerance_tests.cpp | 48 --------------------------------
src/tests/slave_tests.cpp | 47 +++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/085c75cb/src/tests/fault_tolerance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fault_tolerance_tests.cpp b/src/tests/fault_tolerance_tests.cpp
index 3a27d82..cd2594b 100644
--- a/src/tests/fault_tolerance_tests.cpp
+++ b/src/tests/fault_tolerance_tests.cpp
@@ -86,54 +86,6 @@ namespace tests {
class FaultToleranceTest : public MesosTest {};
-// This test checks that when a slave is lost,
-// its offer(s) is rescinded.
-TEST_F(FaultToleranceTest, SlaveLost)
-{
- Try<PID<Master> > master = StartMaster();
- ASSERT_SOME(master);
-
- Try<PID<Slave> > slave = StartSlave();
- ASSERT_SOME(slave);
-
- MockScheduler sched;
- MesosSchedulerDriver driver(
- &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
- EXPECT_CALL(sched, registered(&driver, _, _));
-
- Future<vector<Offer> > offers;
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers))
- .WillRepeatedly(Return()); // Ignore subsequent offers.
-
- driver.start();
-
- AWAIT_READY(offers);
- EXPECT_EQ(1u, offers.get().size());
-
- Future<Nothing> offerRescinded;
- EXPECT_CALL(sched, offerRescinded(&driver, offers.get()[0].id()))
- .WillOnce(FutureSatisfy(&offerRescinded));
-
- Future<Nothing> slaveLost;
- EXPECT_CALL(sched, slaveLost(&driver, offers.get()[0].slave_id()))
- .WillOnce(FutureSatisfy(&slaveLost));
-
- // Stop the checkpointing slave with explicit shutdown message
- // so that the master does not wait for it to reconnect.
- Stop(slave.get(), true);
-
- AWAIT_READY(offerRescinded);
- AWAIT_READY(slaveLost);
-
- driver.stop();
- driver.join();
-
- Shutdown();
-}
-
-
// The purpose of this test is to ensure that when slaves are removed
// from the master, and then attempt to send status updates, we send
// a ShutdownMessage to the slave. Why? Because during a network
http://git-wip-us.apache.org/repos/asf/mesos/blob/085c75cb/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 04e79ec..066cbb0 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -97,6 +97,53 @@ namespace http = process::http;
class SlaveTest : public MesosTest {};
+// This test ensures that when a slave shuts itself down, it
+// unregisters itself and the master notifies the framework
+// immediately and rescinds any offers.
+TEST_F(SlaveTest, Shutdown)
+{
+ Try<PID<Master> > master = StartMaster();
+ ASSERT_SOME(master);
+
+ Try<PID<Slave> > slave = StartSlave();
+ ASSERT_SOME(slave);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+ EXPECT_CALL(sched, registered(&driver, _, _));
+
+ Future<vector<Offer> > offers;
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers))
+ .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+ driver.start();
+
+ AWAIT_READY(offers);
+ EXPECT_EQ(1u, offers.get().size());
+
+ Future<Nothing> offerRescinded;
+ EXPECT_CALL(sched, offerRescinded(&driver, offers.get()[0].id()))
+ .WillOnce(FutureSatisfy(&offerRescinded));
+
+ Future<Nothing> slaveLost;
+ EXPECT_CALL(sched, slaveLost(&driver, offers.get()[0].slave_id()))
+ .WillOnce(FutureSatisfy(&slaveLost));
+
+ // Stop the checkpointing slave with explicit shutdown message
+ // so that the slave unregisters.
+ Stop(slave.get(), true);
+
+ AWAIT_READY(offerRescinded);
+ AWAIT_READY(slaveLost);
+
+ driver.stop();
+ driver.join();
+}
+
+
TEST_F(SlaveTest, ShutdownUnregisteredExecutor)
{
Try<PID<Master>> master = StartMaster();