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

Method test_exec_exit_status

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

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

(self)

Source from the content-addressed store, hash-verified

94 master.kill()
95
96 def test_exec_exit_status(self):
97 """
98 Basic test for the task `exec()` sub-command exit status.
99 """
100 # Launch a master, agent, and task.
101 master = Master()
102 master.launch()
103
104 agent = Agent()
105 agent.launch()
106
107 task = Task({"command": "sleep 1000"})
108 task.launch()
109
110 try:
111 wait_for_task(master, task.name, "TASK_RUNNING")
112 except Exception as exception:
113 raise CLIException(
114 "Error waiting for task '{name}' to"
115 " reach state '{state}': {error}"
116 .format(name=task.name, state="TASK_RUNNING", error=exception))
117
118 try:
119 tasks = http.get_json(master.addr, "tasks")["tasks"]
120 except Exception as exception:
121 raise CLIException(
122 "Could not get tasks from '/{endpoint}' on master: {error}"
123 .format(endpoint="tasks", error=exception))
124
125 self.assertEqual(type(tasks), list)
126 self.assertEqual(len(tasks), 1)
127
128 returncode, _, _ = exec_command(
129 ["mesos", "task", "exec", tasks[0]["id"], "true"])
130 self.assertEqual(returncode, 0)
131
132 returncode, _, _ = exec_command(
133 ["mesos", "task", "exec", tasks[0]["id"], "bash", "-c", "exit 10"])
134 self.assertEqual(returncode, 10)
135
136 # Kill the task, agent, and master.
137 task.kill()
138 agent.kill()
139 master.kill()
140
141
142 def test_exec_interactive(self):

Callers

nothing calls this directly

Calls 14

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