You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/12/10 04:00:53 UTC
mesos git commit: Exposed task health through the state endpoints on
master and slave.
Repository: mesos
Updated Branches:
refs/heads/master 90771c45b -> 0d5a64314
Exposed task health through the state endpoints on master and slave.
Review: https://reviews.apache.org/r/41182
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0d5a6431
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0d5a6431
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0d5a6431
Branch: refs/heads/master
Commit: 0d5a64314222e1e93de5a03965aaf2a0b1c08566
Parents: 90771c4
Author: Artem Harutyunyan <ar...@mesosphere.io>
Authored: Wed Dec 9 18:53:41 2015 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Wed Dec 9 19:00:19 2015 -0800
----------------------------------------------------------------------
src/common/http.cpp | 4 ++
src/tests/health_check_tests.cpp | 110 ++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0d5a6431/src/common/http.cpp
----------------------------------------------------------------------
diff --git a/src/common/http.cpp b/src/common/http.cpp
index 586d1c8..5198650 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -221,6 +221,10 @@ JSON::Object model(const TaskStatus& status)
object.values["container_status"] = model(status.container_status());
}
+ if (status.has_healthy()) {
+ object.values["healthy"] = status.healthy();
+ }
+
return object;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/0d5a6431/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 48f5bfb..0fbccc3 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -34,6 +34,8 @@
#include "tests/mesos.hpp"
#include "tests/utils.hpp"
+namespace http = process::http;
+
using mesos::internal::master::Master;
using mesos::internal::slave::Containerizer;
@@ -249,6 +251,32 @@ TEST_F(HealthCheckTest, HealthyTask)
EXPECT_TRUE(implicitReconciliation.get().has_healthy());
EXPECT_TRUE(implicitReconciliation.get().healthy());
+ // Verify that task health is exposed in the master's state endpoint.
+ {
+ Future<http::Response> response = http::get(master.get(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
+ // Verify that task health is exposed in the slave's state endpoint.
+ {
+ Future<http::Response> response = http::get(slave.get(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
driver.stop();
driver.join();
@@ -488,14 +516,96 @@ TEST_F(HealthCheckTest, HealthStatusChange)
EXPECT_EQ(TASK_RUNNING, statusHealth1.get().state());
EXPECT_TRUE(statusHealth1.get().healthy());
+ // Verify that task health is exposed in the master's state endpoint.
+ {
+ Future<http::Response> response = http::get(master.get(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
+ // Verify that task health is exposed in the slave's state endpoint.
+ {
+ Future<http::Response> response = http::get(slave.get(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
AWAIT_READY(statusHealth2);
EXPECT_EQ(TASK_RUNNING, statusHealth2.get().state());
EXPECT_FALSE(statusHealth2.get().healthy());
+ // Verify that the task health change is reflected in the master's
+ // state endpoint.
+ {
+ Future<http::Response> response = http::get(master.get(), "state");
+ AWAIT_READY(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_EQ(false, find);
+ }
+
+ // Verify that the task health change is reflected in the slave's
+ // state endpoint.
+ {
+ Future<http::Response> response = http::get(slave.get(), "state");
+ AWAIT_READY(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_EQ(false, find);
+ }
+
AWAIT_READY(statusHealth3);
EXPECT_EQ(TASK_RUNNING, statusHealth3.get().state());
EXPECT_TRUE(statusHealth3.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(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
+ // Verify through slave's state endpoint that the task is back to a
+ // healthy state.
+ {
+ Future<http::Response> response = http::get(slave.get(), "state");
+ AWAIT_READY(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_EQ(true, find);
+ }
+
os::rm(tmpPath); // Clean up the temporary file.
driver.stop();