Exemplo n.º 1
0
    def test_parse_with_unexpected_newlines(self):
        """
        Test whether _parse_joblist can parse the qstat -f output
        also when there are unexpected newlines
        """
        # pylint: disable=too-many-locals
        scheduler = PbsproScheduler()

        retval = 0
        stdout = text_qstat_f_to_test_with_unexpected_newlines
        stderr = ''

        job_list = scheduler._parse_joblist_output(retval, stdout, stderr)

        # The parameters are hard coded in the text to parse
        job_on_cluster = 10
        job_parsed = len(job_list)
        self.assertEqual(job_parsed, job_on_cluster)

        job_running = 2
        job_running_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.RUNNING])
        self.assertEqual(job_running, job_running_parsed)

        job_held = 1
        job_held_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED_HELD])
        self.assertEqual(job_held, job_held_parsed)

        job_queued = 5
        job_queued_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED])
        self.assertEqual(job_queued, job_queued_parsed)

        running_users = ['somebody', 'user_556491']
        parsed_running_users = [j.job_owner for j in job_list if j.job_state and j.job_state == JobState.RUNNING]
        self.assertEqual(set(running_users), set(parsed_running_users))

        running_jobs = ['555716', '556491']
        parsed_running_jobs = [j.job_id for j in job_list if j.job_state and j.job_state == JobState.RUNNING]
        self.assertEqual(set(running_jobs), set(parsed_running_jobs))

        for j in job_list:
            if j.allocated_machines:
                num_machines = 0
                num_cpus = 0
                for n in j.allocated_machines:
                    num_machines += 1
                    num_cpus += n.num_cpus

                self.assertTrue(j.num_machines == num_machines)
                self.assertTrue(j.num_cpus == num_cpus)
Exemplo n.º 2
0
    def test_parse_common_joblist_output(self):
        """
        Test whether _parse_joblist can parse the qstat -f output
        """
        # pylint: disable=too-many-locals
        scheduler = PbsproScheduler()

        retval = 0
        stdout = text_qstat_f_to_test
        stderr = ''

        job_list = scheduler._parse_joblist_output(retval, stdout, stderr)

        # The parameters are hard coded in the text to parse
        job_on_cluster = 6
        job_parsed = len(job_list)
        self.assertEqual(job_parsed, job_on_cluster)

        job_running = 2
        job_running_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.RUNNING])
        self.assertEqual(job_running, job_running_parsed)

        job_held = 2
        job_held_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED_HELD])
        self.assertEqual(job_held, job_held_parsed)

        job_queued = 2
        job_queued_parsed = len([j for j in job_list if j.job_state and j.job_state == JobState.QUEUED])
        self.assertEqual(job_queued, job_queued_parsed)

        running_users = ['user02', 'user3']
        parsed_running_users = [j.job_owner for j in job_list if j.job_state and j.job_state == JobState.RUNNING]
        self.assertEqual(set(running_users), set(parsed_running_users))

        running_jobs = ['69301.mycluster', '74164.mycluster']
        parsed_running_jobs = [j.job_id for j in job_list if j.job_state and j.job_state == JobState.RUNNING]
        self.assertEqual(set(running_jobs), set(parsed_running_jobs))

        for j in job_list:
            if j.allocated_machines:
                num_machines = 0
                num_cpus = 0
                for n in j.allocated_machines:
                    num_machines += 1
                    num_cpus += n.num_cpus

                self.assertTrue(j.num_machines == num_machines)
                self.assertTrue(j.num_cpus == num_cpus)