You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/08/12 23:45:16 UTC

[mesos] branch master updated: Fixed a flaky test `RescindOffersEnforcingLimits`.

This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 970026f  Fixed a flaky test `RescindOffersEnforcingLimits`.
970026f is described below

commit 970026f45f876caf8a156602e4fec89b47422c1c
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Mon Aug 12 12:28:34 2019 -0700

    Fixed a flaky test `RescindOffersEnforcingLimits`.
    
    The test is flaky because the agent is added before the
    framework and agent is not offered the framework as expected.
    This patch ensures that the framework is added before the agent.
    
    Review: https://reviews.apache.org/r/71273
---
 src/tests/master_quota_tests.cpp | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/tests/master_quota_tests.cpp b/src/tests/master_quota_tests.cpp
index b5fe235..5832869 100644
--- a/src/tests/master_quota_tests.cpp
+++ b/src/tests/master_quota_tests.cpp
@@ -2080,12 +2080,7 @@ TEST_F(MasterQuotaTest, RescindOffersEnforcingLimits)
   // Cluster resources: cpus:1;mem:1024
   // Allocated: `ROLE1` cpus:1;mem:1024
 
-  // Start a second agent with identical resources.
-  slave::Flags flags2 = CreateSlaveFlags();
-  flags2.resources = "cpus:1;mem:1024";
-  Try<Owned<cluster::Slave>> slave2 = StartSlave(detector.get(), flags2);
-  ASSERT_SOME(slave2);
-
+  // Add a 2nd framework.
   FrameworkInfo frameworkInfo2 = DEFAULT_FRAMEWORK_INFO;
   frameworkInfo2.set_roles(0, ROLE1 + "/child");
 
@@ -2097,20 +2092,29 @@ TEST_F(MasterQuotaTest, RescindOffersEnforcingLimits)
   EXPECT_CALL(sched2, registered(&framework2, _, _))
     .WillOnce(FutureArg<1>(&frameworkId2));
 
+  framework2.start();
+
+  AWAIT_READY(frameworkId2);
+
+  // Start a second agent with identical resources.
+  slave::Flags flags2 = CreateSlaveFlags();
+  flags2.resources = "cpus:1;mem:1024";
+  Try<Owned<cluster::Slave>> agent2 = StartSlave(detector.get(), flags2);
+  ASSERT_SOME(agent2);
+
+  // `agent2` will be allocated to `framework2` due to DRF.
   Future<vector<Offer>> offers2;
   EXPECT_CALL(sched2, resourceOffers(&framework2, _))
     .WillOnce(FutureArg<1>(&offers2))
     .WillRepeatedly(Return()); // Ignore subsequent offers.
 
+  AWAIT_READY(offers2);
+  ASSERT_EQ(1u, offers2->size());
+
   Future<Nothing> offerRescinded2;
   EXPECT_CALL(sched2, offerRescinded(&framework2, _))
     .WillOnce(FutureSatisfy(&offerRescinded2));
 
-  framework2.start();
-
-  AWAIT_READY(offers2);
-  ASSERT_EQ(1u, offers2->size());
-
   // Cluster resources: cpus:2;mem:2048
   // Allocated: `ROLE1`  cpus:1;mem:1024
   //            `ROLE1/child` cpus:1;mem:1024