Repository: mesos Updated Branches: refs/heads/master bc2062791 -> beda6ffb7
Fixed the flaky test case `MasterAPITest.GetTasks`. This changes to wait for every `StatusUpdateAcknowledgementMessage` exactly in this test case to make sure they don't conflict each other. Review: https://reviews.apache.org/r/50181/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/beda6ffb Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/beda6ffb Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/beda6ffb Branch: refs/heads/master Commit: beda6ffb72687d9f5c23b07552cadf42756bcd75 Parents: bc20627 Author: haosdent huang <haosd...@gmail.com> Authored: Wed Jul 27 17:08:45 2016 -0700 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Wed Jul 27 17:08:45 2016 -0700 ---------------------------------------------------------------------- src/tests/api_tests.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/beda6ffb/src/tests/api_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp index abf102f..e440d1b 100644 --- a/src/tests/api_tests.cpp +++ b/src/tests/api_tests.cpp @@ -462,6 +462,7 @@ TEST_P(MasterAPITest, GetState) EXPECT_NE(0u, offers.get().size()); ContentType contentType = GetParam(); + { // GetState before task launch and check we have one framework, one agent // and zero tasks/executors. @@ -488,6 +489,12 @@ TEST_P(MasterAPITest, GetState) EXPECT_CALL(exec, launchTask(_, _)) .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); + Future<StatusUpdateAcknowledgementMessage> acknowledgement = + FUTURE_PROTOBUF( + StatusUpdateAcknowledgementMessage(), + Eq(master.get()->pid), + Eq(slave.get()->pid)); + Future<TaskStatus> status; EXPECT_CALL(sched, statusUpdate(&driver, _)) .WillOnce(FutureArg<1>(&status)); @@ -499,6 +506,8 @@ TEST_P(MasterAPITest, GetState) EXPECT_EQ(TASK_RUNNING, status.get().state()); + AWAIT_READY(acknowledgement); + { // GetState after task launch and check we have a running task. Future<v1::master::Response> v1Response = @@ -513,11 +522,10 @@ TEST_P(MasterAPITest, GetState) ASSERT_EQ(0u, getState.get_tasks().completed_tasks_size()); } - Future<StatusUpdateAcknowledgementMessage> acknowledgement = - FUTURE_PROTOBUF( - StatusUpdateAcknowledgementMessage(), - _, - Eq(slave.get()->pid)); + acknowledgement = FUTURE_PROTOBUF( + StatusUpdateAcknowledgementMessage(), + Eq(master.get()->pid), + Eq(slave.get()->pid)); Future<TaskStatus> status2; EXPECT_CALL(sched, statusUpdate(&driver, _)) @@ -626,6 +634,12 @@ TEST_P(MasterAPITest, GetTasks) EXPECT_CALL(exec, launchTask(_, _)) .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); + Future<StatusUpdateAcknowledgementMessage> acknowledgement = + FUTURE_PROTOBUF( + StatusUpdateAcknowledgementMessage(), + Eq(master.get()->pid), + Eq(slave.get()->pid)); + Future<TaskStatus> status; EXPECT_CALL(sched, statusUpdate(&driver, _)) .WillOnce(FutureArg<1>(&status)); @@ -639,6 +653,8 @@ TEST_P(MasterAPITest, GetTasks) EXPECT_TRUE(status.get().has_executor_id()); EXPECT_EQ(exec.id, status.get().executor_id()); + AWAIT_READY(acknowledgement); + v1::master::Call v1Call; v1Call.set_type(v1::master::Call::GET_TASKS); @@ -658,11 +674,10 @@ TEST_P(MasterAPITest, GetTasks) ASSERT_EQ("1", v1Response.get().get_tasks().tasks(0).task_id().value()); } - Future<StatusUpdateAcknowledgementMessage> acknowledgement = - FUTURE_PROTOBUF( - StatusUpdateAcknowledgementMessage(), - _, - Eq(slave.get()->pid)); + acknowledgement = FUTURE_PROTOBUF( + StatusUpdateAcknowledgementMessage(), + Eq(master.get()->pid), + Eq(slave.get()->pid)); Future<TaskStatus> status2; EXPECT_CALL(sched, statusUpdate(&driver, _))