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:41 UTC
[5/6] mesos git commit: Fixed
OversubscriptionTest.RescindRevocableOfferWithIncreasedRevocable.
Fixed OversubscriptionTest.RescindRevocableOfferWithIncreasedRevocable.
- This test is broken by changes introduced in MESOS-6904.
Review: https://reviews.apache.org/r/55893/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f6aaddb9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f6aaddb9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f6aaddb9
Branch: refs/heads/master
Commit: f6aaddb922b5265ede77afd83fef941da77ee0c4
Parents: daa1528
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Wed Feb 1 11:08:27 2017 -0800
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Wed Feb 1 12:16:18 2017 -0800
----------------------------------------------------------------------
src/tests/oversubscription_tests.cpp | 67 ++++++++++++++-----------------
1 file changed, 31 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f6aaddb9/src/tests/oversubscription_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/oversubscription_tests.cpp b/src/tests/oversubscription_tests.cpp
index 22ae069..167beaf 100644
--- a/src/tests/oversubscription_tests.cpp
+++ b/src/tests/oversubscription_tests.cpp
@@ -441,9 +441,7 @@ TEST_F(OversubscriptionTest, RevocableOffer)
// This test verifies that when the master receives a new estimate for
// oversubscribed resources it rescinds outstanding revocable offers.
// In this test the oversubscribed resources are increased, so the master
-// will send out two offers, the first one is the increased oversubscribed
-// resources and the second one is the oversubscribed resources from the
-// rescind offered resources.
+// will send out new offers with increased revocable resources.
TEST_F(OversubscriptionTest, RescindRevocableOfferWithIncreasedRevocable)
{
// Pause the clock because we want to manually drive the allocations.
@@ -484,40 +482,36 @@ TEST_F(OversubscriptionTest, RescindRevocableOfferWithIncreasedRevocable)
EXPECT_CALL(sched, registered(&driver, _, _));
- Future<vector<Offer>> offers1;
+ Queue<Offer> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers1));
+ .WillRepeatedly(EnqueueOffers(&offers));
driver.start();
// Initially the framework will get all regular resources.
Clock::advance(agentFlags.registration_backoff_factor);
Clock::advance(masterFlags.allocation_interval);
- AWAIT_READY(offers1);
- EXPECT_NE(0u, offers1->size());
- EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());
+ Clock::settle();
- Future<vector<Offer>> offers2;
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers2));
+ EXPECT_EQ(1u, offers.size());
+ EXPECT_TRUE(Resources(offers.get()->resources()).revocable().empty());
// Inject an estimation of oversubscribable resources.
Resources resources1 = createRevocableResources("cpus", "1");
estimations.put(resources1);
// Now the framework will get revocable resources.
- AWAIT_READY(offers2);
- EXPECT_NE(0u, offers2->size());
- EXPECT_EQ(resources1, Resources(offers2.get()[0].resources()));
+ Clock::settle();
+
+ EXPECT_EQ(1u, offers.size());
+ Future<Offer> offer = offers.get();
+ AWAIT_READY(offer);
+ EXPECT_EQ(resources1, Resources(offer->resources()));
Future<OfferID> offerId;
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&offerId));
- Future<vector<Offer>> offers3;
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers3));
-
// Inject another estimation of increased oversubscribable resources
// while the previous revocable offer is outstanding.
Resources resources2 = createRevocableResources("cpus", "3");
@@ -528,27 +522,28 @@ TEST_F(OversubscriptionTest, RescindRevocableOfferWithIncreasedRevocable)
Clock::settle();
// The previous revocable offer should be rescinded.
- AWAIT_EXPECT_EQ(offers2.get()[0].id(), offerId);
-
- // The new offer should be the increased oversubscribed resources.
- AWAIT_READY(offers3);
- EXPECT_NE(0u, offers3->size());
- EXPECT_EQ(createRevocableResources("cpus", "2"),
- Resources(offers3.get()[0].resources()));
-
- Future<vector<Offer>> offers4;
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers4));
-
- // Advance the clock to trigger a batch allocation, this will
- // allocate the oversubscribed resources that were rescinded.
+ AWAIT_EXPECT_EQ(offer->id(), offerId);
+
+ // The allocation run triggered by the agent resource update may or
+ // may not take into account the rescinded offer due to a race
+ // between the dispatched allocation and the recovery of the resources
+ // from the recinded offer. Therefore we advance the clock after these
+ // resources are recovered to trigger a batch allocation to make sure
+ // all resources are allocated.
+ Clock::settle();
Clock::advance(masterFlags.allocation_interval);
Clock::settle();
- // The new offer should be the old oversubscribed resources.
- AWAIT_READY(offers4);
- EXPECT_NE(0u, offers4->size());
- EXPECT_EQ(resources1, Resources(offers4.get()[0].resources()));
+ ASSERT_GT(offers.size(), 0);
+
+ // The total offered resources after the latest estimate.
+ Resources resources3;
+ for (size_t i = 0; i < offers.size(); i++) {
+ resources3 += offers.get()->resources();
+ }
+
+ // The offered resources should match the resource estimate.
+ EXPECT_EQ(resources2, resources3);
driver.stop();
driver.join();