Beispiel #1
0
def test_job_script_time_reserved() -> None:
    # Note: doesn't test that it works, that's what test_scheduler is for
    job_desc = JobDescription()
    job_desc.time_reserved = 70

    script = _job_desc_to_job_script(job_desc)

    assert '00-00:01:10' in script
Beispiel #2
0
def test_system_out_redirect2(
        scheduler_and_fs: Tuple[Scheduler, FileSystem]) -> None:
    sched, fs, _ = scheduler_and_fs

    job_desc = JobDescription()
    job_desc.working_directory = '/home'
    job_desc.command = 'ls'
    job_desc.time_reserved = 1
    job_desc.system_out_file = '/home/cerulean/test_sys_redirect.out'

    job_id = sched.submit(job_desc)
    sched.wait(job_id)

    sysout = (fs / 'home/cerulean/test_sys_redirect.out').read_text()

    retval = sched.get_exit_code(job_id)
    assert retval == 0
    assert 'cerulean' in sysout
Beispiel #3
0
def test_scheduler_timeout(
        scheduler_and_fs: Tuple[Scheduler, FileSystem]) -> None:
    sched, fs, _ = scheduler_and_fs

    job_desc = JobDescription()
    job_desc.working_directory = '/home/cerulean'
    job_desc.command = '/usr/local/bin/endless-job.sh'
    job_desc.time_reserved = 2
    job_id = sched.submit(job_desc)

    while sched.get_status(job_id) != JobStatus.RUNNING:
        time.sleep(0.1)

    t = 0.0
    while sched.get_status(job_id) != JobStatus.DONE:
        time.sleep(1.0)
        t += 1.0

    assert t < 100.0
Beispiel #4
0
def test_system_err_redirect2(
        scheduler_and_fs: Tuple[Scheduler, FileSystem]) -> None:
    sched, fs, _ = scheduler_and_fs

    job_desc = JobDescription()
    job_desc.working_directory = '/home/cerulean'
    job_desc.command = 'while [ a = a ] ; do echo bla >/dev/null; done'
    job_desc.time_reserved = 1
    job_desc.stderr_file = '/dev/null'
    job_desc.system_err_file = '/home/cerulean/test_sys_redirect.err'

    job_id = sched.submit(job_desc)
    sched.wait(job_id)

    syserr = (fs / 'home/cerulean/test_sys_redirect.err').read_text()

    print('Sys err: {}'.format(syserr))

    assert 'CANCELLED' in syserr or 'killed' in syserr or 'Killed' in syserr
Beispiel #5
0
def test_system_err_redirect(
        scheduler_and_fs: Tuple[Scheduler, FileSystem]) -> None:
    sched, fs, _ = scheduler_and_fs

    job_desc = JobDescription()
    job_desc.working_directory = '/home/cerulean'
    job_desc.command = 'bash'
    job_desc.arguments = ['-c', 'for i in x ; do something invalid']
    job_desc.time_reserved = 1
    job_desc.stderr_file = '/dev/null'
    job_desc.system_err_file = '/home/cerulean/test_sys_redirect.err'

    job_id = sched.submit(job_desc)
    sched.wait(job_id)

    syserr = (fs / 'home/cerulean/test_sys_redirect.err').read_text()

    retval = sched.get_exit_code(job_id)
    assert retval != 0
    assert 'syntax error' in syserr
Beispiel #6
0
def test_scheduler_wait(scheduler_and_fs: Tuple[Scheduler, FileSystem],
                        caplog: Any) -> None:
    caplog.set_level(logging.DEBUG)
    sched, fs, _ = scheduler_and_fs

    job_desc = JobDescription()
    job_desc.working_directory = '/home/cerulean'
    job_desc.command = 'ls'
    job_desc.time_reserved = 60
    job_id = sched.submit(job_desc)

    exit_code = sched.wait(job_id)
    assert exit_code == 0

    job_desc.command = '/usr/local/bin/endless-job.sh'
    job_id = sched.submit(job_desc)

    exit_code = sched.wait(job_id, 1.0)
    assert exit_code is None
    sched.cancel(job_id)