This is an automated email from the ASF dual-hosted git repository. qianzhang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 446e55c249dc97033c956c74244c4332b85fc339 Author: Qian Zhang <[email protected]> AuthorDate: Mon Jan 6 16:45:15 2020 +0800 Added a new parameter `resourceLimits` to the `createTask` methods. Review: https://reviews.apache.org/r/71955 --- src/tests/mesos.hpp | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 17fcaa3..0ad0999 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -910,20 +910,25 @@ template < typename TResources, typename TExecutorInfo, typename TCommandInfo, - typename TOffer> + typename TOffer, + typename TScalar> inline TTaskInfo createTask( const TSlaveID& slaveId, - const TResources& resources, + const TResources& resourceRequests, const TCommandInfo& command, const Option<TExecutorID>& executorId = None(), const std::string& name = "test-task", - const std::string& id = id::UUID::random().toString()) + const std::string& id = id::UUID::random().toString(), + const google::protobuf::Map<std::string, TScalar>& resourceLimits = {}) { TTaskInfo task; task.set_name(name); task.mutable_task_id()->set_value(id); setAgentID(&task, slaveId); - task.mutable_resources()->CopyFrom(resources); + task.mutable_resources()->CopyFrom(resourceRequests); + if (!resourceLimits.empty()) { + *task.mutable_limits() = resourceLimits; + } if (executorId.isSome()) { TExecutorInfo executor; executor.mutable_executor_id()->CopyFrom(executorId.get()); @@ -944,14 +949,16 @@ template < typename TResources, typename TExecutorInfo, typename TCommandInfo, - typename TOffer> + typename TOffer, + typename TScalar> inline TTaskInfo createTask( const TSlaveID& slaveId, - const TResources& resources, + const TResources& resourceRequests, const std::string& command, const Option<TExecutorID>& executorId = None(), const std::string& name = "test-task", - const std::string& id = id::UUID::random().toString()) + const std::string& id = id::UUID::random().toString(), + const google::protobuf::Map<std::string, TScalar>& resourceLimits = {}) { return createTask< TTaskInfo, @@ -960,13 +967,15 @@ inline TTaskInfo createTask( TResources, TExecutorInfo, TCommandInfo, - TOffer>( + TOffer, + TScalar>( slaveId, - resources, + resourceRequests, createCommandInfo<TCommandInfo>(command), executorId, name, - id); + id, + resourceLimits); } @@ -977,13 +986,15 @@ template < typename TResources, typename TExecutorInfo, typename TCommandInfo, - typename TOffer> + typename TOffer, + typename TScalar> inline TTaskInfo createTask( const TOffer& offer, const std::string& command, const Option<TExecutorID>& executorId = None(), const std::string& name = "test-task", - const std::string& id = id::UUID::random().toString()) + const std::string& id = id::UUID::random().toString(), + const google::protobuf::Map<std::string, TScalar>& resourceLimits = {}) { return createTask< TTaskInfo, @@ -992,13 +1003,15 @@ inline TTaskInfo createTask( TResources, TExecutorInfo, TCommandInfo, - TOffer>( + TOffer, + TScalar>( getAgentID(offer), offer.resources(), command, executorId, name, - id); + id, + resourceLimits); } @@ -1750,7 +1763,8 @@ inline TaskInfo createTask(Args&&... args) Resources, ExecutorInfo, CommandInfo, - Offer>(std::forward<Args>(args)...); + Offer, + Value::Scalar>(std::forward<Args>(args)...); } @@ -2040,7 +2054,8 @@ inline mesos::v1::TaskInfo createTask(Args&&... args) mesos::v1::Resources, mesos::v1::ExecutorInfo, mesos::v1::CommandInfo, - mesos::v1::Offer>(std::forward<Args>(args)...); + mesos::v1::Offer, + mesos::v1::Value::Scalar>(std::forward<Args>(args)...); }
