You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/02/01 20:18:38 UTC

[2/6] mesos git commit: Fixed MasterAllocatorTest/1.RebalancedForUpdatedWeights.

Fixed MasterAllocatorTest/1.RebalancedForUpdatedWeights.

- This test is broken by changes introduced in MESOS-6904.

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


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

Branch: refs/heads/master
Commit: daa15285fe7fa829cd5ec19c5bb6728df9701280
Parents: f68ed9b
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Wed Feb 1 11:07:45 2017 -0800
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Wed Feb 1 12:16:18 2017 -0800

----------------------------------------------------------------------
 src/tests/master_allocator_tests.cpp | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/daa15285/src/tests/master_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_allocator_tests.cpp b/src/tests/master_allocator_tests.cpp
index 996762f..d22862d 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -34,6 +34,7 @@
 #include <process/gmock.hpp>
 #include <process/owned.hpp>
 #include <process/pid.hpp>
+#include <process/queue.hpp>
 
 #include <stout/some.hpp>
 #include <stout/strings.hpp>
@@ -66,6 +67,7 @@ using process::Clock;
 using process::Future;
 using process::Owned;
 using process::PID;
+using process::Queue;
 
 using process::http::OK;
 using process::http::Response;
@@ -1670,13 +1672,17 @@ TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
   EXPECT_CALL(sched2, registered(&driver2, _, _))
     .WillOnce(FutureSatisfy(&registered2));
 
-  Future<vector<Offer>> framework2offers;
+  Queue<Offer> framework2offers;
   EXPECT_CALL(sched2, resourceOffers(&driver2, _))
-    .WillOnce(FutureArg<1>(&framework2offers));
+    .WillRepeatedly(EnqueueOffers(&framework2offers));
 
   driver2.start();
   AWAIT_READY(registered2);
 
+  // Settle to make sure the dispatched allocation is executed before
+  // the weights are updated.
+  Clock::settle();
+
   // role1 share = 1 (cpus=6, mem=3072)
   //   framework1 share = 1
   // role2 share = 0
@@ -1722,9 +1728,13 @@ TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
   EXPECT_EQ(recoverResources3.get(),
             Resources::parse(agentResources).get());
 
-  // Trigger a batch allocation.
+  // Trigger a batch allocation to make sure all resources are
+  // offered out again.
   Clock::advance(masterFlags.allocation_interval);
 
+  // Settle to make sure all offers are received.
+  Clock::settle();
+
   // role1 share = 0.33 (cpus=2, mem=1024)
   //   framework1 share = 1
   // role2 share = 0.66 (cpus=4, mem=2048)
@@ -1735,10 +1745,13 @@ TYPED_TEST(MasterAllocatorTest, RebalancedForUpdatedWeights)
   EXPECT_EQ(Resources(framework1offers2.get()[0].resources()),
             Resources::parse(agentResources).get());
 
-  AWAIT_READY(framework2offers);
-  ASSERT_EQ(2u, framework2offers.get().size());
+  ASSERT_EQ(2u, framework2offers.size());
   for (int i = 0; i < 2; i++) {
-    EXPECT_EQ(Resources(framework2offers.get()[i].resources()),
+    Future<Offer> offer = framework2offers.get();
+
+    // All offers for framework2 are enqueued by now.
+    AWAIT_READY(offer);
+    EXPECT_EQ(Resources(offer->resources()),
               Resources::parse(agentResources).get());
   }