17 #ifndef __TESTS_ALLOCATOR_HPP__
18 #define __TESTS_ALLOCATOR_HPP__
20 #include <gmock/gmock.h>
32 using ::testing::DoDefault;
33 using ::testing::Invoke;
34 using ::testing::Return;
48 allocator->real->initialize(
arg0,
arg1, arg2, arg3, arg4);
54 allocator->real->recover(
arg0,
arg1);
60 allocator->real->addFramework(
arg0,
arg1, arg2, arg3, arg4);
66 allocator->real->removeFramework(
arg0);
72 allocator->real->activateFramework(
arg0);
78 allocator->real->deactivateFramework(
arg0);
84 allocator->real->updateFramework(
arg0,
arg1, arg2);
90 allocator->real->addSlave(
arg0,
arg1, arg2, arg3, arg4, arg5);
96 allocator->real->removeSlave(
arg0);
102 allocator->real->updateSlave(
arg0,
arg1, arg2, arg3);
108 allocator->real->addResourceProvider(
arg0,
arg1, arg2);
114 allocator->real->activateSlave(
arg0);
120 allocator->real->deactivateSlave(
arg0);
126 allocator->real->updateWhitelist(
arg0);
132 allocator->real->requestResources(
arg0,
arg1);
138 allocator->real->updateAllocation(
arg0,
arg1, arg2, arg3);
144 return allocator->real->updateAvailable(
arg0,
arg1);
150 return allocator->real->updateUnavailability(
arg0,
arg1);
156 return allocator->real->updateInverseOffer(
arg0,
arg1, arg2, arg3, arg4);
162 return allocator->real->getInverseOfferStatuses();
168 allocator->real->recoverResources(
arg0,
arg1, arg2, arg3);
172 ACTION_P2(InvokeRecoverResourcesWithFilters, allocator, timeout)
175 filters.set_refuse_seconds(timeout);
177 allocator->real->recoverResources(
arg0,
arg1, arg2, filters);
183 allocator->real->suppressOffers(
arg0,
arg1);
189 allocator->real->reviveOffers(
arg0,
arg1);
195 allocator->real->setQuota(
arg0,
arg1);
201 allocator->real->removeQuota(
arg0);
207 allocator->real->updateWeights(
arg0);
211 template <
typename T = master::allocator::HierarchicalDRFAllocator>
218 return CHECK_NOTNULL(instance.
get());
221 template <
typename T = master::allocator::HierarchicalDRFAllocator>
239 .WillByDefault(InvokeInitialize(
this));
240 EXPECT_CALL(*
this,
initialize(_, _, _, _, _, _))
241 .WillRepeatedly(DoDefault());
244 .WillByDefault(InvokeRecover(
this));
245 EXPECT_CALL(*
this,
recover(_, _))
246 .WillRepeatedly(DoDefault());
249 .WillByDefault(InvokeAddFramework(
this));
251 .WillRepeatedly(DoDefault());
254 .WillByDefault(InvokeRemoveFramework(
this));
256 .WillRepeatedly(DoDefault());
259 .WillByDefault(InvokeActivateFramework(
this));
261 .WillRepeatedly(DoDefault());
264 .WillByDefault(InvokeDeactivateFramework(
this));
266 .WillRepeatedly(DoDefault());
269 .WillByDefault(InvokeUpdateFramework(
this));
271 .WillRepeatedly(DoDefault());
273 ON_CALL(*
this,
addSlave(_, _, _, _, _, _))
274 .WillByDefault(InvokeAddSlave(
this));
275 EXPECT_CALL(*
this,
addSlave(_, _, _, _, _, _))
276 .WillRepeatedly(DoDefault());
279 .WillByDefault(InvokeRemoveSlave(
this));
281 .WillRepeatedly(DoDefault());
284 .WillByDefault(InvokeUpdateSlave(
this));
286 .WillRepeatedly(DoDefault());
289 .WillByDefault(InvokeAddResourceProvider(
this));
291 .WillRepeatedly(DoDefault());
294 .WillByDefault(InvokeActivateSlave(
this));
296 .WillRepeatedly(DoDefault());
299 .WillByDefault(InvokeDeactivateSlave(
this));
301 .WillRepeatedly(DoDefault());
304 .WillByDefault(InvokeUpdateWhitelist(
this));
306 .WillRepeatedly(DoDefault());
309 .WillByDefault(InvokeRequestResources(
this));
311 .WillRepeatedly(DoDefault());
314 .WillByDefault(InvokeUpdateAllocation(
this));
316 .WillRepeatedly(DoDefault());
319 .WillByDefault(InvokeUpdateAvailable(
this));
321 .WillRepeatedly(DoDefault());
324 .WillByDefault(InvokeUpdateUnavailability(
this));
326 .WillRepeatedly(DoDefault());
329 .WillByDefault(InvokeUpdateInverseOffer(
this));
331 .WillRepeatedly(DoDefault());
334 .WillByDefault(InvokeGetInverseOfferStatuses(
this));
336 .WillRepeatedly(DoDefault());
339 .WillByDefault(InvokeRecoverResources(
this));
341 .WillRepeatedly(DoDefault());
344 .WillByDefault(InvokeSuppressOffers(
this));
346 .WillRepeatedly(DoDefault());
349 .WillByDefault(InvokeReviveOffers(
this));
351 .WillRepeatedly(DoDefault());
354 .WillByDefault(InvokeSetQuota(
this));
356 .WillRepeatedly(DoDefault());
359 .WillByDefault(InvokeRemoveQuota(
this));
361 .WillRepeatedly(DoDefault());
364 .WillByDefault(InvokeUpdateWeights(
this));
366 .WillRepeatedly(DoDefault());
373 const lambda::function<
374 void(
const FrameworkID&,
376 const lambda::function<
377 void(
const FrameworkID&,
379 const Option<std::set<std::string>>&,
384 const int expectedAgentCount,
389 const FrameworkInfo&,
392 const std::set<std::string>&));
395 const FrameworkID&));
398 const FrameworkID&));
401 const FrameworkID&));
405 const FrameworkInfo&,
406 const std::set<std::string>&));
411 const std::vector<SlaveInfo::Capability>&,
423 const Option<std::vector<SlaveInfo::Capability>>&));
441 const std::vector<Request>&));
447 const std::vector<ResourceConversion>&));
451 const std::vector<Offer::Operation>&));
467 mesos::allocator::InverseOfferStatus>>>());
477 const std::set<std::string>&));
481 const std::set<std::string>&));
488 const std::string&));
491 const std::vector<WeightInfo>&));
500 #endif // __TESTS_ALLOCATOR_HPP__
virtual void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters)=0
Recovers resources.
virtual void removeQuota(const std::string &role)=0
Informs the allocator to remove quota for the given role.
virtual void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used)=0
Add resources from a local resource provider to an agent.
constexpr const char * arg1
Definition: shell.hpp:43
Definition: option.hpp:28
virtual void activateSlave(const SlaveID &slaveId)=0
Activates an agent.
virtual void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions)=0
Updates allocation by applying offer operations.
TestAllocator()
Definition: allocator.hpp:227
virtual void initialize(const Duration &allocationInterval, const lambda::function< void(const FrameworkID &, const hashmap< std::string, hashmap< SlaveID, Resources >> &)> &offerCallback, const lambda::function< void(const FrameworkID &, const hashmap< SlaveID, UnavailableResources > &)> &inverseOfferCallback, const Option< std::set< std::string >> &fairnessExcludeResourceNames=None(), bool filterGpuResources=true, const Option< DomainInfo > &domain=None())=0
Initializes the allocator when the master starts up.
Definition: resources.hpp:79
virtual void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)=0
Revives offers to this framework for the specified roles.
mesos::allocator::Allocator * createAllocator()
Definition: allocator.hpp:212
virtual process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses()=0
Retrieves the status of all inverse offers maintained by the allocator.
Definition: duration.hpp:32
virtual void deactivateFramework(const FrameworkID &frameworkId)=0
Deactivates a framework in the Mesos cluster.
constexpr const char * arg0
Definition: shell.hpp:42
virtual void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active, const std::set< std::string > &suppressedRoles)=0
Adds a framework to the Mesos cluster.
Definition: hashmap.hpp:38
virtual ~TestAllocator()
Definition: allocator.hpp:369
virtual void updateWeights(const std::vector< WeightInfo > &weightInfos)=0
Updates the weight associated with one or more roles.
#define CHECK_SOME(expression)
Definition: check.hpp:44
virtual void removeSlave(const SlaveID &slaveId)=0
Removes an agent from the Mesos cluster.
virtual void activateFramework(const FrameworkID &frameworkId)=0
Activates a framework in the Mesos cluster.
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:776
virtual void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles)=0
Updates capabilities of a framework in the Mesos cluster.
virtual void setQuota(const std::string &role, const Quota "a)=0
Informs the allocator to set quota for the given role.
Definition: allocator.hpp:222
MOCK_METHOD4(updateSlave, void(const SlaveID &, const SlaveInfo &, const Option< Resources > &, const Option< std::vector< SlaveInfo::Capability >> &))
virtual void removeFramework(const FrameworkID &frameworkId)=0
Removes a framework from the Mesos cluster.
MOCK_METHOD5(addFramework, void(const FrameworkID &, const FrameworkInfo &, const hashmap< SlaveID, Resources > &, bool active, const std::set< std::string > &))
virtual void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability)=0
Updates unavailability for an agent.
virtual void addSlave(const SlaveID &slaveId, const SlaveInfo &slaveInfo, const std::vector< SlaveInfo::Capability > &capabilities, const Option< Unavailability > &unavailability, const Resources &total, const hashmap< FrameworkID, Resources > &used)=0
Adds or re-adds an agent to the Mesos cluster.
Basic model of an allocator: resources are allocated to a framework in the form of offers...
Definition: allocator.hpp:55
virtual void deactivateSlave(const SlaveID &slaveId)=0
Deactivates an agent.
MOCK_METHOD6(initialize, void(const Duration &, const lambda::function< void(const FrameworkID &, const hashmap< std::string, hashmap< SlaveID, Resources >> &)> &, const lambda::function< void(const FrameworkID &, const hashmap< SlaveID, UnavailableResources > &)> &, const Option< std::set< std::string >> &, bool, const Option< DomainInfo > &))
virtual void updateWhitelist(const Option< hashset< std::string >> &whitelist)=0
Updates the list of trusted agents.
process::Owned< mesos::allocator::Allocator > real
Definition: allocator.hpp:493
virtual void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests)=0
Requests resources for a framework.
Try< Nothing > create(const std::string &hierarchy, const std::string &cgroup, bool recursive=false)
ACTION_P2(InvokeRecoverResourcesWithFilters, allocator, timeout)
Definition: allocator.hpp:172
virtual void recover(const int expectedAgentCount, const hashmap< std::string, Quota > "as)=0
Informs the allocator of the recovered state from the master.
ACTION_P(InvokeInitialize, allocator)
Definition: allocator.hpp:46
MOCK_METHOD2(recover, void(const int expectedAgentCount, const hashmap< std::string, Quota > &))
MOCK_METHOD3(updateFramework, void(const FrameworkID &, const FrameworkInfo &, const std::set< std::string > &))
virtual void suppressOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)=0
Suppresses offers.
MOCK_METHOD0(getInverseOfferStatuses, process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus >>>())
virtual process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations)=0
Updates available resources on an agent based on a sequence of offer operations.
const T & get() const
Definition: try.hpp:73
MOCK_METHOD1(removeFramework, void(const FrameworkID &))
virtual void updateInverseOffer(const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< InverseOfferStatus > &status, const Option< Filters > &filters=None())=0
Updates inverse offer.
virtual void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None())=0
Updates an agent.