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/11/25 15:39:31 UTC

[1/2] mesos git commit: Ignored subsequent status update in HealthStatusChange tests.

Repository: mesos
Updated Branches:
  refs/heads/master 08da1ee8a -> 83863c7d5


Ignored subsequent status update in HealthStatusChange tests.

In HealthStatusChange test cases, we launch a task that toggles between
healthy and unhealthy, and will never be killed because no consecutive
health failures occur. We need to ignore subsequent status updates: it
is possible to continue to receive status updates before we stop the
driver.

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


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

Branch: refs/heads/master
Commit: a7a1ced113ee6a6633bbb0d78f401d0c01e5205b
Parents: 08da1ee
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Nov 25 16:32:48 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 16:32:48 2016 +0100

----------------------------------------------------------------------
 src/tests/health_check_tests.cpp | 48 ++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a7a1ced1/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index a4436bd..3443de6 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -839,7 +839,7 @@ TEST_F(HealthCheckTest, HealthStatusChange)
 
 // 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.
+// sent to the framework.
 TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
 {
   Shared<Docker> docker(new MockDocker(
@@ -901,8 +901,8 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
   dockerInfo.set_image("alpine");
   containerInfo.mutable_docker()->CopyFrom(dockerInfo);
 
-  // Create a temporary file in host and then we could this file to make sure
-  // the health check command is run in docker container.
+  // Create a temporary file in host and then we could this file to
+  // make sure the health check command is run in docker container.
   string tmpPath = path::join(os::getcwd(), "foobar");
   ASSERT_SOME(os::write(tmpPath, "bar"));
 
@@ -916,11 +916,12 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
   //
   // Case 1:
   //   - Remove the temporary file.
-  string alt = "rm " + tmpPath + " || (mkdir -p " + os::getcwd() +
-               " && echo foo >" + tmpPath + " && exit 1)";
+  const string healthCheckCmd =
+    "rm " + tmpPath + " || "
+    "(mkdir -p " + os::getcwd() + " && echo foo >" + tmpPath + " && exit 1)";
 
   vector<TaskInfo> tasks = populateTasks(
-      "sleep 120", alt, offers.get()[0], 0, 3, None(), containerInfo);
+      "sleep 60", healthCheckCmd, offers.get()[0], 0, 3, None(), containerInfo);
 
   Future<ContainerID> containerId;
   EXPECT_CALL(containerizer, launch(_, _, _, _, _, _, _, _))
@@ -929,35 +930,36 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
                            &MockDockerContainerizer::_launch)));
 
   Future<TaskStatus> statusRunning;
-  Future<TaskStatus> statusHealth1;
-  Future<TaskStatus> statusHealth2;
-  Future<TaskStatus> statusHealth3;
+  Future<TaskStatus> statusUnhealthy;
+  Future<TaskStatus> statusHealthy;
+  Future<TaskStatus> statusUnhealthyAgain;
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillOnce(FutureArg<1>(&statusRunning))
-    .WillOnce(FutureArg<1>(&statusHealth1))
-    .WillOnce(FutureArg<1>(&statusHealth2))
-    .WillOnce(FutureArg<1>(&statusHealth3));
+    .WillOnce(FutureArg<1>(&statusUnhealthy))
+    .WillOnce(FutureArg<1>(&statusHealthy))
+    .WillOnce(FutureArg<1>(&statusUnhealthyAgain))
+    .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_FALSE(statusHealth1.get().healthy());
+  AWAIT_READY(statusUnhealthy);
+  EXPECT_EQ(TASK_RUNNING, statusUnhealthy.get().state());
+  EXPECT_FALSE(statusUnhealthy.get().healthy());
 
-  AWAIT_READY(statusHealth2);
-  EXPECT_EQ(TASK_RUNNING, statusHealth2.get().state());
-  EXPECT_TRUE(statusHealth2.get().healthy());
+  AWAIT_READY(statusHealthy);
+  EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
+  EXPECT_TRUE(statusHealthy.get().healthy());
 
-  AWAIT_READY(statusHealth3);
-  EXPECT_EQ(TASK_RUNNING, statusHealth3.get().state());
-  EXPECT_FALSE(statusHealth3.get().healthy());
+  AWAIT_READY(statusUnhealthyAgain);
+  EXPECT_EQ(TASK_RUNNING, statusUnhealthyAgain.get().state());
+  EXPECT_FALSE(statusUnhealthyAgain.get().healthy());
 
-  // Check the temporary file created in host still exists and the content
-  // don't change.
+  // Check the temporary file created in host still exists and the
+  // content don't change.
   ASSERT_SOME(os::read(tmpPath));
   EXPECT_EQ("bar", os::read(tmpPath).get());
 


[2/2] mesos git commit: Dropped http status check in HealthCheckTest.HealthStatusChange.

Posted by al...@apache.org.
Dropped http status check in HealthCheckTest.HealthStatusChange.

Drop http status check because so far we could not guarantee the
http queries order match the `statusUpdate` order or arrive in
sync, i.e., before the next status update has been processed.

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


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

Branch: refs/heads/master
Commit: 83863c7d56ca91f5aa3f5df2dd4887d589462eaf
Parents: a7a1ced
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Nov 25 16:33:07 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 16:38:49 2016 +0100

----------------------------------------------------------------------
 src/tests/health_check_tests.cpp | 121 ++--------------------------------
 1 file changed, 4 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/83863c7d/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 3443de6..3b0125e 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -643,8 +643,7 @@ TEST_F(HealthCheckTest, HealthyTaskNonShell)
 
 
 // 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.
+// health status updates are sent to the framework scheduler.
 TEST_F(HealthCheckTest, HealthStatusChange)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
@@ -712,126 +711,14 @@ TEST_F(HealthCheckTest, HealthStatusChange)
   EXPECT_EQ(TASK_RUNNING, statusHealthy.get().state());
   EXPECT_TRUE(statusHealthy.get().healthy());
 
-  // Verify that task health is exposed in the master's state endpoint.
-  {
-    Future<http::Response> response = http::get(
-        master.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_TRUE(find);
-  }
-
-  // Verify that task health is exposed in the agent's state endpoint.
-  {
-    Future<http::Response> response = http::get(
-        agent.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].executors[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_TRUE(find);
-  }
-
   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.
-  {
-    Future<http::Response> response = http::get(
-        master.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_FALSE(find);
-  }
-
-  // Verify that the task health change is reflected in the agent's
-  // state endpoint.
-  {
-    Future<http::Response> response = http::get(
-        agent.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].executors[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_FALSE(find);
-  }
-
   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.
-  {
-    Future<http::Response> response = http::get(
-        master.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_TRUE(find);
-  }
-
-  // Verify through agent's state endpoint that the task is back to a
-  // healthy state.
-  {
-    Future<http::Response> response = http::get(
-        agent.get()->pid,
-        "state",
-        None(),
-        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
-
-    AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
-
-    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
-    ASSERT_SOME(parse);
-
-    Result<JSON::Value> find = parse.get().find<JSON::Value>(
-        "frameworks[0].executors[0].tasks[0].statuses[0].healthy");
-    EXPECT_SOME_TRUE(find);
-  }
-
   driver.stop();
   driver.join();
 }
@@ -839,7 +726,7 @@ TEST_F(HealthCheckTest, HealthStatusChange)
 
 // 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 framework.
+// sent to the framework scheduler.
 TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
 {
   Shared<Docker> docker(new MockDocker(
@@ -958,8 +845,8 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthStatusChange)
   EXPECT_EQ(TASK_RUNNING, statusUnhealthyAgain.get().state());
   EXPECT_FALSE(statusUnhealthyAgain.get().healthy());
 
-  // Check the temporary file created in host still exists and the
-  // content don't change.
+  // Check the temporary file created in host still
+  // exists and the content has not changed.
   ASSERT_SOME(os::read(tmpPath));
   EXPECT_EQ("bar", os::read(tmpPath).get());