You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2018/11/26 13:19:06 UTC
[mesos] branch master updated: Updated 'mesos task list' to only
display running tasks.
This is an automated email from the ASF dual-hosted git repository.
klueska pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 2b03f94 Updated 'mesos task list' to only display running tasks.
2b03f94 is described below
commit 2b03f942b5cf9375a75f08b36091c3b3e7f096ff
Author: Armand Grillet <ag...@mesosphere.io>
AuthorDate: Mon Nov 26 08:14:42 2018 -0500
Updated 'mesos task list' to only display running tasks.
Review: https://reviews.apache.org/r/69394/
---
src/python/cli_new/lib/cli/plugins/task/main.py | 7 +++++--
src/python/cli_new/lib/cli/tests/task.py | 10 +++++-----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/python/cli_new/lib/cli/plugins/task/main.py b/src/python/cli_new/lib/cli/plugins/task/main.py
index 4abc70a..0ce21b3 100644
--- a/src/python/cli_new/lib/cli/plugins/task/main.py
+++ b/src/python/cli_new/lib/cli/plugins/task/main.py
@@ -61,8 +61,8 @@ class Task(PluginBase):
"list": {
"arguments": [],
"flags": {},
- "short_help": "List all active tasks in a Mesos cluster",
- "long_help": "List all active tasks in a Mesos cluster"
+ "short_help": "List all running tasks in a Mesos cluster",
+ "long_help": "List all running tasks in a Mesos cluster"
}
}
@@ -126,6 +126,9 @@ class Task(PluginBase):
if task["statuses"]:
task_state = task["statuses"][-1]["state"]
+ if task_state != "TASK_RUNNING":
+ continue
+
table.add_row([task["id"],
task_state,
task["framework_id"],
diff --git a/src/python/cli_new/lib/cli/tests/task.py b/src/python/cli_new/lib/cli/tests/task.py
index 1b48c0a..eb01bf5 100644
--- a/src/python/cli_new/lib/cli/tests/task.py
+++ b/src/python/cli_new/lib/cli/tests/task.py
@@ -21,7 +21,6 @@ Task plugin tests.
import os
from cli import config
-from cli import http
from cli.exceptions import CLIException
@@ -162,9 +161,10 @@ class TestTaskPlugin(CLITestCase):
task = Task({"command": "sleep 1000"})
task.launch()
- # Open the master's `/tasks` endpoint and read the
- # task information ourselves.
- tasks = http.get_json(master.addr, 'tasks')["tasks"]
+ tasks = running_tasks(master)
+ if not tasks:
+ raise CLIException("Unable to find running tasks on master"
+ " '{master}'".format(master=master.addr))
self.assertEqual(type(tasks), list)
self.assertEqual(len(tasks), 1)
@@ -186,7 +186,7 @@ class TestTaskPlugin(CLITestCase):
self.assertEqual("Framework ID", table[0][2])
self.assertEqual("Executor ID", table[0][3])
self.assertEqual(tasks[0]["id"], table[1][0])
- self.assertEqual("UNKNOWN", table[1][1])
+ self.assertEqual(tasks[0]["statuses"][-1]["state"], table[1][1])
self.assertEqual(tasks[0]["framework_id"], table[1][2])
self.assertEqual(tasks[0]["executor_id"], table[1][3])