Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsarm committed Mar 9, 2020
1 parent 1f9c8d1 commit e77a66a
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions unittests/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ def test_guess_num_tasks(self):
with pytest.raises(NotImplementedError):
self.testjob.guess_num_tasks()

# Monkey patch `self._update_state` to simulate that the job is
# pending on the queue for enough time so it can be canceled due
# to exceeding the maximum pending time
@fixtures.switch_to_user_runtime
def test_submit_max_pending_time(self):
self.setup_user()
self.parallel_cmd = 'sleep 30'
self.prepare()
self.testjob.scheduler._update_state = self._update_state
self.testjob._max_pending_time = timedelta(seconds=5)
self.testjob.submit()
with pytest.raises(JobError):
self.testjob.wait()


class TestLocalJob(_TestJob, unittest.TestCase):
def assertProcessDied(self, pid):
Expand Down Expand Up @@ -321,6 +335,10 @@ def test_guess_num_tasks(self):
self.testjob.wait()
assert self.testjob.num_tasks == 1

def test_submit_max_pending_time(self):
pytest.skip('the maximum pending time has no effect on the '
'local scheduler')


class TestSlurmJob(_TestJob, unittest.TestCase):
@property
Expand Down Expand Up @@ -439,20 +457,6 @@ def test_submit_job_array(self):
assert all([re.search('Task id: 0', output),
re.search('Task id: 1', output)])

# Monkey patch `self._update_state` to simulate that the job is
# pending on the queue for enough time so it can be canceled due
# to exceeding the maximum pending time
@fixtures.switch_to_user_runtime
def test_submit_max_pending_time(self):
self.setup_user()
self.parallel_cmd = 'sleep 30'
self.prepare()
self.testjob.scheduler._update_state = self._update_state
self.testjob._max_pending_time = timedelta(seconds=5)
self.testjob.submit()
with pytest.raises(JobError):
self.testjob.wait()


class TestSqueueJob(TestSlurmJob):
@property
Expand Down Expand Up @@ -546,9 +550,12 @@ def test_prepare_no_cpus(self):
assert self.expected_directives == found_directives

def test_submit_timelimit(self):
# Skip this test for PBS, since we the minimum time limit is 1min
# Skip this test for PBS, since the minimum time limit is 1min
pytest.skip("PBS minimum time limit is 60s")

def test_submit_max_pending_time(self):
pytest.skip('not implemented for the pbs scheduler')


class TestTorqueJob(TestPbsJob):
@property
Expand Down Expand Up @@ -581,20 +588,6 @@ def test_submit_timelimit(self):
def _update_state(self, job):
job.state = 'QUEUED'

# Monkey patch `self._update_state` to simulate that the job is
# pending on the queue for enough time so it can be canceled due
# to exceeding the maximum pending time
@fixtures.switch_to_user_runtime
def test_submit_max_pending_time(self):
self.setup_user()
self.parallel_cmd = 'sleep 30'
self.prepare()
self.testjob.scheduler._update_state = self._update_state
self.testjob._max_pending_time = timedelta(seconds=5)
self.testjob.submit()
with pytest.raises(JobError):
self.testjob.wait()


class TestSlurmFlexibleNodeAllocation(unittest.TestCase):
def create_dummy_nodes(obj):
Expand Down

0 comments on commit e77a66a

Please sign in to comment.