Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 320 additions & 6 deletions app/nullius/execution.py

Large diffs are not rendered by default.

366 changes: 366 additions & 0 deletions app/tests/test_execution_queue.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/ui_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ def test_a_running_run_is_stopped_from_another_machine(self):
for _ in range(400):
if "started" in "\n".join(self.get(f"/runs/{run_id}").json["log"]): break
time.sleep(0.02)
with patch.object(execution, "stop", lambda ex: False): # a queue's Stop that could not be saved
s = self.post(f"/runs/{run_id}/stop", environ_base={"REMOTE_ADDR": "10.0.0.7"})
self.assertEqual((s.status_code, "no run was told" in s.json["error"]), (503, True))
s = self.post(f"/runs/{run_id}/stop", environ_base={"REMOTE_ADDR": "10.0.0.7"})
self.assertEqual((s.status_code, s.json["id"]), (200, run_id))
self.assertIn(s.json["state"], ("stopping", "stopped"))
Expand Down
4 changes: 4 additions & 0 deletions app/ui_tests/test_run_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ def test_the_page_carries_the_token_the_stop_button_sends(self):
for _ in range(200):
if ex.pid: break
time.sleep(0.02)
with patch.object(execution, "stop", lambda ex: False): # a queue's Stop that could not be saved: said, none told
s = self.client.post(f"/run/{r.json['id']}/stop", headers={"Origin": "http://localhost", "X-CSRF-Token": self.csrf}); self.addCleanup(s.close)
self.assertEqual((s.status_code, s.json["ok"], ex.state), (503, False, "running"))
self.assertIn("no run was told", s.json["error"])
s = self.client.post(f"/run/{r.json['id']}/stop", headers={"Origin": "http://localhost", "X-CSRF-Token": self.csrf}); self.addCleanup(s.close)
self.assertEqual(s.status_code, 200); self.assertEqual(s.json["state"], "stopping") # said at once
ex.thread.join(10); self.assertEqual((ex.state, ex.exit_code), ("stopped", 130))
Expand Down
3 changes: 2 additions & 1 deletion app/web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ def api_run(run_id):
@api("run")
def api_run_stop(run_id):
ex = _run(run_id)
ex.stop()
if not execution.stop(ex): # a suite's Stop is its whole queue's, saved before its runs are told
raise _Refused(503, "the Stop could not be saved, so no run was told: stop it again")
return _json(ex.summary())


Expand Down
3 changes: 2 additions & 1 deletion app/web/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ def run_stop(run_id):
ex = execution.EXECUTIONS.get(run_id)
if ex is None:
abort(404)
ex.stop()
if not execution.stop(ex): # a suite's Stop is its whole queue's, saved before its runs are told
return jsonify({**ex.summary(), "ok": False, "error": "The Stop could not be saved, so no run was told: stop it again."}), 503
return jsonify(ok=True, **ex.summary())


Expand Down