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:29 UTC
[10/14] mesos git commit: Avoided periodic allocations in persistent
volume endpoint tests.
Avoided periodic allocations in persistent volume endpoint tests.
Turn off periodic allocations to avoid the race between
`HierarchicalAllocator::updateAvailable()` and periodic allocations.
Review: https://reviews.apache.org/r/63010
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/adecb9ac
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/adecb9ac
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/adecb9ac
Branch: refs/heads/master
Commit: adecb9ac56d5ea4958a5308da9c3596bf240df78
Parents: 67a98cc
Author: Alexander Rukletsov <al...@apache.org>
Authored: Sat Oct 14 01:57:36 2017 -0700
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Mon Oct 16 17:42:43 2017 -0700
----------------------------------------------------------------------
src/tests/persistent_volume_endpoints_tests.cpp | 153 ++++++++++---------
1 file changed, 84 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/adecb9ac/src/tests/persistent_volume_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_endpoints_tests.cpp b/src/tests/persistent_volume_endpoints_tests.cpp
index 97b7c99..cd83abc 100644
--- a/src/tests/persistent_volume_endpoints_tests.cpp
+++ b/src/tests/persistent_volume_endpoints_tests.cpp
@@ -73,12 +73,14 @@ namespace tests {
class PersistentVolumeEndpointsTest : public MesosTest
{
public:
- // Set up the master flags such that it allows registration of the
- // framework created with 'createFrameworkInfo'.
+ // Set up the master flags such that it allows registration of the framework
+ // created with 'createFrameworkInfo'.
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 = Milliseconds(50);
+ flags.allocation_interval = Seconds(1000);
flags.roles = createFrameworkInfo().role();
return flags;
}
@@ -170,9 +172,6 @@ TEST_F(PersistentVolumeEndpointsTest, StaticReservation)
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&rescindedOfferId));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
Future<Response> destroyResponse = process::http::post(
master.get()->pid,
"destroy-volumes",
@@ -185,6 +184,12 @@ TEST_F(PersistentVolumeEndpointsTest, StaticReservation)
EXPECT_EQ(rescindedOfferId.get(), offer.id());
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -263,9 +268,6 @@ TEST_F(PersistentVolumeEndpointsTest, DynamicReservation)
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&rescindedOfferId));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
Resources volume = createPersistentVolume(
Megabytes(64),
frameworkInfo.role(),
@@ -287,6 +289,12 @@ TEST_F(PersistentVolumeEndpointsTest, DynamicReservation)
EXPECT_EQ(rescindedOfferId.get(), offer.id());
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -779,9 +787,6 @@ TEST_F(PersistentVolumeEndpointsTest, BadCredentials)
// operator to perform volume creation/destruction operations successfully.
TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACL)
{
- // Pause the clock to gain control over the offer cycle.
- Clock::pause();
-
ACLs acls;
// This ACL asserts that the principal of `DEFAULT_CREDENTIAL`
@@ -816,7 +821,7 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACL)
Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
ASSERT_SOME(slave);
- // Advance clock to trigger agent registration before we HTTP POST.
+ // Advance the clock to trigger agent registration before we HTTP POST.
Clock::advance(slaveFlags.registration_backoff_factor);
AWAIT_READY(slaveRegisteredMessage);
@@ -856,9 +861,6 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACL)
driver.start();
- Clock::settle();
- Clock::advance(masterFlags.allocation_interval);
-
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -872,9 +874,6 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACL)
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&rescindedOfferId));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
Future<Response> destroyResponse = process::http::post(
master.get()->pid,
"destroy-volumes",
@@ -883,13 +882,16 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACL)
AWAIT_EXPECT_RESPONSE_STATUS_EQ(Accepted().status, destroyResponse);
- Clock::settle();
- Clock::advance(masterFlags.allocation_interval);
-
AWAIT_READY(rescindedOfferId);
EXPECT_EQ(rescindedOfferId.get(), offer.id());
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -977,9 +979,6 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateACLMultipleRoles)
// principal will lead to a properly failed request.
TEST_F(PersistentVolumeEndpointsTest, BadCreateAndDestroyACL)
{
- // Pause the clock to gain control over the offer cycle.
- Clock::pause();
-
ACLs acls;
// This ACL asserts that the principal of `DEFAULT_CREDENTIAL_2`
@@ -1083,9 +1082,6 @@ TEST_F(PersistentVolumeEndpointsTest, BadCreateAndDestroyACL)
driver.start();
- Clock::settle();
- Clock::advance(masterFlags.allocation_interval);
-
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -1189,9 +1185,6 @@ TEST_F(PersistentVolumeEndpointsTest, BadCreateACLMultipleRoles)
// is provided.
TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACLBadCredential)
{
- // Pause the clock to gain control over the offer cycle.
- Clock::pause();
-
// Create a credential which will not be listed
// for valid authentication with the master.
Credential failedCredential;
@@ -1286,9 +1279,6 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACLBadCredential)
driver.start();
- Clock::settle();
- Clock::advance(masterFlags.allocation_interval);
-
AWAIT_READY(offers);
ASSERT_EQ(1u, offers->size());
@@ -1533,16 +1523,21 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
EXPECT_EQ(offer.slave_id(), slaveId);
- // We use the filter explicitly here so that the resources will not
- // be filtered for 5 seconds (the default).
- Filters filters;
- filters.set_refuse_seconds(0);
+ Future<CheckpointResourcesMessage> checkpointResources =
+ FUTURE_PROTOBUF(CheckpointResourcesMessage(), _, _);
+ // Reserve the resources.
+ driver.acceptOffers({offer.id()}, {RESERVE(dynamicallyReserved)});
+
+ // Make sure the allocator processes the `RESERVE` operation before summoning
+ // an offer.
+ AWAIT_READY(checkpointResources);
+
+ // Summon an offer.
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers));
- // Reserve the resources.
- driver.acceptOffers({offer.id()}, {RESERVE(dynamicallyReserved)}, filters);
+ driver.reviveOffers();
// Expect an offer with reserved resources.
AWAIT_READY(offers);
@@ -1563,11 +1558,19 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
None(),
frameworkInfo.principal());
+ checkpointResources = FUTURE_PROTOBUF(CheckpointResourcesMessage(), _, _);
+
+ // Create the volume.
+ driver.acceptOffers({offer.id()}, {CREATE(volume)});
+
+ // Make sure the master processes the accept call before summoning an offer.
+ AWAIT_READY(checkpointResources);
+
+ // Summon an offer.
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers));
- // Create the volume.
- driver.acceptOffers({offer.id()}, {CREATE(volume)}, filters);
+ driver.reviveOffers();
// Expect an offer with a persistent volume.
AWAIT_READY(offers);
@@ -1583,9 +1586,6 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&rescindedOfferId));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
// Destroy the volume using HTTP operator endpoint.
Future<Response> destroyResponse = process::http::post(
master.get()->pid,
@@ -1598,6 +1598,12 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
AWAIT_READY(rescindedOfferId);
EXPECT_EQ(rescindedOfferId.get(), offer.id());
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
// Expect an offer containing reserved resources.
AWAIT_READY(offers);
@@ -1610,9 +1616,6 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
EXPECT_CALL(sched, offerRescinded(&driver, _))
.WillOnce(FutureArg<1>(&rescindedOfferId));
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(FutureArg<1>(&offers));
-
// Unreserve the resources using HTTP operator endpoint.
Future<Response> unreserveResponse = process::http::post(
master.get()->pid,
@@ -1625,6 +1628,12 @@ TEST_F(PersistentVolumeEndpointsTest, OfferCreateThenEndpointRemove)
AWAIT_READY(rescindedOfferId);
EXPECT_EQ(rescindedOfferId.get(), offer.id());
+ // Summon an offer.
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.reviveOffers();
+
// Expect an offer containing only unreserved resources.
AWAIT_READY(offers);
@@ -1716,18 +1725,19 @@ TEST_F(PersistentVolumeEndpointsTest, EndpointCreateThenOfferRemove)
EXPECT_TRUE(Resources(offer.resources()).contains(
allocatedResources(volume, frameworkInfo.role())));
- // We use the filter explicitly here so that the resources will not
- // be filtered for 5 seconds (the default).
- Filters filters;
- filters.set_refuse_seconds(0);
+ Future<CheckpointResourcesMessage> checkpointResources =
+ FUTURE_PROTOBUF(CheckpointResourcesMessage(), _, _);
+ driver.acceptOffers({offer.id()}, {DESTROY(volume)});
+
+ // Make sure the master processes the accept call before summoning an offer.
+ AWAIT_READY(checkpointResources);
+
+ // Summon an offer.
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers));
- driver.acceptOffers(
- {offer.id()},
- {DESTROY(volume)},
- filters);
+ driver.reviveOffers();
// Expect an offer containing the dynamic reservation.
AWAIT_READY(offers);
@@ -1741,11 +1751,19 @@ TEST_F(PersistentVolumeEndpointsTest, EndpointCreateThenOfferRemove)
<< Resources(offer.resources()) << " vs "
<< allocatedResources(dynamicallyReserved, frameworkInfo.role());
+ checkpointResources = FUTURE_PROTOBUF(CheckpointResourcesMessage(), _, _);
+
+ // Unreserve the resources.
+ driver.acceptOffers({offer.id()}, {UNRESERVE(dynamicallyReserved)});
+
+ // Make sure the master processes the accept call before summoning an offer.
+ AWAIT_READY(checkpointResources);
+
+ // Summon an offer.
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers));
- // Unreserve the resources.
- driver.acceptOffers({offer.id()}, {UNRESERVE(dynamicallyReserved)}, filters);
+ driver.reviveOffers();
// Expect an offer containing only unreserved resources.
AWAIT_READY(offers);
@@ -1769,8 +1787,6 @@ TEST_F(PersistentVolumeEndpointsTest, ReserveAndSlaveRemoval)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- Clock::pause();
-
Future<SlaveRegisteredMessage> slave1RegisteredMessage =
FUTURE_PROTOBUF(SlaveRegisteredMessage(), master.get()->pid, _);
@@ -1969,25 +1985,24 @@ TEST_F(PersistentVolumeEndpointsTest, SlavesEndpointFullResources)
TaskInfo taskInfo = createTask(offer.slave_id(), taskResources, "sleep 1000");
- // We use the filter explicitly here so that the resources will not
- // be filtered for 5 seconds (the default).
- Filters filters;
- filters.set_refuse_seconds(0);
-
// Expect a TASK_RUNNING status.
EXPECT_CALL(sched, statusUpdate(&driver, _));
Future<Nothing> _statusUpdateAcknowledgement =
FUTURE_DISPATCH(_, &Slave::_statusUpdateAcknowledgement);
- // Expect another resource offer.
+ driver.acceptOffers({offer.id()}, {LAUNCH({taskInfo})});
+
+ // Wait for TASK_RUNNING update ack.
+ AWAIT_READY(_statusUpdateAcknowledgement);
+
+ // Summon an offer.
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers));
- driver.acceptOffers({offer.id()}, {LAUNCH({taskInfo})}, filters);
+ driver.reviveOffers();
- // Wait for TASK_RUNNING update ack.
- AWAIT_READY(_statusUpdateAcknowledgement);
+ AWAIT_READY(offers);
response = process::http::get(
master.get()->pid,