Exemple #1
0
    def testJobIds(self, subprocessMock):
        """
        The jobs method should return all emitted job ids.
        """
        status = {
            'force':
            False,
            'lastStep':
            None,
            'scheduledAt':
            1481379658.5455897,
            'scriptArgs': [],
            'skip': [],
            'startAfter':
            None,
            'steps': [
                {
                    'name': 'start',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'start.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'xxx': [12, 34],
                    },
                },
                {
                    'name': 'end',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'end.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'yyy': [56, 78, 90],
                    },
                },
            ],
        }

        subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n'
                                       '12|name|RUNNING|04:32:00|cpu-3\n'
                                       '34|name|COMPLETED|04:32:00|cpu-3\n'
                                       '56|name|RUNNING|04:32:00|cpu-4\n'
                                       '78|name|COMPLETED|04:32:00|cpu-4\n'
                                       '90|name|RUNNING|04:32:00|cpu-5\n')

        sps = SlurmPipelineStatus(status)
        self.assertEqual({12, 34, 56, 78, 90}, sps.jobs())
Exemple #2
0
    def testJobIdsNoJobs(self, subprocessMock):
        """
        The jobs method should return an empty set when no jobs were started.
        """
        status = {
            'force':
            False,
            'lastStep':
            None,
            'scheduledAt':
            1481379658.5455897,
            'scriptArgs': [],
            'skip': [],
            'startAfter':
            None,
            'steps': [
                {
                    'name': 'start',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'start.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {},
                },
                {
                    'name': 'end',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'end.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {},
                },
            ],
        }

        subprocessMock.return_value = (
            'JobID|JobName|State|Elapsed|Nodelist\n')

        sps = SlurmPipelineStatus(status)
        self.assertEqual(set(), sps.jobs())