Fixed flakiness in MasterAuthorizationTest.SlaveDisconnected. The goal of this test is to check this interleaving:
task launch: block on authorization slave terminates gracefully: removed by master auth succeeds: we expect the task launch to fail However, the test neglected to ensure that slave removal was completed before allowing authorization to succeed. Review: https://reviews.apache.org/r/51371/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0cb24804 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0cb24804 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0cb24804 Branch: refs/heads/master Commit: 0cb248044c23ff702a1099e724474fe5c1a5c17e Parents: df037de Author: Neil Conway <neil.con...@gmail.com> Authored: Mon Sep 19 15:47:48 2016 -0700 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Mon Sep 19 15:47:48 2016 -0700 ---------------------------------------------------------------------- src/tests/master_authorization_tests.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/0cb24804/src/tests/master_authorization_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_authorization_tests.cpp b/src/tests/master_authorization_tests.cpp index a6399f1..74422c7 100644 --- a/src/tests/master_authorization_tests.cpp +++ b/src/tests/master_authorization_tests.cpp @@ -660,18 +660,17 @@ TEST_F(MasterAuthorizationTest, SlaveDisconnected) // Wait until authorization is in progress. AWAIT_READY(authorize); + Future<Nothing> slaveLost; EXPECT_CALL(sched, slaveLost(&driver, _)) - .Times(AtMost(1)); - - Future<Nothing> deactivateSlave = - FUTURE_DISPATCH(_, &MesosAllocatorProcess::deactivateSlave); + .WillOnce(FutureSatisfy(&slaveLost)); - // Stop the slave with explicit shutdown message so that the master does not - // wait for it to reconnect. + // Stop the slave with explicit shutdown message so that the master + // does not wait for it to reconnect. slave.get()->shutdown(); slave->reset(); - AWAIT_READY(deactivateSlave); + // Wait for the slave to be removed by the master. + AWAIT_READY(slaveLost); Future<TaskStatus> status; EXPECT_CALL(sched, statusUpdate(&driver, _))