Repository: mesos
Updated Branches:
  refs/heads/master e048e898e -> 895f539b1


Fixed a race in resource provider resubscription test.

We previously did not make ensure that after the simulated agent
failover in
`ResourceProviderManagerHttpApiTest.ResubscribeResourceProvider` the
mock resource provider created as part of the test did not reconnect
to the restarted agent (as opposed to the newly initialized resource
provider). This lead to unmet test expectations.

With this patch we now explicitly tear down the mock resource provider
after we have detected that the agent went away to prevent the race.

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


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

Branch: refs/heads/master
Commit: c6a60b81ad74479f197dac82e002d509c1d27b14
Parents: e048e89
Author: Benjamin Bannier <[email protected]>
Authored: Fri May 4 12:09:20 2018 -0700
Committer: Chun-Hung Hsiao <[email protected]>
Committed: Fri May 4 12:09:20 2018 -0700

----------------------------------------------------------------------
 src/tests/resource_provider_manager_tests.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c6a60b81/src/tests/resource_provider_manager_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resource_provider_manager_tests.cpp 
b/src/tests/resource_provider_manager_tests.cpp
index e8ca377..662ea3b 100644
--- a/src/tests/resource_provider_manager_tests.cpp
+++ b/src/tests/resource_provider_manager_tests.cpp
@@ -1124,9 +1124,21 @@ TEST_P_TEMP_DISABLED_ON_WINDOWS(
 
   Future<Nothing> __recover = FUTURE_DISPATCH(_, &Slave::__recover);
 
+  // We terminate the resource provider once we have confirmed that it
+  // got disconnected. This avoids it to in turn resubscribe racing
+  // with the newly created resource provider.
+  Future<Nothing> disconnected;
+  EXPECT_CALL(*resourceProvider, disconnected())
+    .WillOnce(DoAll(
+        FutureSatisfy(&disconnected),
+        Invoke([&resourceProvider]() { resourceProvider.reset(); })))
+    .WillRepeatedly(Return()); // Ignore spurious calls concurrent with 
`reset`.
+
   // The agent failover.
-  EXPECT_CALL(*resourceProvider, disconnected());
   agent->reset();
+
+  AWAIT_READY(disconnected);
+
   agent = StartSlave(detector.get(), slaveFlags);
 
   Clock::advance(slaveFlags.registration_backoff_factor);

Reply via email to