mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nniel...@apache.org
Subject mesos git commit: Fixed a race condition in hook tests for remove-executor hook.
Date Wed, 24 Jun 2015 18:28:37 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 8bc1893f2 -> 6b00c3243


Fixed a race condition in hook tests for remove-executor hook.

Previously, the code was not checking for TASK_RUNNING status message
from the MockExecutor before stopping the scheduler driver. This caused
the Executor to be terminated prematurely (before the tasks were
launched) and thus the remove-executor hook was never called. The fix
was to wait for the TASK_RUNNING status update and then wait for the
shutdown() within MockExecutor. Only then we wait for the future from
remove-executor hook.

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


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

Branch: refs/heads/master
Commit: 6b00c3243324b89fe35f1f6699c6c2e4293a3f94
Parents: 8bc1893
Author: Kapil Arya <kapil@mesosphere.io>
Authored: Tue Jun 23 15:47:34 2015 -0700
Committer: Niklas Q. Nielsen <nik@qni.dk>
Committed: Wed Jun 24 11:26:49 2015 -0700

----------------------------------------------------------------------
 src/tests/hook_tests.cpp | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6b00c324/src/tests/hook_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hook_tests.cpp b/src/tests/hook_tests.cpp
index 3ffde6d..806ba03 100644
--- a/src/tests/hook_tests.cpp
+++ b/src/tests/hook_tests.cpp
@@ -255,7 +255,7 @@ TEST_F(HookTest, VerifySlaveExecutorEnvironmentDecorator)
 // Test executor environment decorator hook and remove executor hook
 // for slave. We expect the environment-decorator hook to create a
 // temporary file and the remove-executor hook to delete that file.
-TEST_F(HookTest, DISABLED_VerifySlaveLaunchExecutorHook)
+TEST_F(HookTest, VerifySlaveLaunchExecutorHook)
 {
   master::Flags masterFlags = CreateMasterFlags();
 
@@ -298,11 +298,19 @@ TEST_F(HookTest, DISABLED_VerifySlaveLaunchExecutorHook)
   vector<TaskInfo> tasks;
   tasks.push_back(task);
 
-  EXPECT_CALL(exec, launchTask(_, _));
+  EXPECT_CALL(exec, registered(_, _, _, _));
+
+  EXPECT_CALL(exec, launchTask(_, _))
+    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
 
-  Future<ExecutorInfo> executorInfo;
-  EXPECT_CALL(exec, registered(_, _, _, _))
-    .WillOnce(FutureArg<1>(&executorInfo));
+  // Executor shutdown would force the Slave to execute the
+  // remove-executor hook.
+  EXPECT_CALL(exec, shutdown(_));
+
+  Future<TaskStatus> status;
+  EXPECT_CALL(sched, statusUpdate(&driver, _))
+    .WillOnce(FutureArg<1>(&status))
+    .WillRepeatedly(Return());
 
   // On successful completion of the "slaveLaunchExecutorHook", the
   // test hook will send a HookExecuted message to itself. We wait
@@ -311,15 +319,18 @@ TEST_F(HookTest, DISABLED_VerifySlaveLaunchExecutorHook)
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
-  AWAIT_READY(executorInfo);
+  AWAIT_READY(status);
 
   driver.stop();
   driver.join();
 
-  Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
-
-  // Now wait for the hook to finish execution.
+  // The scheduler shutdown from above forces the executor to
+  // shutdown. This in turn should force the Slave to execute
+  // the remove-executor hook.
+  // Here, we wait for the hook to finish execution.
   AWAIT_READY(hookFuture);
+
+  Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
 }
 
 


Mime
View raw message