Improved consistency of test code for partitioning an agent. Removed unnecessary `Clock::settle` calls: `Clock::settle` should typically only be used when a test case does not have an easy way to wait for a _specific_ event to occur. In this case, `Clock::settle` was unnecessary because the test code immediately proceeded to `AWAIT_READY` for a more specific event.
Also fixed up some whitespace. Review: https://reviews.apache.org/r/50417/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5de96fa4 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5de96fa4 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5de96fa4 Branch: refs/heads/master Commit: 5de96fa4b3e603553dbae3f06aff6621b268a7be Parents: 60dbd34 Author: Neil Conway <neil.con...@gmail.com> Authored: Fri Aug 5 16:41:28 2016 -0700 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Fri Aug 5 16:41:28 2016 -0700 ---------------------------------------------------------------------- src/tests/partition_tests.cpp | 14 ++++---------- src/tests/slave_recovery_tests.cpp | 4 +--- src/tests/slave_tests.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/5de96fa4/src/tests/partition_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/partition_tests.cpp b/src/tests/partition_tests.cpp index bafc7ce..0a72b34 100644 --- a/src/tests/partition_tests.cpp +++ b/src/tests/partition_tests.cpp @@ -134,7 +134,7 @@ TEST_P(PartitionTest, PartitionedSlave) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - break; + break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); @@ -265,15 +265,13 @@ TEST_P(PartitionTest, PartitionedSlaveReregistration) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - break; + break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); } Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); // The master will have notified the framework of the lost task. AWAIT_READY(lostStatus); @@ -392,15 +390,13 @@ TEST_P(PartitionTest, PartitionedSlaveStatusUpdates) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - break; + break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); } Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); // Wait for the master to attempt to shut down the slave. AWAIT_READY(shutdownMessage); @@ -543,15 +539,13 @@ TEST_P(PartitionTest, PartitionedSlaveExitedExecutor) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - break; + break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); } Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); // The master will have notified the framework of the lost task. AWAIT_READY(lostStatus); http://git-wip-us.apache.org/repos/asf/mesos/blob/5de96fa4/src/tests/slave_recovery_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp index 83e89d6..998d445 100644 --- a/src/tests/slave_recovery_tests.cpp +++ b/src/tests/slave_recovery_tests.cpp @@ -3276,15 +3276,13 @@ TYPED_TEST(SlaveRecoveryTest, PartitionedSlave) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - break; + break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); } Clock::advance(masterFlags.agent_ping_timeout); - Clock::settle(); // The master will notify the framework that the slave was lost. AWAIT_READY(slaveLost); http://git-wip-us.apache.org/repos/asf/mesos/blob/5de96fa4/src/tests/slave_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp index b9fa85d..890119f 100644 --- a/src/tests/slave_tests.cpp +++ b/src/tests/slave_tests.cpp @@ -2425,13 +2425,14 @@ TEST_F(SlaveTest, RateLimitSlaveShutdown) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - Clock::advance(masterFlags.agent_ping_timeout); break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); } + Clock::advance(masterFlags.agent_ping_timeout); + // The master should attempt to acquire a permit. AWAIT_READY(acquire); @@ -2495,13 +2496,14 @@ TEST_F(SlaveTest, CancelSlaveShutdown) AWAIT_READY(ping); pings++; if (pings == masterFlags.max_agent_ping_timeouts) { - Clock::advance(masterFlags.agent_ping_timeout); break; } ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _); Clock::advance(masterFlags.agent_ping_timeout); } + Clock::advance(masterFlags.agent_ping_timeout); + // The master should attempt to acquire a permit. AWAIT_READY(acquire);