MCPcopy Create free account
hub / github.com/apache/mesos / test_exec

Method test_exec

src/python/cli_new/lib/cli/tests/task.py:49–94  ·  view source on GitHub ↗

Basic test for the task `exec()` sub-command.

(self)

Source from the content-addressed store, hash-verified

47 Test class for the task plugin.
48 """
49 def test_exec(self):
50 """
51 Basic test for the task `exec()` sub-command.
52 """
53 # Launch a master, agent, and task.
54 master = Master()
55 master.launch()
56
57 agent = Agent()
58 agent.launch()
59
60 with open(LOREM_IPSUM) as text:
61 content = text.read()
62 command = "printf '{data}' > a.txt && sleep 1000".format(data=content)
63 task = Task({"command": command})
64 task.launch()
65
66 try:
67 wait_for_task(master, task.name, "TASK_RUNNING")
68 except Exception as exception:
69 raise CLIException(
70 "Error waiting for task '{name}' to"
71 " reach state '{state}': {error}"
72 .format(name=task.name, state="TASK_RUNNING", error=exception))
73
74 try:
75 tasks = http.get_json(master.addr, "tasks")["tasks"]
76 except Exception as exception:
77 raise CLIException(
78 "Could not get tasks from '/{endpoint}' on master: {error}"
79 .format(endpoint="tasks", error=exception))
80
81 self.assertEqual(type(tasks), list)
82 self.assertEqual(len(tasks), 1)
83
84 returncode, stdout, stderr = exec_command(
85 ["mesos", "task", "exec", tasks[0]["id"], "cat", "a.txt"])
86
87 self.assertEqual(returncode, 0)
88 self.assertEqual(stdout, content)
89 self.assertEqual(stderr, "")
90
91 # Kill the task, agent, and master.
92 task.kill()
93 agent.kill()
94 master.kill()
95
96 def test_exec_exit_status(self):
97 """

Callers

nothing calls this directly

Calls 15

launchMethod · 0.95
launchMethod · 0.95
launchMethod · 0.95
killMethod · 0.95
killMethod · 0.95
killMethod · 0.95
MasterClass · 0.90
AgentClass · 0.90
TaskClass · 0.90
wait_for_taskFunction · 0.90
CLIExceptionClass · 0.90
exec_commandFunction · 0.90

Tested by

no test coverage detected