MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / test_server_lost_finish_running_with_task

Function test_server_lost_finish_running_with_task

tests/test_worker.py:282–304  ·  view source on GitHub ↗
(hq_env: HqEnv)

Source from the content-addressed store, hash-verified

280
281
282def test_server_lost_finish_running_with_task(hq_env: HqEnv):
283 hq_env.start_server()
284 worker = hq_env.start_worker(on_server_lost="finish-running")
285 path = os.path.join(hq_env.work_path, "finished")
286 hq_env.command(
287 [
288 "submit",
289 "--array=1-10",
290 "--",
291 "bash",
292 "-c",
293 f"sleep 2; touch {path}-$HQ_TASK_ID",
294 ]
295 )
296 wait_for_job_state(hq_env, 1, "RUNNING")
297 hq_env.kill_server()
298 time.sleep(0.5)
299 assert worker.poll() is None
300 time.sleep(2.0)
301 hq_env.check_process_exited(worker, expected_code=1)
302
303 files = [path for path in os.listdir(hq_env.work_path) if path.startswith("finished-")]
304 assert len(files) == 1
305
306
307def test_server_lost_finish_running_explicit_stop(hq_env: HqEnv):

Callers

nothing calls this directly

Calls 7

wait_for_job_stateFunction · 0.85
commandMethod · 0.80
kill_serverMethod · 0.80
sleepMethod · 0.80
check_process_exitedMethod · 0.80
start_serverMethod · 0.45
start_workerMethod · 0.45

Tested by

no test coverage detected