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/02/28 18:55:25 UTC
[07/10] mesos git commit: Modified existing scheduler tests as an
aftermath of pipelining change.
Modified existing scheduler tests as an aftermath of pipelining change.
This change modifies the existing tests to handle the new
`connected/disconnected` semantics that were introduced as a result of the
pipelining change.
Now `connected` is possible to invoked more then once i.e. during test shutdown,
the master closed the event stream making us call the `disconnected` callback.
However, the master detector can still detect the same master and establish a
connection to it while it is shutting down leading to `connected` callback be
invoked again in some cases.
Review: https://reviews.apache.org/r/43667/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9b0a8ce9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9b0a8ce9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9b0a8ce9
Branch: refs/heads/master
Commit: 9b0a8ce9a7cc1cfbf062157a7baecfffc9b025dc
Parents: 3c3e92e
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Sun Feb 28 09:52:34 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Feb 28 09:52:34 2016 -0800
----------------------------------------------------------------------
src/tests/master_maintenance_tests.cpp | 18 ++++-
src/tests/scheduler_tests.cpp | 104 +++++++++++++++++-----------
2 files changed, 77 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b0a8ce9/src/tests/master_maintenance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_maintenance_tests.cpp b/src/tests/master_maintenance_tests.cpp
index 356015e..3faa813 100644
--- a/src/tests/master_maintenance_tests.cpp
+++ b/src/tests/master_maintenance_tests.cpp
@@ -385,7 +385,8 @@ TEST_F(MasterMaintenanceTest, PendingUnavailabilityTest)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -489,6 +490,9 @@ TEST_F(MasterMaintenanceTest, PendingUnavailabilityTest)
EXPECT_CALL(exec, shutdown(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -1092,7 +1096,8 @@ TEST_F(MasterMaintenanceTest, InverseOffers)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -1321,6 +1326,9 @@ TEST_F(MasterMaintenanceTest, InverseOffers)
EXPECT_CALL(exec, shutdown(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -1418,7 +1426,8 @@ TEST_F(MasterMaintenanceTest, InverseOffersFilters)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -1678,6 +1687,9 @@ TEST_F(MasterMaintenanceTest, InverseOffersFilters)
EXPECT_CALL(exec2, shutdown(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b0a8ce9/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 37f1709..90f3e3e 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -116,9 +116,10 @@ ACTION_P(Enqueue, queue)
}
}
+// TODO(anand): Add a test for scheduler failover after MESOS-3339 is resolved.
-// This test verifies that when a scheduler resubscribes it receives
-// SUBSCRIBED event with the previously assigned framework id.
+
+// This test verifies that a scheduler can subscribe with the master.
TEST_P(SchedulerTest, Subscribe)
{
master::Flags flags = CreateMasterFlags();
@@ -131,7 +132,8 @@ TEST_P(SchedulerTest, Subscribe)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -147,41 +149,19 @@ TEST_P(SchedulerTest, Subscribe)
EXPECT_CALL(callbacks, received(_))
.WillRepeatedly(Enqueue(&events));
- {
- Call call;
- call.set_type(Call::SUBSCRIBE);
-
- Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
- subscribe->set_force(true);
+ Call call;
+ call.set_type(Call::SUBSCRIBE);
+ Call::Subscribe* subscribe = call.mutable_subscribe();
+ subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
- mesos.send(call);
- }
+ mesos.send(call);
Future<Event> event = events.get();
AWAIT_READY(event);
EXPECT_EQ(Event::SUBSCRIBED, event.get().type());
- v1::FrameworkID id(event.get().subscribed().framework_id());
-
- // Resubscribe with the same framework id.
- {
- Call call;
- call.mutable_framework_id()->CopyFrom(id);
- call.set_type(Call::SUBSCRIBE);
-
- Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
- subscribe->mutable_framework_info()->mutable_id()->CopyFrom(id);
- subscribe->set_force(true);
-
- mesos.send(call);
- }
-
- event = events.get();
- AWAIT_READY(event);
- EXPECT_EQ(Event::SUBSCRIBED, event.get().type());
- EXPECT_EQ(id, event.get().subscribed().framework_id());
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
Shutdown();
}
@@ -207,7 +187,8 @@ TEST_P(SchedulerTest, TaskRunning)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -307,6 +288,9 @@ TEST_P(SchedulerTest, TaskRunning)
EXPECT_CALL(*executor, disconnected(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -331,7 +315,8 @@ TEST_P(SchedulerTest, ReconcileTask)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -433,6 +418,9 @@ TEST_P(SchedulerTest, ReconcileTask)
EXPECT_CALL(*executor, disconnected(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -457,7 +445,8 @@ TEST_P(SchedulerTest, KillTask)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -576,6 +565,9 @@ TEST_P(SchedulerTest, KillTask)
EXPECT_CALL(*executor, disconnected(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -600,7 +592,8 @@ TEST_P(SchedulerTest, ShutdownExecutor)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -702,6 +695,9 @@ TEST_P(SchedulerTest, ShutdownExecutor)
EXPECT_EQ(Event::FAILURE, event.get().type());
EXPECT_EQ(evolve(executorId), event.get().failure().executor_id());
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -726,7 +722,8 @@ TEST_P(SchedulerTest, Teardown)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -817,6 +814,9 @@ TEST_P(SchedulerTest, Teardown)
AWAIT_READY(shutdown);
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -836,7 +836,8 @@ TEST_P(SchedulerTest, Decline)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -898,6 +899,9 @@ TEST_P(SchedulerTest, Decline)
ASSERT_EQ(1, event.get().offers().offers().size());
ASSERT_EQ(offer.resources(), event.get().offers().offers(0).resources());
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -917,7 +921,8 @@ TEST_P(SchedulerTest, Revive)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -995,6 +1000,9 @@ TEST_P(SchedulerTest, Revive)
EXPECT_NE(0, event.get().offers().offers().size());
ASSERT_EQ(offer.resources(), event.get().offers().offers(0).resources());
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -1014,7 +1022,8 @@ TEST_P(SchedulerTest, Suppress)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -1108,6 +1117,9 @@ TEST_P(SchedulerTest, Suppress)
EXPECT_NE(0, event.get().offers().offers().size());
ASSERT_EQ(offer.resources(), event.get().offers().offers(0).resources());
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -1132,7 +1144,8 @@ TEST_P(SchedulerTest, Message)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -1235,6 +1248,9 @@ TEST_P(SchedulerTest, Message)
EXPECT_CALL(*executor, disconnected(_))
.Times(AtMost(1));
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}
@@ -1251,7 +1267,8 @@ TEST_P(SchedulerTest, Request)
Future<Nothing> connected;
EXPECT_CALL(callbacks, connected())
- .WillOnce(FutureSatisfy(&connected));
+ .WillOnce(FutureSatisfy(&connected))
+ .WillRepeatedly(Return()); // Ignore future invocations.
Mesos mesos(
master.get(),
@@ -1300,6 +1317,9 @@ TEST_P(SchedulerTest, Request)
AWAIT_READY(requestResources);
+ EXPECT_CALL(callbacks, disconnected())
+ .Times(AtMost(1));
+
Shutdown();
}