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/27 13:49:41 UTC

[6/6] mesos git commit: Minor clean ups in `health_check_tests.cpp` for consistency.

Minor clean ups in `health_check_tests.cpp` for consistency.

* Replace `Testing` to `Tests` in comments.
* Remove redundant `.Times(1)`.
* Fix typos.

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


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

Branch: refs/heads/master
Commit: 388bc4d08c574b8e1870e3758d6f1135e7f9f66d
Parents: 02d09e5
Author: haosdent huang <ha...@gmail.com>
Authored: Thu Oct 27 14:27:46 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Thu Oct 27 15:48:46 2016 +0200

----------------------------------------------------------------------
 src/tests/health_check_tests.cpp | 146 +++++++++++++++++-----------------
 1 file changed, 73 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/388bc4d0/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 80bd26f..b1a8942 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -228,7 +228,10 @@ TEST_F(HealthCheckTest, HealthCheckProtobufValidation)
 }
 
 
-// Testing a healthy task reporting one healthy status to scheduler.
+// This test creates a healthy task and verifies that the healthy
+// status is reflected in the status updates sent as reconciliation
+// answers, and in the state endpoint of both the master and the
+// agent.
 TEST_F(HealthCheckTest, HealthyTask)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -242,8 +245,7 @@ TEST_F(HealthCheckTest, HealthyTask)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -259,21 +261,21 @@ TEST_F(HealthCheckTest, HealthyTask)
     populateTasks("sleep 120", "exit 0", offers.get()[0]);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth));
+    .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().has_healthy());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().has_healthy());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   Future<TaskStatus> explicitReconciliation;
   EXPECT_CALL(sched, statusUpdate(&driver, _))
@@ -283,7 +285,7 @@ TEST_F(HealthCheckTest, HealthyTask)
   TaskStatus status;
 
   // Send a task status to trigger explicit reconciliation.
-  const TaskID taskId = statusHealth.get().task_id();
+  const TaskID taskId = statusHealthy.get().task_id();
   status.mutable_task_id()->CopyFrom(taskId);
 
   // State is not checked by reconciliation, but is required to be
@@ -352,8 +354,10 @@ TEST_F(HealthCheckTest, HealthyTask)
 }
 
 
-// Testing a healthy task with a container image using mesos
-// containerizer reporting one healthy status to scheduler.
+// This test creates a healthy task with a container image using mesos
+// containerizer and verifies that the healthy status is reported to the
+// scheduler and is reflected in the state endpoints of both the master
+// and the agent.
 TEST_F(HealthCheckTest, ROOT_HealthyTaskWithContainerImage)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -380,8 +384,7 @@ TEST_F(HealthCheckTest, ROOT_HealthyTaskWithContainerImage)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -412,21 +415,21 @@ TEST_F(HealthCheckTest, ROOT_HealthyTaskWithContainerImage)
   health->mutable_command()->set_value("exit 0");
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth));
+    .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), {task});
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().has_healthy());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().has_healthy());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   // Verify that task health is exposed in the master's state endpoint.
   {
@@ -469,8 +472,8 @@ TEST_F(HealthCheckTest, ROOT_HealthyTaskWithContainerImage)
 }
 
 
-// Testing a healthy task reporting one healthy status to scheduler for
-// docker executor.
+// This test creates a healthy task using the Docker executor and
+// verifies that the healthy status is reported to the scheduler.
 TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTask)
 {
   Shared<Docker> docker(new MockDocker(
@@ -512,8 +515,7 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTask)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -543,11 +545,11 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTask)
                            &MockDockerContainerizer::_launch)));
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth));
+    .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
@@ -556,10 +558,10 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTask)
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().has_healthy());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().has_healthy());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   Future<Option<ContainerTermination>> termination =
     containerizer.wait(containerId.get());
@@ -599,8 +601,7 @@ TEST_F(HealthCheckTest, HealthyTaskNonShell)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -621,27 +622,29 @@ TEST_F(HealthCheckTest, HealthyTaskNonShell)
     populateTasks("sleep 120", command, offers.get()[0]);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth));
+    .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   driver.stop();
   driver.join();
 }
 
 
-// Testing health status change reporting to scheduler.
+// This test creates a task whose health flaps, and verifies that the
+// health status updates are sent to the framework and reflected in the
+// state endpoint of both the master and the agent.
 TEST_F(HealthCheckTest, HealthStatusChange)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -834,7 +837,9 @@ TEST_F(HealthCheckTest, HealthStatusChange)
 }
 
 
-// Testing health status change reporting to scheduler for docker executor.
+// This test creates a task that uses the Docker executor and whose
+// health flaps. It then verifies that the health status updates are
+// sent to the scheduler.
 TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
 {
   Shared<Docker> docker(new MockDocker(
@@ -980,7 +985,8 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
 }
 
 
-// Testing killing task after number of consecutive failures.
+// This test ensures that a task is killed if the number of maximum
+// health check failures is reached.
 TEST_F(HealthCheckTest, ConsecutiveFailures)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -994,8 +1000,7 @@ TEST_F(HealthCheckTest, ConsecutiveFailures)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1057,7 +1062,8 @@ TEST_F(HealthCheckTest, ConsecutiveFailures)
 }
 
 
-// Testing command using environment variable.
+// Tests that the task's env variables are copied to the env used to
+// execute COMMAND health checks.
 TEST_F(HealthCheckTest, EnvironmentSetup)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -1071,8 +1077,7 @@ TEST_F(HealthCheckTest, EnvironmentSetup)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1091,20 +1096,20 @@ TEST_F(HealthCheckTest, EnvironmentSetup)
     "sleep 120", "exit $STATUS", offers.get()[0], 0, None(), env);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
   .WillOnce(FutureArg<1>(&statusRunning))
-  .WillOnce(FutureArg<1>(&statusHealth));
+  .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), tasks);
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   driver.stop();
   driver.join();
@@ -1125,8 +1130,7 @@ TEST_F(HealthCheckTest, GracePeriod)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1167,7 +1171,8 @@ TEST_F(HealthCheckTest, GracePeriod)
 }
 
 
-// Testing continue running health check when check command timeout.
+// This test creates a task with a health check command that will time
+// out, and verifies that the health check is retried after the timeout.
 TEST_F(HealthCheckTest, CheckCommandTimeout)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -1181,8 +1186,7 @@ TEST_F(HealthCheckTest, CheckCommandTimeout)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1226,7 +1230,7 @@ TEST_F(HealthCheckTest, CheckCommandTimeout)
 }
 
 
-// Testing a healthy task via HTTP without specifying `type`. HTTP health
+// Tests a healthy task via HTTP without specifying `type`. HTTP health
 // checks without `type` are allowed for backwards compatibility with the
 // v0 and v1 API.
 //
@@ -1240,9 +1244,6 @@ TEST_F(HealthCheckTest, DISABLED_HealthyTaskViaHTTPWithoutType)
   Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-  flags.isolation = "posix/cpu,posix/mem";
-
   Owned<MasterDetector> detector = master.get()->createDetector();
   Try<Owned<cluster::Slave>> agent = StartSlave(detector.get());
   ASSERT_SOME(agent);
@@ -1251,8 +1252,7 @@ TEST_F(HealthCheckTest, DISABLED_HealthyTaskViaHTTPWithoutType)
   MesosSchedulerDriver driver(
     &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .Times(1);
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1278,21 +1278,21 @@ TEST_F(HealthCheckTest, DISABLED_HealthyTaskViaHTTPWithoutType)
   task.mutable_health_check()->CopyFrom(healthCheck);
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth));
+    .WillOnce(FutureArg<1>(&statusHealthy));
 
   driver.launchTasks(offers.get()[0].id(), {task});
 
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().has_healthy());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().has_healthy());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   driver.stop();
   driver.join();
@@ -1918,11 +1918,11 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTaskViaTCP)
                            &MockDockerContainerizer::_launch)));
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth;
+  Future<TaskStatus> statusHealthy;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth))
+    .WillOnce(FutureArg<1>(&statusHealthy))
     .WillRepeatedly(Return()); // Ignore subsequent updates.
 
   driver.launchTasks(offers.get()[0].id(), {task});
@@ -1932,10 +1932,10 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTaskViaTCP)
   AWAIT_READY(statusRunning);
   EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
 
-  AWAIT_READY(statusHealth);
-  EXPECT_EQ(TASK_RUNNING, statusHealth.get().state());
-  EXPECT_TRUE(statusHealth.get().has_healthy());
-  EXPECT_TRUE(statusHealth.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().has_healthy());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
   Future<Option<ContainerTermination>> termination =
     containerizer.wait(containerId.get());