You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/12/02 21:29:11 UTC

[04/10] mesos git commit: Improved SlaveRecoveryTest.ReconcileShutdownFramework.

Improved SlaveRecoveryTest.ReconcileShutdownFramework.

Check the output of the "/state" endpoint to confirm that the framework
has been shutdown properly and the task has been marked as killed.

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


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

Branch: refs/heads/master
Commit: 4cc4fe42ecf9280f87104ea355003a09a6fde231
Parents: 8030108
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:09 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:09 2016 -0800

----------------------------------------------------------------------
 src/tests/slave_recovery_tests.cpp | 46 +++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4cc4fe42/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 3b7d8cf..324cf59 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -34,6 +34,7 @@
 
 #include <process/dispatch.hpp>
 #include <process/gmock.hpp>
+#include <process/http.hpp>
 #include <process/owned.hpp>
 #include <process/reap.hpp>
 
@@ -73,6 +74,9 @@ using namespace mesos::internal::slave;
 
 using namespace process;
 
+using process::http::OK;
+using process::http::Response;
+
 using google::protobuf::RepeatedPtrField;
 
 using mesos::internal::master::Master;
@@ -3013,8 +3017,7 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileShutdownFramework)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  // Capture the slave and framework ids.
-  SlaveID slaveId = offers.get()[0].slave_id();
+  // Capture the framework id.
   FrameworkID frameworkId = offers.get()[0].framework_id();
 
   // Expecting TASK_RUNNING status.
@@ -3061,6 +3064,45 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileShutdownFramework)
 
   // Ensure that the executor is terminated.
   AWAIT_READY(executorTerminated);
+
+  // Check the output of the master's "/state" endpoint.
+  Future<Response> response = process::http::get(
+      master.get()->pid,
+      "state",
+      None(),
+      createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+  Try<JSON::Object> parse = JSON::parse<JSON::Object>(response->body);
+  ASSERT_SOME(parse);
+
+  EXPECT_TRUE(parse->values["frameworks"].as<JSON::Array>().values.empty());
+  EXPECT_TRUE(parse->values["orphan_tasks"].as<JSON::Array>().values.empty());
+
+  JSON::Array completedFrameworks =
+    parse->values["completed_frameworks"].as<JSON::Array>();
+
+  ASSERT_EQ(1u, completedFrameworks.values.size());
+
+  JSON::Object completedFramework =
+    completedFrameworks.values.front().as<JSON::Object>();
+
+  EXPECT_EQ(
+      frameworkId,
+      completedFramework.values["id"].as<JSON::String>().value);
+
+  JSON::Array completedTasks =
+    completedFramework.values["completed_tasks"].as<JSON::Array>();
+
+  ASSERT_EQ(1u, completedTasks.values.size());
+
+  JSON::Object completedTask = completedTasks.values.front().as<JSON::Object>();
+
+  EXPECT_EQ(
+      "TASK_KILLED",
+      completedTask.values["state"].as<JSON::String>().value);
 }