From 2d08d1c4d5403e1bc0c4c95b068828fb53df3dd5 Mon Sep 17 00:00:00 2001 From: kvashchuka Date: Thu, 20 May 2021 14:01:48 +0200 Subject: [PATCH] Add test --- tests/res/job_queue/test_job_queue.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/res/job_queue/test_job_queue.py b/tests/res/job_queue/test_job_queue.py index d7c9633bf..c2c8da9be 100644 --- a/tests/res/job_queue/test_job_queue.py +++ b/tests/res/job_queue/test_job_queue.py @@ -39,7 +39,7 @@ def dummy_exit_callback(args): """ -def create_queue(script, max_submit=1, max_runtime=None): +def create_queue(script, max_submit=1, max_runtime=None, callback_timeout=None): driver = Driver(driver_type=QueueDriverEnum.LOCAL_DRIVER, max_running=5) job_queue = JobQueue(driver, max_submit=max_submit) with open(dummy_config["job_script"], "w") as f: @@ -59,6 +59,7 @@ def create_queue(script, max_submit=1, max_runtime=None): exit_callback_function=dummy_config["exit_callback"], callback_arguments=[{"job_number": i}], max_runtime=max_runtime, + callback_timeout=callback_timeout, ) job_queue.add_job(job, i) @@ -155,7 +156,18 @@ def test_failing_jobs(self): def test_timeout_jobs(self): with TestAreaContext("job_queue_test_kill") as work_area: - job_queue = create_queue(never_ending_script, max_submit=1, max_runtime=5) + job_numbers = set() + + def callback(arg): + nonlocal job_numbers + job_numbers.add(arg[0]["job_number"]) + + job_queue = create_queue( + never_ending_script, + max_submit=1, + max_runtime=5, + callback_timeout=callback, + ) assert job_queue.queue_size == 10 assert job_queue.is_active() @@ -177,6 +189,8 @@ def test_timeout_jobs(self): JobStatusType.JOB_QUEUE_IS_KILLED ) + assert job_numbers == set(range(10)) + for job in job_queue.job_list: job.wait_for()