mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbann...@apache.org
Subject [2/3] mesos git commit: Added test of handling of checkpointed resources in reregistration.
Date Thu, 04 Jan 2018 12:27:17 GMT
Added test of handling of checkpointed resources in reregistration.

This patch adds a test that confirms that the master resends
checkpointed resources to the agent on reregistration.

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


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

Branch: refs/heads/1.5.x
Commit: 6f134c93e52120ad6f29ef9057e2045ad8f24c7c
Parents: 4e5b8cf
Author: Benjamin Bannier <benjamin.bannier@mesosphere.io>
Authored: Thu Jan 4 11:12:17 2018 +0100
Committer: Benjamin Bannier <bbannier@apache.org>
Committed: Thu Jan 4 11:39:59 2018 +0100

----------------------------------------------------------------------
 src/tests/slave_recovery_tests.cpp | 95 +++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6f134c93/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 387c2ff..23a2909 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -4786,6 +4786,101 @@ TYPED_TEST(SlaveRecoveryTest, AgentReconfigurationWithRunningTask)
 }
 
 
+// This test verifies that checkpointed resources sent by a non resource
+// provider-capable agent during agent reregistration are ignored by
+// the master and that the master reattempts the checkpointing.
+TYPED_TEST(SlaveRecoveryTest, CheckpointedResources)
+{
+  Clock::pause();
+
+  master::Flags masterFlags = this->CreateMasterFlags();
+  Try<Owned<cluster::Master>> master = this->StartMaster(masterFlags);
+
+  slave::Flags slaveFlags = this->CreateSlaveFlags();
+
+  StandaloneMasterDetector detector(master.get()->pid);
+  Try<Owned<cluster::Slave>> slave = this->StartSlave(&detector, slaveFlags);
+  ASSERT_SOME(slave);
+
+  // Advance the clock to trigger the agent registration.
+  Clock::advance(slaveFlags.registration_backoff_factor);
+
+  FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
+  frameworkInfo.set_roles(0, "foo");
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);
+
+  EXPECT_CALL(sched, registered(&driver, _, _));
+
+  Future<vector<Offer>> offers1;
+  EXPECT_CALL(sched, resourceOffers(_, _))
+    .WillOnce(FutureArg<1>(&offers1))
+    .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+  driver.start();
+
+  // Advance the clock to trigger a batch allocation.
+  Clock::advance(masterFlags.allocation_interval);
+
+  AWAIT_READY(offers1);
+  ASSERT_FALSE(offers1->empty());
+
+  // Below we send a reserve operation which is applied in the master
+  // speculatively. We drop the operation on its way to the agent so
+  // that the master's and the agent's view of the agent's
+  // checkpointed resources diverge.
+  Future<CheckpointResourcesMessage> checkpointResourcesMessage =
+    DROP_PROTOBUF(CheckpointResourcesMessage(), _, _);
+
+  // 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);
+
+  const Offer& offer1 = offers1->at(0);
+
+  const Resources offeredResources = offer1.resources();
+  const Resources dynamicallyReserved =
+    offeredResources.pushReservation(createDynamicReservationInfo(
+        frameworkInfo.roles(0), frameworkInfo.principal()));
+
+  driver.acceptOffers({offer1.id()}, {RESERVE(dynamicallyReserved)}, filters);
+
+  AWAIT_READY(checkpointResourcesMessage);
+
+  // Restart and reregister the agent.
+  slave.get()->terminate();
+
+  slave = this->StartSlave(&detector, slaveFlags);
+
+  // Advance the clock to trigger an agent registration.
+  Clock::advance(slaveFlags.registration_backoff_factor);
+  Clock::settle();
+
+  Future<vector<Offer>> offers2;
+  EXPECT_CALL(sched, resourceOffers(_, _))
+    .WillOnce(FutureArg<1>(&offers2))
+    .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+  // Advance the clock to trigger a batch allocation.
+  Clock::advance(masterFlags.allocation_interval);
+  Clock::settle();
+
+  AWAIT_READY(offers2);
+  ASSERT_FALSE(offers2->empty());
+
+  const Offer& offer2 = offers2->at(0);
+
+  // The second offer will be identical to the first
+  // one as our operations never made it to the agent.
+  const Resources offeredResources2 = offer2.resources();
+
+  EXPECT_EQ(dynamicallyReserved, offeredResources2);
+}
+
+
 // We explicitly instantiate a SlaveRecoveryTest for test cases where
 // we assume we'll only have the MesosContainerizer.
 class MesosContainerizerSlaveRecoveryTest


Mime
View raw message