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 2016/01/29 22:14:38 UTC
mesos git commit: Fixed flaky MaxCompletedTasksPerFrameworkFlag test.
Repository: mesos
Updated Branches:
refs/heads/master 222446f48 -> 45d42f7da
Fixed flaky MaxCompletedTasksPerFrameworkFlag test.
Previously, this test was calling EXPECT_CALL() on
SchedulerDriver.resourceOffers() after the scheduler driver itself had
already been started. This resulted in flaky test results when offers
came in between schedDriver.start() and the EXPECT_CALL().
This commit fixes this test by moving the EXPECT_CALL() above the
schedDriver.start() call. However, because of the nature of this test,
this introduced a few complexities related to processing the incoming offers
in a loop later on. To allow this, we had to introduce a custom gmock
ACTION to enqueue offers in a process::Queue for later processing. This
ACTION is generally useful and has been placed in src/tests/mesos.hpp.
Review: https://reviews.apache.org/r/42921/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/45d42f7d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/45d42f7d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/45d42f7d
Branch: refs/heads/master
Commit: 45d42f7dad2a1d11624c2b5c5e5bc3f24a99b656
Parents: 222446f
Author: Kevin Klues <kl...@gmail.com>
Authored: Fri Jan 29 13:14:20 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Fri Jan 29 13:14:34 2016 -0800
----------------------------------------------------------------------
src/tests/master_tests.cpp | 20 +++++++++-----------
src/tests/mesos.hpp | 14 ++++++++++++++
2 files changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/45d42f7d/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index ce6ce25..0357b1c 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -4021,25 +4021,23 @@ TEST_F(MasterTest, MaxCompletedTasksPerFrameworkFlag)
EXPECT_CALL(sched, registered(_, _, _))
.WillOnce(FutureSatisfy(&schedRegistered));
+ process::Queue<Offer> offers;
+ EXPECT_CALL(sched, resourceOffers(_, _))
+ .WillRepeatedly(EnqueueOffers(&offers));
+
schedDriver.start();
AWAIT_READY(schedRegistered);
for (size_t i = 0; i < totalTasksPerFramework; i++) {
- Future<vector<Offer>> offers;
- EXPECT_CALL(sched, resourceOffers(&schedDriver, _))
- .WillOnce(FutureArg<1>(&offers))
- .WillRepeatedly(Return());
-
- AWAIT_READY(offers);
- EXPECT_NE(0u, offers->size());
- Offer offer = offers.get()[0];
+ Future<Offer> offer = offers.get();
+ AWAIT_READY(offer);
TaskInfo task;
task.set_name("");
task.mutable_task_id()->set_value(stringify(i));
- task.mutable_slave_id()->MergeFrom(offer.slave_id());
- task.mutable_resources()->MergeFrom(offer.resources());
+ task.mutable_slave_id()->MergeFrom(offer->slave_id());
+ task.mutable_resources()->MergeFrom(offer->resources());
task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);
// Make sure the task passes through its TASK_FINISHED
@@ -4051,7 +4049,7 @@ TEST_F(MasterTest, MaxCompletedTasksPerFrameworkFlag)
EXPECT_CALL(sched, statusUpdate(_, _))
.WillOnce(FutureArg<1>(&statusFinished));
- schedDriver.launchTasks(offer.id(), {task});
+ schedDriver.launchTasks(offer->id(), {task});
AWAIT_READY(statusFinished);
EXPECT_EQ(TASK_FINISHED, statusFinished->state());
http://git-wip-us.apache.org/repos/asf/mesos/blob/45d42f7d/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 845b637..c2bae47 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -783,6 +783,20 @@ ACTION_P(DeclineOffers, filters)
}
+// For use with a MockScheduler, for example:
+// process::Queue<Offer> offers;
+// EXPECT_CALL(sched, resourceOffers(_, _))
+// .WillRepeatedly(EnqueueOffers(&offers));
+// Enqueues all received offers into the provided queue.
+ACTION_P(EnqueueOffers, queue)
+{
+ std::vector<Offer> offers = arg1;
+ foreach (const Offer& offer, offers) {
+ queue->put(offer);
+ }
+}
+
+
// Definition of a mock Executor to be used in tests with gmock.
class MockExecutor : public Executor
{