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

Method test_exec_interactive

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

Test for the task `exec()` sub-command, using `--interactive`.

(self)

Source from the content-addressed store, hash-verified

140
141
142 def test_exec_interactive(self):
143 """
144 Test for the task `exec()` sub-command, using `--interactive`.
145 """
146 # Launch a master, agent, and task.
147 master = Master()
148 master.launch()
149
150 agent = Agent()
151 agent.launch()
152
153 task = Task({"command": "sleep 1000"})
154 task.launch()
155
156 try:
157 wait_for_task(master, task.name, "TASK_RUNNING")
158 except Exception as exception:
159 raise CLIException(
160 "Error waiting for task '{name}' to"
161 " reach state '{state}': {error}"
162 .format(name=task.name, state="TASK_RUNNING", error=exception))
163
164 try:
165 tasks = http.get_json(master.addr, "tasks")["tasks"]
166 except Exception as exception:
167 raise CLIException(
168 "Could not get tasks from '/{endpoint}' on master: {error}"
169 .format(endpoint="tasks", error=exception))
170
171 self.assertEqual(type(tasks), list)
172 self.assertEqual(len(tasks), 1)
173
174 with open(LOREM_IPSUM) as text:
175 returncode, stdout, stderr = exec_command(
176 ["mesos", "task", "exec", "-i", tasks[0]["id"], "cat"],
177 stdin=text)
178
179 self.assertEqual(returncode, 0)
180 with open(LOREM_IPSUM) as text:
181 self.assertEqual(stdout, text.read())
182 self.assertEqual(stderr, "")
183
184 # Kill the task, agent, and master.
185 task.kill()
186 agent.kill()
187 master.kill()
188
189
190 def test_list(self):

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