You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/10/31 23:01:16 UTC

mesos git commit: Updated tests to use `createCallKill`.

Repository: mesos
Updated Branches:
  refs/heads/master f9b7a76c9 -> 816518867


Updated tests to use `createCallKill`.

Updated all the tests that send v1 API KILL calls to use the
`createCallKill` test helper.

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


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

Branch: refs/heads/master
Commit: 8165188676ebc00707b61f6782a171170098b6be
Parents: f9b7a76
Author: James Peach <jp...@apache.org>
Authored: Tue Oct 31 15:42:07 2017 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue Oct 31 16:00:28 2017 -0700

----------------------------------------------------------------------
 src/tests/mesos.hpp           |  5 +++++
 src/tests/scheduler_tests.cpp | 13 ++-----------
 src/tests/slave_tests.cpp     | 39 ++++++--------------------------------
 3 files changed, 13 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/81651886/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index c5e0224..e25defe 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1917,6 +1917,7 @@ inline mesos::v1::scheduler::Call createCallAcknowledge(
 inline mesos::v1::scheduler::Call createCallKill(
     const mesos::v1::FrameworkID& frameworkId,
     const mesos::v1::TaskID& taskId,
+    const Option<mesos::v1::AgentID>& agentId = None(),
     const Option<mesos::v1::KillPolicy>& killPolicy = None())
 {
   mesos::v1::scheduler::Call call;
@@ -1926,6 +1927,10 @@ inline mesos::v1::scheduler::Call createCallKill(
   mesos::v1::scheduler::Call::Kill* kill = call.mutable_kill();
   kill->mutable_task_id()->CopyFrom(taskId);
 
+  if (agentId.isSome()) {
+    kill->mutable_agent_id()->CopyFrom(agentId.get());
+  }
+
   if (killPolicy.isSome()) {
     kill->mutable_kill_policy()->CopyFrom(killPolicy.get());
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/81651886/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 6df4d32..60f60cc 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -1026,17 +1026,8 @@ TEST_P(SchedulerTest, KillTask)
     .WillOnce(v1::executor::SendUpdateFromTaskID(
         frameworkId, evolve(executorId), v1::TASK_KILLED));
 
-  {
-    Call call;
-    call.mutable_framework_id()->CopyFrom(frameworkId);
-    call.set_type(Call::KILL);
-
-    Call::Kill* kill = call.mutable_kill();
-    kill->mutable_task_id()->CopyFrom(taskInfo.task_id());
-    kill->mutable_agent_id()->CopyFrom(offer.agent_id());
-
-    mesos.send(call);
-  }
+  mesos.send(
+      v1::createCallKill(frameworkId, taskInfo.task_id(), offer.agent_id()));
 
   AWAIT_READY(update2);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/81651886/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 7766ae1..aae5e60 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -4449,17 +4449,8 @@ TEST_F(SlaveTest, KillTaskUnregisteredHTTPExecutor)
     .WillOnce(FutureArg<1>(&update1))
     .WillOnce(FutureArg<1>(&update2));
 
-  {
-    Call call;
-    call.mutable_framework_id()->CopyFrom(frameworkId);
-    call.set_type(Call::KILL);
-
-    Call::Kill* kill = call.mutable_kill();
-    kill->mutable_task_id()->CopyFrom(task1.task_id());
-    kill->mutable_agent_id()->CopyFrom(offer.agent_id());
-
-    mesos.send(call);
-  }
+  mesos.send(
+      v1::createCallKill(frameworkId, task1.task_id(), offer.agent_id()));
 
   AWAIT_READY(update1);
   AWAIT_READY(update2);
@@ -7147,17 +7138,8 @@ TEST_F(SlaveTest, KillTaskGroupBetweenRunTaskParts)
     .WillOnce(DoAll(Invoke(&slave, &MockSlave::unmocked_removeFramework),
                     FutureSatisfy(&removeFramework)));
 
-  {
-    Call call;
-    call.mutable_framework_id()->CopyFrom(frameworkId);
-    call.set_type(Call::KILL);
-
-    Call::Kill* kill = call.mutable_kill();
-    kill->mutable_task_id()->CopyFrom(taskInfo1.task_id());
-    kill->mutable_agent_id()->CopyFrom(offer.agent_id());
-
-    mesos.send(call);
-  }
+  mesos.send(
+      v1::createCallKill(frameworkId, taskInfo1.task_id(), offer.agent_id()));
 
   AWAIT_READY(killTask);
 
@@ -7426,17 +7408,8 @@ TEST_F(SlaveTest, KillQueuedTaskGroup)
 
   // Kill a task in the task group before the executor
   // subscribes with the agent.
-  {
-    Call call;
-    call.mutable_framework_id()->CopyFrom(frameworkId);
-    call.set_type(Call::KILL);
-
-    Call::Kill* kill = call.mutable_kill();
-    kill->mutable_task_id()->CopyFrom(taskInfo2.task_id());
-    kill->mutable_agent_id()->CopyFrom(offer.agent_id());
-
-    mesos.send(call);
-  }
+  mesos.send(
+      v1::createCallKill(frameworkId, taskInfo2.task_id(), offer.agent_id()));
 
   AWAIT_READY(update1);
   AWAIT_READY(update2);