def test_parse_job_qtime_ok(self):

        pattern_args = {
            'jserial': '01',
            'jname': 'cream_921657923',
            'jstate': 'Q',
            'qtime': 'Wed Aug 21 11:37:25 2013',
            'queue': 'cert',
            'pair1': 'dummy1 = None'
        }
        tmpfile = self.workspace.createFile(self.jobPattern % pattern_args)

        pattern_args = {
            'jserial': '02',
            'jname': 'cream_921657924',
            'jstate': 'Q',
            'qtime': 'Wed Aug 21 11:37:30 2013',
            'queue': 'cert',
            'pair1': 'dummy1 = None'
        }
        self.workspace.appendToFile(self.jobPattern % pattern_args, tmpfile)

        outList = list()
        QStatHandler.parse(outList, None, tmpfile)
        qtimeCount = 0
        for jtable in outList:
            if jtable['qtime'] == 1377074245 or jtable['qtime'] == 1377074250:
                qtimeCount += 1
        self.assertTrue(qtimeCount == 2)
    def test_parse_job_stime_ok(self):

        pattern_args = {
            'jserial': '01',
            'jname': 'cream_921657923',
            'jstate': 'R',
            'qtime': 'Wed Aug 21 11:37:25 2013',
            'queue': 'cert',
            'pair1': 'start_time = Wed Aug 21 11:37:26 2013'
        }
        tmpfile = self.workspace.createFile(self.jobPattern % pattern_args)

        pattern_args = {
            'jserial': '02',
            'jname': 'cream_921657924',
            'jstate': 'Q',
            'qtime': 'Wed Aug 21 11:37:30 2013',
            'queue': 'cert',
            'pair1': 'dummy1 = None'
        }
        self.workspace.appendToFile(self.jobPattern % pattern_args, tmpfile)

        outList = list()
        QStatHandler.parse(outList, None, tmpfile)
        stimeCount = 0
        for jtable in outList:
            try:
                if jtable['start'] == 1377074246 and jtable[
                        'startAnchor'] == 'start_time':
                    stimeCount += 1
            except:
                pass
        self.assertTrue(stimeCount == 1)
 def test_parse_job_stime_ok(self):
 
     pattern_args = {'jserial' : '01', 
                     'jname' : 'cream_921657923', 
                     'jstate' : 'R',
                     'qtime' : 'Wed Aug 21 11:37:25 2013',
                     'queue' : 'cert',
                     'pair1' : 'start_time = Wed Aug 21 11:37:26 2013'}
     tmpfile = self.workspace.createFile(self.jobPattern % pattern_args)
     
     pattern_args = {'jserial' : '02', 
                     'jname' : 'cream_921657924', 
                     'jstate' : 'Q',
                     'qtime' : 'Wed Aug 21 11:37:30 2013',
                     'queue' : 'cert',
                     'pair1' : 'dummy1 = None'}
     self.workspace.appendToFile(self.jobPattern % pattern_args, tmpfile)
     
     outList = list()
     QStatHandler.parse(outList, None, tmpfile)
     stimeCount = 0
     for jtable in outList:
         try:
             if jtable['start'] == 1377074246 and jtable['startAnchor'] == 'start_time':
                 stimeCount += 1
         except:
             pass
     self.assertTrue(stimeCount == 1) 
 def test_parse_job_qtime_ok(self):
 
     pattern_args = {'jserial' : '01', 
                     'jname' : 'cream_921657923', 
                     'jstate' : 'Q',
                     'qtime' : 'Wed Aug 21 11:37:25 2013',
                     'queue' : 'cert',
                     'pair1' : 'dummy1 = None'}
     tmpfile = self.workspace.createFile(self.jobPattern % pattern_args)
     
     pattern_args = {'jserial' : '02', 
                     'jname' : 'cream_921657924', 
                     'jstate' : 'Q',
                     'qtime' : 'Wed Aug 21 11:37:30 2013',
                     'queue' : 'cert',
                     'pair1' : 'dummy1 = None'}
     self.workspace.appendToFile(self.jobPattern % pattern_args, tmpfile)
     
     outList = list()
     QStatHandler.parse(outList, None, tmpfile)
     qtimeCount = 0
     for jtable in outList:
         if jtable['qtime'] == 1377074245 or jtable['qtime'] == 1377074250:
             qtimeCount += 1
     self.assertTrue(qtimeCount == 2) 
 def test_parse_queue_ok(self):
     
     pattern_args = {'queue' : 'cert', 'maxcpu' : '24:00:00', 'maxwt' : '36:00:00'}
     tmpfile = self.workspace.createFile(self.queuePattern % pattern_args)
     
     container = QStatHandler.parseQueueInfo('cert', None, tmpfile)
     result = container.maxCPUtime == 86400
     result = result and container.maxWallTime == 129600
     self.assertTrue(result)
    def test_parse_queue_ok(self):

        pattern_args = {
            'queue': 'cert',
            'maxcpu': '24:00:00',
            'maxwt': '36:00:00'
        }
        tmpfile = self.workspace.createFile(self.queuePattern % pattern_args)

        container = QStatHandler.parseQueueInfo('cert', None, tmpfile)
        result = container.maxCPUtime == 86400
        result = result and container.maxWallTime == 129600
        self.assertTrue(result)
    def test_lrmsver_missing(self):
        pattern = self.srvPattern.replace('pbs_version', 'no_version')

        tmpfile = self.workspace.createFile(pattern)
        self.assertTrue(QStatHandler.parseLRMSVersion(None, tmpfile) == None)
    def test_lrmsver_ok(self):
        pattern = self.srvPattern % {'lrmsver': '2.5.7'}

        tmpfile = self.workspace.createFile(pattern)
        self.assertTrue(
            QStatHandler.parseLRMSVersion(None, tmpfile) == '2.5.7')
 def test_lrmsver_missing(self):
     pattern = self.srvPattern.replace('pbs_version', 'no_version')
     
     tmpfile = self.workspace.createFile(pattern)
     self.assertTrue(QStatHandler.parseLRMSVersion(None, tmpfile) == None)
 def test_lrmsver_ok(self):
     pattern = self.srvPattern % {'lrmsver' : '2.5.7'}
     
     tmpfile = self.workspace.createFile(pattern)
     self.assertTrue(QStatHandler.parseLRMSVersion(None, tmpfile) == '2.5.7')