def test_get_status_bjobs_fails_query_status_using_log_job_status_is_success( self, get_lines_of_log_file_mock, run_process_mock ): lsf_status_checker = StatusChecker( 123, "dummy", wait_between_tries=0.001, max_status_checks=4 ) actual = lsf_status_checker.get_status() expected = "success" self.assertEqual(actual, expected) assert_called_n_times_with_same_args( run_process_mock, 4, "bjobs -o 'stat' -noheader 123" ) get_lines_of_log_file_mock.assert_called_once_with()
def test_get_status_bjobs_fails_exit_info_not_yet_written_job_status_is_running( self, get_lines_of_log_file_mock, run_process_mock ): lsf_status_checker = StatusChecker( 123, "dummy", wait_between_tries=0.001, max_status_checks=4 ) actual = lsf_status_checker.get_status() expected = lsf_status_checker.RUNNING self.assertEqual(actual, expected) assert_called_n_times_with_same_args( run_process_mock, 4, "bjobs -o 'stat' -noheader 123" ) get_lines_of_log_file_mock.assert_called_once_with()
def test___get_status___status_ZOMBI_and_kill_zombie___job_status_is_failed( self, run_process_mock ): jobid = 123 lsf_status_checker = StatusChecker(jobid, "dummy", kill_zombie=True) actual = lsf_status_checker.get_status() expected = lsf_status_checker.FAILED self.assertEqual(actual, expected) calls = [ call("bjobs -o 'stat' -noheader {}".format(jobid)), call("bkill -r {}".format(jobid)), ] run_process_mock.assert_has_calls(calls, any_order=False)
def test_get_status_bjobs_fails_resource_line_not_recognised_job_status_is_running( self, get_lines_of_log_file_mock, run_process_mock ): lsf_status_checker = StatusChecker( 123, "dummy", wait_between_tries=0.001, max_status_checks=4 ) actual = lsf_status_checker.get_status() expected = lsf_status_checker.FAILED assert actual == expected assert_called_n_times_with_same_args( run_process_mock, 4, "bjobs -o 'stat' -noheader 123" ) get_lines_of_log_file_mock.assert_called_once_with()