mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [1/2] git commit: Added a SIGUSR1 shutdown test.
Date Thu, 19 Jun 2014 03:41:03 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 6c385a9da -> aaef6bcf9


Added a SIGUSR1 shutdown test.

Review: https://reviews.apache.org/r/22737


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/aaef6bcf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/aaef6bcf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/aaef6bcf

Branch: refs/heads/master
Commit: aaef6bcf9be799dda82b207c6f6cb1cbaf02f0fc
Parents: 671b4c4
Author: Alexandra Sava <alexandrasava18@gmail.com>
Authored: Wed Jun 18 18:07:06 2014 -0700
Committer: Benjamin Mahler <bmahler@twitter.com>
Committed: Wed Jun 18 20:40:57 2014 -0700

----------------------------------------------------------------------
 src/tests/slave_recovery_tests.cpp | 74 +++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/aaef6bcf/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 9a73348..9274b1a 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -1777,6 +1777,80 @@ TYPED_TEST(SlaveRecoveryTest, ShutdownSlave)
 }
 
 
+// The slave should shutdown when it receives a SIGUSR1 signal.
+TYPED_TEST(SlaveRecoveryTest, ShutdownSlaveSIGUSR1)
+{
+  Try<PID<Master> > master = this->StartMaster();
+  ASSERT_SOME(master);
+
+  slave::Flags flags = this->CreateSlaveFlags();
+
+  Try<TypeParam*> containerizer = TypeParam::create(flags, true);
+  ASSERT_SOME(containerizer);
+
+  Try<PID<Slave> > slave = this->StartSlave(containerizer.get(), flags);
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+
+  // Enable checkpointing for the framework.
+  FrameworkInfo frameworkInfo;
+  frameworkInfo.CopyFrom(DEFAULT_FRAMEWORK_INFO);
+  frameworkInfo.set_checkpoint(true);
+
+  MesosSchedulerDriver driver(
+      &sched, frameworkInfo, master.get(), DEFAULT_CREDENTIAL);
+
+  EXPECT_CALL(sched, registered(_, _, _));
+
+  Future<vector<Offer> > offers;
+  EXPECT_CALL(sched, resourceOffers(_, _))
+    .WillOnce(FutureArg<1>(&offers))  // Initial offer.
+    .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+  driver.start();
+
+  AWAIT_READY(offers);
+
+  EXPECT_NE(0u, offers.get().size());
+
+  TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+  vector<TaskInfo> tasks;
+  tasks.push_back(task); // Long-running task.
+
+  Future<Nothing> statusUpdate;
+  EXPECT_CALL(sched, statusUpdate(_, _))
+    .WillOnce(FutureSatisfy(&statusUpdate))
+    .WillRepeatedly(Return());
+
+  driver.launchTasks(offers.get()[0].id(), tasks);
+
+  // Wait for TASK_RUNNING update to be acknowledged.
+  AWAIT_READY(statusUpdate);
+
+  Future<Nothing> executorTerminated =
+    FUTURE_DISPATCH(_, &Slave::executorTerminated);
+
+  Future<Nothing> signaled =
+    FUTURE_DISPATCH(_, &Slave::signaled);
+
+  // Send SIGUSR1 signal to the slave.
+  kill(getpid(), SIGUSR1);
+
+  AWAIT_READY(signaled);
+  AWAIT_READY(executorTerminated);
+
+  // Make sure the slave terminates.
+  ASSERT_TRUE(process::wait(slave.get(), Seconds(10)));
+
+  driver.stop();
+  driver.join();
+
+  this->Shutdown();
+  delete containerizer.get();
+}
+
+
 // The checkpointing slave fails to do recovery and tries to register
 // as a new slave. The master should give it a new id and transition
 // all the tasks of the old slave to LOST.


Mime
View raw message