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 2016/04/21 14:27:46 UTC

mesos git commit: Fixed flakiness in MasterAllocatorTest.RebalancedForUpdatedWeights.

Repository: mesos
Updated Branches:
  refs/heads/master a823a7285 -> d778d4502


Fixed flakiness in MasterAllocatorTest.RebalancedForUpdatedWeights.

We make sure all resources from rescinded offers are recovered before
next batch allocation is triggered. This prevents a batch allocation
from sneaking in-between recovering resources.

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


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

Branch: refs/heads/master
Commit: d778d4502f468336df8094feb9ecde8589e2a86b
Parents: a823a72
Author: Yongqiao Wang <yq...@cn.ibm.com>
Authored: Thu Apr 21 13:52:42 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Thu Apr 21 13:52:42 2016 +0200

----------------------------------------------------------------------
 src/tests/master_allocator_tests.cpp | 33 ++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d778d450/src/tests/master_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_allocator_tests.cpp b/src/tests/master_allocator_tests.cpp
index bb96b25..ec46913 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -1514,12 +1514,16 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst)
 // according to the updated weights.
 TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
 {
+  Clock::pause();
+
   TestAllocator<TypeParam> allocator;
 
   EXPECT_CALL(allocator, initialize(_, _, _, _));
 
   // Start Mesos master.
-  Try<Owned<cluster::Master>> master = this->StartMaster(&allocator);
+  master::Flags masterFlags = this->CreateMasterFlags();
+  Try<Owned<cluster::Master>> master =
+    this->StartMaster(&allocator, masterFlags);
   ASSERT_SOME(master);
 
   Owned<MasterDetector> detector = master.get()->createDetector();
@@ -1602,6 +1606,16 @@ TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
   // Expect offer rescinded.
   EXPECT_CALL(sched1, offerRescinded(&driver1, _)).Times(3);
 
+  Future<Resources> recoverResources1, recoverResources2, recoverResources3;
+  EXPECT_CALL(allocator, recoverResources(_, _, _, _))
+    .WillOnce(DoAll(FutureArg<2>(&recoverResources1),
+                    InvokeRecoverResources(&allocator)))
+    .WillOnce(DoAll(FutureArg<2>(&recoverResources2),
+                    InvokeRecoverResources(&allocator)))
+    .WillOnce(DoAll(FutureArg<2>(&recoverResources3),
+                    InvokeRecoverResources(&allocator)))
+    .WillRepeatedly(DoDefault());
+
   // Update the weight of 'role2' to 2.0.
   RepeatedPtrField<WeightInfo> infos = createWeightInfos("role2=2.0");
   Future<Response> response = process::http::request(
@@ -1616,8 +1630,21 @@ TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
   AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response)
     << response.get().body;
 
-  // 'updateWeights' will rescind all outstanding offers and trigger
-  // the allocation immediately.
+  // 'updateWeights' will rescind all outstanding offers and the rescinded
+  // offer resources will only be available to the updated weights once
+  // another allocation is invoked.
+  AWAIT_READY(recoverResources1);
+  EXPECT_EQ(recoverResources1.get(),
+            Resources::parse(agentResources).get());
+  AWAIT_READY(recoverResources2);
+  EXPECT_EQ(recoverResources2.get(),
+            Resources::parse(agentResources).get());
+  AWAIT_READY(recoverResources3);
+  EXPECT_EQ(recoverResources3.get(),
+            Resources::parse(agentResources).get());
+
+  // Trigger a batch allocation.
+  Clock::advance(masterFlags.allocation_interval);
 
   // role1 share = 0.33 (cpus=2, mem=1024)
   //   framework1 share = 1