Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kvashchuka committed May 20, 2021
1 parent f3ade4d commit 2d08d1c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/res/job_queue/test_job_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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()

Expand Down

0 comments on commit 2d08d1c

Please sign in to comment.