You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2016/10/05 16:26:11 UTC

[3/5] mesos git commit: Updated and reenabled 'HealthCheckTest.GracePeriod'.

Updated and reenabled 'HealthCheckTest.GracePeriod'.

This test was disabled in 2014 because it was considered flaky.
The test is now updated and run 1000 times without a single failure.

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


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

Branch: refs/heads/master
Commit: 59f63332aa1d60b7088e1998076ac79467ee712e
Parents: 4c6ba2a
Author: Gast�n Kleiman <ga...@mesosphere.com>
Authored: Wed Oct 5 18:10:52 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Oct 5 18:24:28 2016 +0200

----------------------------------------------------------------------
 src/tests/health_check_tests.cpp | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/59f63332/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 2c7a585..250affd 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -17,7 +17,6 @@
 #include <mesos/executor.hpp>
 #include <mesos/scheduler.hpp>
 
-#include <process/clock.hpp>
 #include <process/future.hpp>
 #include <process/owned.hpp>
 #include <process/pid.hpp>
@@ -55,7 +54,6 @@ using mesos::master::detector::MasterDetector;
 using mesos::slave::ContainerLogger;
 using mesos::slave::ContainerTermination;
 
-using process::Clock;
 using process::Future;
 using process::Owned;
 using process::PID;
@@ -1117,8 +1115,8 @@ TEST_F(HealthCheckTest, EnvironmentSetup)
 }
 
 
-// Testing grace period that ignores all failed task failures.
-TEST_F(HealthCheckTest, DISABLED_GracePeriod)
+// Tests that health check failures are ignored during the grace period.
+TEST_F(HealthCheckTest, GracePeriod)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
@@ -1144,33 +1142,29 @@ TEST_F(HealthCheckTest, DISABLED_GracePeriod)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
+  // The health check for this task will always fail, but the grace period of
+  // 9999 seconds should mask the failures.
   vector<TaskInfo> tasks = populateTasks(
-    "sleep 120", "exit 1", offers.get()[0], 6);
+    "sleep 2", "false", offers.get()[0], 9999);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusFinished;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth))
+    .WillOnce(FutureArg<1>(&statusFinished))
     .WillRepeatedly(Return());
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
-  Clock::pause();
-  EXPECT_TRUE(statusHealth.isPending());
+  AWAIT_READY(statusRunning);
+  EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
+  EXPECT_FALSE(statusRunning.get().has_healthy());
 
   // No task unhealthy update should be called in grace period.
-  Clock::advance(Seconds(5));
-  EXPECT_TRUE(statusHealth.isPending());
-
-  Clock::advance(Seconds(1));
-  Clock::settle();
-  Clock::resume();
-
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_FALSE(statusHealth.get().healthy());
+  AWAIT_READY(statusFinished);
+  EXPECT_EQ(TASK_FINISHED, statusFinished.get().state());
+  EXPECT_FALSE(statusFinished.get().has_healthy());
 
   driver.stop();
   driver.join();