Пример #1
0
    def test_task_fail(self, execution_manager):
        # do not retry tasks on failure
        execution_manager.max_task_retries = 1

        job_exec = execution_manager.submit_job(
            Job(ExecutionType.MOCK, {"num_tasks": "2"}))

        # verify the job is in running state
        assert wait_until(
            _verify_state,
            10,
            0.5,
            execution_manager.get_job(job_exec.jid),
            ExecutionState.DISPATCHED,
        )

        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert wait_until(_verify_state, 10, 0.5, task,
                              ExecutionState.DISPATCHED)
            execution_manager.task_start(task.tid)

        assert execution_manager.get_job(
            job_exec.jid).state == ExecutionState.RUNNING
        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert task.state == ExecutionState.RUNNING

        execution_manager.task_failure(
            execution_manager.get_job(job_exec.jid).get_tasks()[0].tid)
        for task in execution_manager.get_job(job_exec.jid).get_tasks()[1:]:
            execution_manager.task_finish(task.tid)

        assert execution_manager.get_job(
            job_exec.jid).state == ExecutionState.FAILED
        return job_exec
Пример #2
0
    def test_task_finish(self, execution_manager):
        job_exec = execution_manager.submit_job(
            Job(ExecutionType.MOCK, {"num_tasks": "2"}))

        # verify the job is in running state
        assert wait_until(
            _verify_state,
            10,
            0.5,
            execution_manager.get_job(job_exec.jid),
            ExecutionState.DISPATCHED,
        )
        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert wait_until(_verify_state, 10, 0.5, task,
                              ExecutionState.DISPATCHED)
            execution_manager.task_start(task.tid)

        assert execution_manager.get_job(
            job_exec.jid).state == ExecutionState.RUNNING

        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert task.state == ExecutionState.RUNNING
            execution_manager.task_finish(task.tid)

        assert execution_manager.get_job(
            job_exec.jid).state == ExecutionState.FINISHED

        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert task.state == ExecutionState.FINISHED
Пример #3
0
 def test_submit_job(self, user_client):
     jid = user_client.submit_job(
         Job(ExecutionType.MOCK, {"num_tasks": "10"}))
     # wait for the job to finish
     assert wait_until(
         lambda i: user_client.job_status(i).state == "FINISHED", 20, 0.5,
         jid)
Пример #4
0
 def test_submit_job(self, master):
     master.register_worker(Worker("worker 1", None, None))
     job = master.submit_job(Job(ExecutionType.MOCK, {"num_tasks": "2"}))
     assert wait_until(
         lambda i: master.get_job(i).state == ExecutionState.FINISHED,
         20,
         0.5,
         job.jid,
     )
Пример #5
0
    def test_task_lookup(self, execution_manager):
        job_exec = execution_manager.submit_job(
            Job(ExecutionType.MOCK, {"num_tasks": "2"}))

        # verify the job is in running state
        assert wait_until(
            _verify_state,
            10,
            0.5,
            execution_manager.get_job(job_exec.jid),
            ExecutionState.DISPATCHED,
        )
        for task in execution_manager.get_job(job_exec.jid).get_tasks():
            assert wait_until(_verify_state, 10, 0.5, task,
                              ExecutionState.DISPATCHED)
            execution_manager.task_start(task.tid)

        assert (len(
            execution_manager.get_tasks(jid=job_exec.jid,
                                        states=[ExecutionState.RUNNING])) == 2)
Пример #6
0
def mock_job_exec(num_tasks):
    job = job_factory.create_job(
        Job(ExecutionType.MOCK, {"num_tasks": str(num_tasks)}))
    job.setup()
    return job
Пример #7
0
 def test_list_jobs(self, master):
     master.submit_job(Job(ExecutionType.MOCK, {"num_tasks": "2"}))
     master.register_worker(Worker("worker 1", None, None))
     assert len(master.list_jobs()) == 1
Пример #8
0
 def test_submit_bad_job_params(self, master):
     master.register_worker(Worker("worker 1", None, None))
     with pytest.raises(JobInitializationException):
         master.submit_job(
             Job(ExecutionType.MOCK, {"num_tasks": "not_an_int"}))
Пример #9
0
 def test_job_submit(self, execution_manager):
     execution_manager.submit_job(
         Job(ExecutionType.MOCK, {"num_tasks": "2"}))
     assert True
Пример #10
0
 def test_submit_job_failure(self, user_client):
     with pytest.raises(JobInitializationException):
         user_client.submit_job(
             Job(ExecutionType.MOCK, {"num_tasks": "not_an_int"}))