Example #1
0
    def queued_jobs_status(self):
        """
        Get the status of jobs in the job queue
        :return: the status
        """
        try:
            output = subprocess.check_output([config['run_bjobs_command']], stderr=subprocess.STDOUT)
            bjobs_parser = BjobsParser(output.splitlines())
            return bjobs_parser.parse()

        except subprocess.CalledProcessError, ex:
            log.exception("When getting running jobs.")
            raise ServiceException('When getting running jobs, failed with non-zero error code. "%s"' % ex.output)
Example #2
0
class TestJulesLogFileParser(TestController):

    def setUp(self):
        self.lines = []
        self.parser = BjobsParser(self.lines)


    def test_GIVEN_no_output_WHEN_parse_THEN_return_empty_list(self):

        result = self.parser.parse()

        assert_that(len(result), is_(0), "No jobs in dictionary")

    def test_GIVEN_no_jobs_output_WHEN_parse_THEN_return_empty_list(self):
        self.lines.append('No unfinished job found')

        result = self.parser.parse()

        assert_that(len(result), is_(0), "No jobs in dictionary")

    def test_GIVEN_one_running_job_in_list_WHEN_parse_THEN_return_that_job_as_running(self):
        self.lines.append(header)
        self.lines.append('402753  jholt01 RUN  lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')

        result = self.parser.parse()

        assert_that(len(result), is_(1), "Jobs in dictionary")
        assert_that(result[402753], is_(constants.MODEL_RUN_STATUS_RUNNING), "job status")

    def test_GIVEN_one_pending_job_in_list_WHEN_parse_THEN_return_that_job_as_pending(self):
        self.lines.append(header)
        self.lines.append('402753  jholt01 PEND lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')

        result = self.parser.parse()

        assert_that(len(result), is_(1), "Jobs in dictionary")
        assert_that(result[402753], is_(constants.MODEL_RUN_STATUS_PENDING), "job status")

    def test_GIVEN_one_unknown_job_in_list_WHEN_parse_THEN_return_that_job_as_pending(self):
        self.lines.append(header)
        self.lines.append('402753  jholt01 BLAH lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')

        result = self.parser.parse()

        assert_that(len(result), is_(1), "Jobs in dictionary")
        assert_that(result[402753], is_(constants.MODEL_RUN_STATUS_UNKNOWN), "job status")

    def test_GIVEN_multiple_jobs_in_list_WHEN_parse_THEN_return_that_jobs(self):
        self.lines.append(header)
        self.lines.append('402753  jholt01 BLAH lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')
        self.lines.append('402754  jholt01 PEND lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')
        self.lines.append('                                jules-bd1-d 16*host042.j *> out.lo Jul  2 12:13')
        self.lines.append('402755  jholt01 RUN  lotus      jules-bd1-d 8*host041.j *> out.log Jul  2 12:13')

        result = self.parser.parse()

        assert_that(len(result), is_(3), "Jobs in dictionary")
        assert_that(result[402753], is_(constants.MODEL_RUN_STATUS_UNKNOWN), "job status")
        assert_that(result[402754], is_(constants.MODEL_RUN_STATUS_PENDING), "job status")
        assert_that(result[402755], is_(constants.MODEL_RUN_STATUS_RUNNING), "job status")
Example #3
0
 def setUp(self):
     self.lines = []
     self.parser = BjobsParser(self.lines)