Beispiel #1
0
 def test_start_invalid_time_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(2)
     j._allocate([1])
     with pytest.raises(ValueError) as excinfo:
         j._start(1)
     assert 'current_time' in str(excinfo.value)
Beispiel #2
0
 def test_start_rejected_job_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._reject()
     with pytest.raises(RuntimeError) as excinfo:
         j._start(2)
     assert 'runnable' in str(excinfo.value)
Beispiel #3
0
 def test_runtime(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(0)
     j._terminate(10, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert j.runtime == 10
Beispiel #4
0
 def test_turnaround_time(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(10)
     j._terminate(30, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert j.turnaround_time == j.waiting_time + j.runtime
Beispiel #5
0
 def test_stretch_with_walltime(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0, 100)
     j._submit(0)
     j._allocate([1])
     j._start(10)
     j._terminate(20, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert j.stretch == j.waiting_time / j.walltime
Beispiel #6
0
 def test_terminate_not_running_job_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     with pytest.raises(RuntimeError) as excinfo:
         j._terminate(10, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert 'running' in str(excinfo.value)
Beispiel #7
0
    def test_allocate_size_less_than_requested_must_raise(self):
        j = jobs.Job("1", "w", 3, jobs.DelayJobProfile("p", 100), 0)
        j._submit(0)
        with pytest.raises(ValueError) as excinfo:
            j._allocate([3, 2])

        assert "hosts" in str(excinfo.value)
Beispiel #8
0
 def test_slowdown(self):
     j = jobs.Job("1", "w", 2, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1, 2])
     j._start(10)
     j._terminate(30, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert j.slowdown == max(1, j.turnaround_time / j.runtime)
Beispiel #9
0
 def test_allocate_valid(self):
     alloc = [1]
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate(alloc)
     assert j.is_runnable and j.state == jobs.JobState.ALLOCATED
     assert j.allocation == alloc
Beispiel #10
0
    def test_reject_allocated_job_must_raise(self):
        j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
        j._submit(0)
        j._allocate([1])
        with pytest.raises(RuntimeError) as excinfo:
            j._reject()

        assert 'queue' in str(excinfo.value)
Beispiel #11
0
 def test_allocate_staging_job_with_missing_src_mapping_must_raise(self):
     prof = jobs.DataStagingJobProfile("p", 1, "a", "b")
     alloc = [1]
     j = jobs.Job("1", "w", 1, prof, 0)
     j._submit(0)
     with pytest.raises(ValueError) as excinfo:
         j._allocate(alloc, {"b": 1})
     assert "a" in str(excinfo.value)
Beispiel #12
0
 def test_start_valid(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(2)
     assert j.is_running
     assert j.state == jobs.JobState.RUNNING
     assert j.start_time == 2
Beispiel #13
0
 def test_terminate_invalid_time_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(2)
     with pytest.raises(ValueError) as excinfo:
         j._terminate(1, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert 'current_time' in str(excinfo.value)
Beispiel #14
0
 def test_allocate_not_storage_job_with_mapping_must_raise(self):
     prof = jobs.DelayJobProfile("p", 100)
     alloc = [1]
     j = jobs.Job("1", "w", 1, prof, 0)
     j._submit(0)
     with pytest.raises(ValueError) as excinfo:
         j._allocate(alloc, {"b": 1})
     assert "mapping" in str(excinfo.value)
Beispiel #15
0
 def test_allocate_pfs_job_without_mapping_must_raise(self):
     prof = jobs.ParallelHomogeneousPFSJobProfile("p", 10, 20, "a")
     alloc = [1]
     j = jobs.Job("1", "w", 1, prof, 0)
     j._submit(0)
     with pytest.raises(ValueError) as excinfo:
         j._allocate(alloc)
     assert "mapping" in str(excinfo.value)
Beispiel #16
0
 def test_start_finished_job_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(1)
     j._terminate(2, jobs.JobState.COMPLETED_FAILED)
     with pytest.raises(RuntimeError) as excinfo:
         j._start(2)
     assert 'runnable' in str(excinfo.value)
Beispiel #17
0
 def test_terminate_walltime_reached_valid(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(0)
     j._terminate(10, jobs.JobState.COMPLETED_WALLTIME_REACHED)
     assert j.is_finished
     assert j.state == jobs.JobState.COMPLETED_WALLTIME_REACHED
     assert j.stop_time == 10
Beispiel #18
0
 def test_terminate_successfully_valid(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(0)
     j._terminate(10, jobs.JobState.COMPLETED_SUCCESSFULLY)
     assert j.is_finished
     assert j.state == jobs.JobState.COMPLETED_SUCCESSFULLY
     assert j.stop_time == 10
Beispiel #19
0
 def test_reject_finished_job_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(0)
     j._terminate(10, jobs.JobState.COMPLETED_SUCCESSFULLY)
     with pytest.raises(RuntimeError) as excinfo:
         j._reject()
     assert 'queue' in str(excinfo.value)
Beispiel #20
0
    def test_valid_instance(self):
        name, workload, res, subtime = "1", "w", 2, 1
        profile = jobs.DelayJobProfile("p", 100)

        j = jobs.Job(name, workload, res, profile, subtime, user_id=22)

        assert j.name == name and j.workload == j.workload
        assert j.res == res and j.profile == profile
        assert j.subtime == subtime and j.state == jobs.JobState.UNKNOWN
        assert j.walltime is None and j.user_id == 22 and j.allocation is None
        assert j.start_time is None and j.stop_time is None
Beispiel #21
0
    def test_terminate_with_invalid_final_state_must_raise(self):
        j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
        j._submit(0)
        j._allocate([1])
        j._start(0)

        with pytest.raises(ValueError) as excinfo:
            j._terminate(10, jobs.JobState.ALLOCATED)
        assert 'final_state' in str(excinfo.value)

        with pytest.raises(ValueError) as excinfo:
            j._terminate(10, jobs.JobState.REJECTED)
        assert 'final_state' in str(excinfo.value)
Beispiel #22
0
 def test_slowdown_when_not_finished_must_not_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(10)
     assert j.slowdown is None
Beispiel #23
0
    def test_allocate_not_submitted_job_must_raise(self):
        j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
        with pytest.raises(RuntimeError) as excinfo:
            j._allocate([3])

        assert "queue" in str(excinfo.value)
Beispiel #24
0
 def test_turnaround_time_when_not_finished_must_not_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(10)
     assert j.turnaround_time is None
Beispiel #25
0
 def test_reject_job_submitted_valid(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._reject()
     assert j.state == jobs.JobState.REJECTED and j.is_rejected
Beispiel #26
0
 def test_submit_valid(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     assert j.subtime == 0
     assert j.state == jobs.JobState.SUBMITTED and j.is_submitted
Beispiel #27
0
 def test_submit_submitted_job_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     with pytest.raises(RuntimeError) as excinfo:
         j._submit(0)
     assert 'submitted' in str(excinfo.value)
Beispiel #28
0
 def test_waiting_time_when_not_started_must_not_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     assert j.waiting_time is None
Beispiel #29
0
 def test_waiting_time(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     j._submit(0)
     j._allocate([1])
     j._start(10)
     assert j.waiting_time == 10
Beispiel #30
0
 def test_submit_invalid_time_must_raise(self):
     j = jobs.Job("1", "w", 1, jobs.DelayJobProfile("p", 100), 0)
     with pytest.raises(ValueError) as excinfo:
         j._submit(-1)
     assert 'subtime' in str(excinfo.value)