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/03/30 21:01:22 UTC
[2/3] mesos git commit: Added test for `reconnect` functionality.
Added test for `reconnect` functionality.
This change adds a trivial test for testing the `reconnect`
method on the scheduler library.
Review: https://reviews.apache.org/r/45409/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bae4f13f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bae4f13f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bae4f13f
Branch: refs/heads/master
Commit: bae4f13f7ad9f35202866b398b7bdd278f6d3fea
Parents: 140c82a
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Wed Mar 30 12:00:31 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Mar 30 12:00:31 2016 -0700
----------------------------------------------------------------------
src/tests/scheduler_tests.cpp | 64 ++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bae4f13f/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 917058f..0c66f65 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -1478,6 +1478,70 @@ TEST_P(SchedulerTest, Request)
}
+// This test verifies that the scheduler is able to force a reconnection with
+// the master.
+TEST_P(SchedulerTest, SchedulerReconnect)
+{
+ master::Flags flags = CreateMasterFlags();
+ flags.authenticate_frameworks = false;
+
+ Try<Owned<cluster::Master>> master = StartMaster(flags);
+ ASSERT_SOME(master);
+
+ auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto detector = std::make_shared<StandaloneMasterDetector>(master.get()->pid);
+
+ Future<Nothing> connected;
+ EXPECT_CALL(*scheduler, connected(_))
+ .WillOnce(FutureSatisfy(&connected));
+
+ ContentType contentType = GetParam();
+
+ scheduler::TestV1Mesos mesos(
+ master.get()->pid, contentType, scheduler, detector);
+
+ AWAIT_READY(connected);
+
+ Future<Nothing> disconnected;
+ EXPECT_CALL(*scheduler, disconnected(_))
+ .WillOnce(FutureSatisfy(&disconnected));
+
+ EXPECT_CALL(*scheduler, connected(_))
+ .WillOnce(FutureSatisfy(&connected));
+
+ // Force a reconnection with the master. This should result in a
+ // `disconnected` callback followed by a `connected` callback.
+ mesos.reconnect();
+
+ AWAIT_READY(disconnected);
+
+ // The scheduler should be able to immediately reconnect with the master.
+ AWAIT_READY(connected);
+
+ EXPECT_CALL(*scheduler, disconnected(_))
+ .WillOnce(FutureSatisfy(&disconnected));
+
+ // Simulate a spurious master failure event at the scheduler.
+ detector->appoint(None());
+
+ AWAIT_READY(disconnected);
+
+ EXPECT_CALL(*scheduler, disconnected(_))
+ .Times(0);
+
+ EXPECT_CALL(*scheduler, connected(_))
+ .Times(0);
+
+ mesos.reconnect();
+
+ // Flush any possible remaining events. The mocked scheduler will fail if the
+ // reconnection attempt resulted in any additional callbacks after the
+ // scheduler has disconnected.
+ Clock::pause();
+ Clock::settle();
+}
+
+
// TODO(benh): Write test for sending Call::Acknowledgement through
// master to slave when Event::Update was generated locally.