You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/12/06 11:13:53 UTC

mesos git commit: Fixed a flaky test case in reservation tests.

Repository: mesos
Updated Branches:
  refs/heads/master d72d60924 -> 419da0067


Fixed a flaky test case in reservation tests.

ReservationTest.MasterFailover could fail when parameterized with
the 'RESOURCE_PROVIDER' capability. After the simulated master
failover, the re-registered framework could receive an offer before
the re-registered agent sends a 'UPDATE_SLAVE' message. On receiving
this message, the master would rescind the offer and send out a new
one. The test expected a single offer to be send. It has been changed
to accept the first offer and ignore subsequent ones.

Also, the test case has been updated to run with paused clock.

Review: https://reviews.apache.org/r/64247/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/419da006
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/419da006
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/419da006

Branch: refs/heads/master
Commit: 419da0067c5bd619edd65303e0edc73fedf3fa8c
Parents: d72d609
Author: Jan Schlicht <ja...@mesosphere.io>
Authored: Wed Dec 6 12:08:59 2017 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Dec 6 12:13:24 2017 +0100

----------------------------------------------------------------------
 src/tests/reservation_tests.cpp | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/419da006/src/tests/reservation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/reservation_tests.cpp b/src/tests/reservation_tests.cpp
index 7f1bb39..34fa441 100644
--- a/src/tests/reservation_tests.cpp
+++ b/src/tests/reservation_tests.cpp
@@ -846,6 +846,10 @@ TEST_P(ReservationTest, ResourcesCheckpointing)
 // dynamic reservations are later correctly offered to the framework.
 TEST_P(ReservationTest, MasterFailover)
 {
+  // Pause the cock and control it manually in order to
+  // control the timing of the offer cycle.
+  Clock::pause();
+
   FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
   frameworkInfo.set_roles(0, "role");
 
@@ -866,6 +870,8 @@ TEST_P(ReservationTest, MasterFailover)
   Try<Owned<cluster::Slave>> slave = StartSlave(&detector, slaveFlags);
   ASSERT_SOME(slave);
 
+  Clock::advance(slaveFlags.registration_backoff_factor);
+  Clock::settle();
   AWAIT_READY(slaveReady1);
 
   MockScheduler sched;
@@ -887,6 +893,10 @@ TEST_P(ReservationTest, MasterFailover)
 
   driver.start();
 
+  // Advance the clock to generate an offer.
+  Clock::advance(masterFlags.allocation_interval);
+  Clock::settle();
+
   // In the first offer, expect an offer with unreserved resources.
   AWAIT_READY(offers);
 
@@ -907,9 +917,7 @@ TEST_P(ReservationTest, MasterFailover)
   AWAIT_READY(message);
 
   // This is to make sure operation message is processed.
-  Clock::pause();
   Clock::settle();
-  Clock::resume();
 
   EXPECT_CALL(sched, disconnected(&driver));
 
@@ -919,33 +927,23 @@ TEST_P(ReservationTest, MasterFailover)
   Try<Owned<cluster::Master>> master2 = StartMaster(masterFlags);
   ASSERT_SOME(master2);
 
-  Future<SlaveReregisteredMessage> slaveReregistered =
-    FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _);
-
-  Future<Nothing> slaveReady2 = getSlaveReady();
-
   EXPECT_CALL(sched, registered(&driver, _, _));
 
   // The expectation for the next offer.
   EXPECT_CALL(sched, resourceOffers(&driver, _))
-    .WillOnce(FutureArg<1>(&offers));
+    .WillOnce(FutureArg<1>(&offers))
+    .WillRepeatedly(Return());  // Ignore subsequent offers.
 
   // Simulate a new master detected event on the slave so that the
   // slave will do a re-registration.
   detector.appoint(master2.get()->pid);
 
   // Ensure agent registration is processed.
-  Clock::pause();
   Clock::advance(slaveFlags.authentication_backoff_factor);
   Clock::advance(slaveFlags.registration_backoff_factor);
   Clock::settle();
   Clock::resume();
 
-  // Wait for slave to confirm re-registration.
-  AWAIT_READY(slaveReregistered);
-
-  AWAIT_READY(slaveReady2);
-
   // In the next offer, expect an offer with the reserved resources.
   AWAIT_READY(offers);