def test_parse_failed_squeue_output(self): """ Test that _parse_joblist_output reacts as expected to failures. """ scheduler = SlurmScheduler() # non-zero return value should raise with pytest.raises(SchedulerError, match='squeue returned exit code 1'): scheduler._parse_joblist_output(1, TEXT_SQUEUE_TO_TEST, '') # pylint: disable=protected-access # non-empty stderr should be logged with self.assertLogs(scheduler.logger, logging.WARNING): scheduler._parse_joblist_output(0, TEXT_SQUEUE_TO_TEST, 'error message') # pylint: disable=protected-access
def test_parse_common_joblist_output(self): """ Test whether _parse_joblist_output can parse the squeue output """ scheduler = SlurmScheduler() retval = 0 stdout = TEXT_SQUEUE_TO_TEST stderr = '' job_list = scheduler._parse_joblist_output(retval, stdout, stderr) # pylint: disable=protected-access job_dict = {j.job_id: j for j in job_list} # The parameters are hard coded in the text to parse job_parsed = len(job_list) assert job_parsed == JOBS_ON_CLUSTER job_running_parsed = len([j for j in job_list if j.job_state \ and j.job_state == JobState.RUNNING]) assert len(JOBS_RUNNING) == job_running_parsed job_held_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED_HELD]) assert JOBS_HELD == job_held_parsed job_queued_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED]) assert JOBS_QUEUED == job_queued_parsed parsed_running_users = [j.job_owner for j in job_list if j.job_state and j.job_state == JobState.RUNNING] assert set(USERS_RUNNING) == set(parsed_running_users) parsed_running_jobs = [j.job_id for j in job_list if j.job_state and j.job_state == JobState.RUNNING] assert set(JOBS_RUNNING) == set(parsed_running_jobs) assert job_dict['863553'].requested_wallclock_time_seconds, 30 * 60 # pylint: disable=invalid-name assert job_dict['863553'].wallclock_time_seconds, 29 * 60 + 29 assert job_dict['863553'].dispatch_time, datetime.datetime(2013, 5, 23, 11, 44, 11) assert job_dict['863553'].submission_time, datetime.datetime(2013, 5, 23, 10, 42, 11) assert job_dict['863100'].annotation == 'Resources' assert job_dict['863100'].num_machines == 32 assert job_dict['863100'].num_mpiprocs == 1024 assert job_dict['863100'].queue_name == 'normal' assert job_dict['861352'].title == 'Pressure_PBEsol_0' assert job_dict['863554'].requested_wallclock_time_seconds is None # pylint: disable=invalid-name
def test_parse_common_joblist_output(self): """ Test whether _parse_joblist can parse the qstat -f output """ scheduler = SlurmScheduler() retval = 0 stdout = TEXT_SQUEUE_TO_TEST stderr = '' job_list = scheduler._parse_joblist_output(retval, stdout, stderr) # pylint: disable=protected-access job_dict = {j.job_id: j for j in job_list} # The parameters are hard coded in the text to parse job_parsed = len(job_list) self.assertEqual(job_parsed, JOBS_ON_CLUSTER) job_running_parsed = len([j for j in job_list if j.job_state \ and j.job_state == JobState.RUNNING]) self.assertEqual(len(JOBS_RUNNING), job_running_parsed) job_held_parsed = len([ j for j in job_list if j.job_state and j.job_state == JobState.QUEUED_HELD ]) self.assertEqual(JOBS_HELD, job_held_parsed) job_queued_parsed = len([ j for j in job_list if j.job_state and j.job_state == JobState.QUEUED ]) self.assertEqual(JOBS_QUEUED, job_queued_parsed) parsed_running_users = [ j.job_owner for j in job_list if j.job_state and j.job_state == JobState.RUNNING ] self.assertEqual(set(USERS_RUNNING), set(parsed_running_users)) parsed_running_jobs = [ j.job_id for j in job_list if j.job_state and j.job_state == JobState.RUNNING ] self.assertEqual(set(JOBS_RUNNING), set(parsed_running_jobs)) self.assertEqual(job_dict['863553'].requested_wallclock_time_seconds, 30 * 60) # pylint: disable=invalid-name self.assertEqual(job_dict['863553'].wallclock_time_seconds, 29 * 60 + 29) self.assertEqual(job_dict['863553'].dispatch_time, datetime.datetime(2013, 5, 23, 11, 44, 11)) self.assertEqual(job_dict['863553'].submission_time, datetime.datetime(2013, 5, 23, 10, 42, 11)) self.assertEqual(job_dict['863100'].annotation, 'Resources') self.assertEqual(job_dict['863100'].num_machines, 32) self.assertEqual(job_dict['863100'].num_mpiprocs, 1024) self.assertEqual(job_dict['863100'].queue_name, 'normal') self.assertEqual(job_dict['861352'].title, 'Pressure_PBEsol_0') self.assertEqual(job_dict['863554'].requested_wallclock_time_seconds, None) # pylint: disable=invalid-name