Repository: mesos Updated Branches: refs/heads/master 63a7a7928 -> f9a5a800f
Fixed the race in MasterTest.MasterFailoverLongLivedExecutor. Review: https://reviews.apache.org/r/31977 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f9a5a800 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f9a5a800 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f9a5a800 Branch: refs/heads/master Commit: f9a5a800f0adb34db7122ee4ec9783894489d34a Parents: 63a7a79 Author: Michael Park <[email protected]> Authored: Wed Mar 25 11:09:26 2015 -0700 Committer: Niklas Q. Nielsen <[email protected]> Committed: Wed Mar 25 11:09:26 2015 -0700 ---------------------------------------------------------------------- src/tests/master_tests.cpp | 12 ++++++++---- src/tests/mesos.hpp | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/f9a5a800/src/tests/master_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index 78e775d..2bfd0f8 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -3193,7 +3193,7 @@ TEST_F(MasterTest, TaskDiscoveryInfo) // Test verifies that a long lived executor works after master // fail-over. The test launches a task, restarts the master and // launches another task using the same executor. -TEST_F(MasterTest, DISABLED_MasterFailoverLongLivedExecutor) +TEST_F(MasterTest, MasterFailoverLongLivedExecutor) { // Start master and create detector to inform scheduler and slave // about newly elected master. @@ -3252,10 +3252,9 @@ TEST_F(MasterTest, DISABLED_MasterFailoverLongLivedExecutor) .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); Future<TaskStatus> status1; - Future<TaskStatus> status2; - EXPECT_CALL(sched, statusUpdate(&driver, _)) + EXPECT_CALL(sched, statusUpdate(&driver, TaskStatusEq(task1))) .WillOnce(FutureArg<1>(&status1)) - .WillOnce(FutureArg<1>(&status2)); + .WillRepeatedly(Return()); driver.launchTasks(offers1.get()[0].id(), tasks1); @@ -3288,6 +3287,11 @@ TEST_F(MasterTest, DISABLED_MasterFailoverLongLivedExecutor) vector<TaskInfo> tasks2; tasks2.push_back(task2); + Future<TaskStatus> status2; + EXPECT_CALL(sched, statusUpdate(&driver, TaskStatusEq(task2))) + .WillOnce(FutureArg<1>(&status2)) + .WillRepeatedly(Return()); + // Start the second task with the new master on the running executor. driver.launchTasks(offers2.get()[0].id(), tasks2); http://git-wip-us.apache.org/repos/asf/mesos/blob/f9a5a800/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 45e3520..0e98572 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -1140,6 +1140,15 @@ void ExpectNoFutureProtobufs(T t, From from, To to) process::ExpectNoFutureMessages(testing::Eq(t.GetTypeName()), from, to); } + +// This matcher is used to match the task ids of TaskStatus messages. +// Suppose we set up N futures for LaunchTasks and N futures for StatusUpdates. +// (This is a common pattern). We get into a situation where all StatusUpdates +// are satisfied before the LaunchTasks if the master re-sends StatusUpdates. +// We use this matcher to only satisfy the StatusUpdate future if the +// StatusUpdate came from the corresponding task. +MATCHER_P(TaskStatusEq, task, "") { return arg.task_id() == task.task_id(); } + } // namespace tests { } // namespace internal { } // namespace mesos {
