You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/11/07 16:20:07 UTC
mesos git commit: Added a test to catch regressions to MESOS-4975.
Repository: mesos
Updated Branches:
refs/heads/master 11b986985 -> 28c004210
Added a test to catch regressions to MESOS-4975.
Review: https://reviews.apache.org/r/53501
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/28c00421
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/28c00421
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/28c00421
Branch: refs/heads/master
Commit: 28c004210165a53d0a671f9b8c53c507f5e1d489
Parents: 11b9869
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Oct 28 16:58:14 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Mon Nov 7 08:19:20 2016 -0800
----------------------------------------------------------------------
src/tests/master_tests.cpp | 67 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/28c00421/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 3143af1..ed859ab 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -91,6 +91,7 @@ using mesos::v1::scheduler::Event;
using process::Clock;
using process::Future;
+using process::Message;
using process::Owned;
using process::PID;
using process::Promise;
@@ -3108,6 +3109,72 @@ TEST_F(MasterTest, OrphanTasksMultipleAgents)
}
+// This test verifies that when a framework tears down with no tasks
+// still alive or pending acknowledgement, it doesn't show up in the
+// /state endpoint's "unregistered_frameworks" list. This is to catch
+// any regression to MESOS-4975.
+TEST_F(MasterTest, UnregisteredFrameworksAfterTearDown)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get());
+ ASSERT_SOME(slave);
+
+ // Wait until the master fully processes slave registration before
+ // connecting the framework. This is to reproduce the condition in
+ // MESOS-4975.
+ Future<Message> slaveRegisteredMessage = FUTURE_MESSAGE(
+ Eq(SlaveRegisteredMessage().GetTypeName()), _, _);
+
+ AWAIT_READY(slaveRegisteredMessage);
+
+ // Give `frameworkInfo` a framework ID to simulate a failed-over
+ // framework (with no unacknowledged tasks). This is to reproduce
+ // the condition in MESOS-4975.
+ FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
+ frameworkInfo.mutable_id()->set_value("framework1");
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+ Future<Nothing> registered;
+ EXPECT_CALL(sched, registered(&driver, _, _))
+ .WillOnce(FutureSatisfy(®istered));
+
+ driver.start();
+
+ // Wait until the master full processes framework registration
+ // before shutting it down.
+ AWAIT_READY(registered);
+
+ driver.stop();
+ driver.join();
+
+ // Ensure that there are no unregistered frameworks in "/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.get().body);
+ ASSERT_SOME(parse);
+
+ JSON::Object state = parse.get();
+
+ JSON::Array unregisteredFrameworks =
+ state.values["unregistered_frameworks"].as<JSON::Array>();
+
+ EXPECT_EQ(0u, unregisteredFrameworks.values.size());
+}
+
+
// This tests /tasks endpoint to return correct task information.
TEST_F(MasterTest, TasksEndpoint)
{