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:12 UTC

[4/5] mesos git commit: Improved the naming of variables in HealthCheckTest.HealthStatusChange.

Improved the naming of variables in HealthCheckTest.HealthStatusChange.

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


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

Branch: refs/heads/master
Commit: be4e42f0680326c26179174bd5ef1d828733d3e7
Parents: 59f6333
Author: Gast�n Kleiman <ga...@mesosphere.com>
Authored: Wed Oct 5 18:12:26 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Oct 5 18:24:29 2016 +0200

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/be4e42f0/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 250affd..27889dc 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -684,30 +684,32 @@ TEST_F(HealthCheckTest, HealthStatusChange)
   //   - Attempt to remove the nonexistent temporary file.
   //   - Create the temporary file.
   //   - Exit with a non-zero status.
-  string alt = "rm " + tmpPath + " || (touch " + tmpPath + " && exit 1)";
+  const string healthCheckCmd =
+    "rm " + tmpPath + " || (touch " + tmpPath + " && exit 1)";
 
   vector<TaskInfo> tasks = populateTasks(
-      "sleep 120", alt, offers.get()[0], 0, 3);
+      "sleep 120", healthCheckCmd, offers.get()[0], 0, 3);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth1;
-  Future<TaskStatus> statusHealth2;
-  Future<TaskStatus> statusHealth3;
+  Future<TaskStatus> statusHealthy;
+  Future<TaskStatus> statusUnhealthy;
+  Future<TaskStatus> statusHealthyAgain;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth1))
-    .WillOnce(FutureArg<1>(&statusHealth2))
-    .WillOnce(FutureArg<1>(&statusHealth3));
+    .WillOnce(FutureArg<1>(&statusHealthy))
+    .WillOnce(FutureArg<1>(&statusUnhealthy))
+    .WillOnce(FutureArg<1>(&statusHealthyAgain))
+    .WillRepeatedly(Return()); // Ignore subsequent updates.
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth1);
-  EXPECT_EQ(TASK_RUNNING, statusHealth1.get().state());
-  EXPECT_TRUE(statusHealth1.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   // Verify that task health is exposed in the master's state endpoint.
   {
@@ -745,9 +747,9 @@ TEST_F(HealthCheckTest, HealthStatusChange)
     EXPECT_SOME_TRUE(find);
   }
 
-  AWAIT_READY(statusHealth2);
-  EXPECT_EQ(TASK_RUNNING, statusHealth2.get().state());
-  EXPECT_FALSE(statusHealth2.get().healthy());
+  AWAIT_READY(statusUnhealthy);
+  EXPECT_EQ(TASK_RUNNING, statusUnhealthy.get().state());
+  EXPECT_FALSE(statusUnhealthy.get().healthy());
 
   // Verify that the task health change is reflected in the master's
   // state endpoint.
@@ -787,9 +789,9 @@ TEST_F(HealthCheckTest, HealthStatusChange)
     EXPECT_SOME_FALSE(find);
   }
 
-  AWAIT_READY(statusHealth3);
-  EXPECT_EQ(TASK_RUNNING, statusHealth3.get().state());
-  EXPECT_TRUE(statusHealth3.get().healthy());
+  AWAIT_READY(statusHealthyAgain);
+  EXPECT_EQ(TASK_RUNNING, statusHealthyAgain.get().state());
+  EXPECT_TRUE(statusHealthyAgain.get().healthy());
 
   // Verify through master's state endpoint that the task is back to a
   // healthy state.