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 2017/10/17 00:44:32 UTC
[13/14] mesos git commit: Avoided periodic allocations in api tests.
Avoided periodic allocations in api tests.
Turn off periodic allocations to avoid the race between
`HierarchicalAllocator::updateAvailable()` and periodic allocations.
Review: https://reviews.apache.org/r/63012
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4a39d12d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4a39d12d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4a39d12d
Branch: refs/heads/master
Commit: 4a39d12d115a2f7463c3c41fc7ae4dee12238eeb
Parents: a6bd245
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Oct 11 20:06:06 2017 -0700
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Mon Oct 16 17:42:43 2017 -0700
----------------------------------------------------------------------
src/tests/api_tests.cpp | 49 +++++++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4a39d12d/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 706dd9a..6fa49d7 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -113,6 +113,15 @@ class MasterAPITest
public WithParamInterface<ContentType>
{
public:
+ virtual master::Flags CreateMasterFlags()
+ {
+ // Turn off periodic allocations to avoid the race between
+ // `HierarchicalAllocator::updateAvailable()` and periodic allocations.
+ master::Flags flags = MesosTest::CreateMasterFlags();
+ flags.allocation_interval = Seconds(1000);
+ return flags;
+ }
+
// Helper function to post a request to "/api/v1" master endpoint and return
// the response.
Future<v1::master::Response> post(
@@ -973,11 +982,7 @@ TEST_P(MasterAPITest, ReserveResources)
EXPECT_CALL(allocator, initialize(_, _, _, _, _, _));
- // Set a low allocation interval to speed up this test.
- master::Flags flags = MesosTest::CreateMasterFlags();
- flags.allocation_interval = Milliseconds(50);
-
- Try<Owned<cluster::Master>> master = StartMaster(&allocator, flags);
+ Try<Owned<cluster::Master>> master = StartMaster(&allocator);
ASSERT_SOME(master);
Future<SlaveID> slaveId;
@@ -1018,9 +1023,6 @@ TEST_P(MasterAPITest, ReserveResources)
EXPECT_TRUE(Resources(offer.resources()).contains(
allocatedResources(unreserved, frameworkInfo.role())));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
// Expect an offer to be rescinded!
EXPECT_CALL(sched, offerRescinded(_, _));
@@ -1044,6 +1046,12 @@ TEST_P(MasterAPITest, ReserveResources)
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::Accepted().status, response);
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -1065,11 +1073,7 @@ TEST_P(MasterAPITest, UnreserveResources)
EXPECT_CALL(allocator, initialize(_, _, _, _, _, _));
- // Set a low allocation interval to speed up this test.
- master::Flags flags = MesosTest::CreateMasterFlags();
- flags.allocation_interval = Milliseconds(50);
-
- Try<Owned<cluster::Master>> master = StartMaster(&allocator, flags);
+ Try<Owned<cluster::Master>> master = StartMaster(&allocator);
ASSERT_SOME(master);
Future<SlaveID> slaveId;
@@ -1130,9 +1134,6 @@ TEST_P(MasterAPITest, UnreserveResources)
EXPECT_TRUE(Resources(offer.resources()).contains(
allocatedResources(dynamicallyReserved, frameworkInfo.role())));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
// Expect an offer to be rescinded!
EXPECT_CALL(sched, offerRescinded(_, _));
@@ -1155,6 +1156,12 @@ TEST_P(MasterAPITest, UnreserveResources)
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::Accepted().status, unreserveResponse);
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -2206,6 +2213,7 @@ TEST_P(MasterAPITest, EventAuthorizationFiltering)
}
master::Flags masterFlags = CreateMasterFlags();
+ masterFlags.allocation_interval = Milliseconds(50);
Result<Authorizer*> authorizer = Authorizer::create(acls);
Try<Owned<cluster::Master>> master =
@@ -3751,6 +3759,15 @@ class AgentAPITest
public WithParamInterface<ContentType>
{
public:
+ virtual master::Flags CreateMasterFlags()
+ {
+ // Turn off periodic allocations to avoid the race between
+ // `HierarchicalAllocator::updateAvailable()` and periodic allocations.
+ master::Flags flags = MesosTest::CreateMasterFlags();
+ flags.allocation_interval = Seconds(1000);
+ return flags;
+ }
+
// Helper function to post a request to "/api/v1" agent endpoint and return
// the response.
Future<v1::agent::Response> post(