示例#1
0
class TestFileChecker(GangaUnitTest):
    def setUp(self):
        super(TestFileChecker, self).setUp()
        from Ganga.GPI import Job, FileChecker, Executable, Local
        from GangaTest.Framework.utils import sleep_until_completed

        self.c = FileChecker()
        self.jobslice = []
        args = ['1', '2', '12']
        for arg in args:
            j = Job(application=Executable(), backend=Local())
            # write string to tmpfile
            j.application.args = [arg]
            self.jobslice.append(j)

        for j in self.jobslice:
            j.submit()
            self.assertTrue(sleep_until_completed(j), 'Timeout on job submission: job is still not finished')
            self.assertEqual(j.status, 'completed')

    def checkFail(self, message):
        from Ganga.GPIDev.Adapters.IPostProcessor import PostProcessException
        try:
            self.c.check(self.jobslice[0])
        except PostProcessException:
            pass
        else:
            self.fail('Should have thrown exception: ' + message)

    def testFileChecker_badInput(self):

        self.c.files = ['stdout']

        self.checkFail('no searchString sepcified')

        self.c.files = []
        self.c.searchStrings = ['buttary']

        self.checkFail('no files specified')

        self.c.files = ['not_a_file']

        self.checkFail('file does not exist')

    def testFileChecker_standardCheck(self):

        self.c.files = ['stdout']
        self.c.searchStrings = ['1']
        self.c.failIfFound = False
        self.c.check(self.jobslice[0])
        self.c.check(self.jobslice[1])
        self.c.check(self.jobslice[2])

        self.c.searchStrings = ['1', '2']

        self.c.check(self.jobslice[0])
        self.c.check(self.jobslice[1])
        self.c.check(self.jobslice[2])
示例#2
0
class TestFileChecker(GangaUnitTest):
    def setUp(self):
        super(TestFileChecker, self).setUp()
        from Ganga.GPI import Job, FileChecker, Executable, Local

        self.c = FileChecker()
        self.jobslice = []
        args = ['1', '2', '12']
        for arg in args:
            j = Job(application=Executable(), backend=Local())
            # write string to tmpfile
            j.application.args = [arg]
            self.jobslice.append(j)

        for j in self.jobslice:
            j.submit()
            assert run_until_completed(
                j), 'Timeout on job submission: job is still not finished'
            self.assertEqual(j.status, 'completed')

    def checkFail(self, message):
        from Ganga.GPIDev.Adapters.IPostProcessor import PostProcessException
        try:
            self.c.check(self.jobslice[0])
        except PostProcessException:
            pass
        else:
            self.fail('Should have thrown exception: ' + message)

    def testFileChecker_badInput(self):

        self.c.files = ['stdout']

        self.checkFail('no searchString sepcified')

        self.c.files = []
        self.c.searchStrings = ['buttary']

        self.checkFail('no files specified')

        self.c.files = ['not_a_file']

        self.checkFail('file does not exist')

    def testFileChecker_standardCheck(self):

        self.c.files = ['stdout']
        self.c.searchStrings = ['1']
        self.c.failIfFound = False
        self.c.check(self.jobslice[0])
        self.c.check(self.jobslice[1])
        self.c.check(self.jobslice[2])

        self.c.searchStrings = ['1', '2']

        self.c.check(self.jobslice[0])
        self.c.check(self.jobslice[1])
        self.c.check(self.jobslice[2])
示例#3
0
    def setUp(self):
        super(TestFileChecker, self).setUp()
        from Ganga.GPI import Job, FileChecker, Executable, Local

        self.c = FileChecker()
        self.jobslice = []
        args = ['1', '2', '12']
        for arg in args:
            j = Job(application=Executable(), backend=Local())
            # write string to tmpfile
            j.application.args = [arg]
            self.jobslice.append(j)

        for j in self.jobslice:
            j.submit()
            assert run_until_completed(
                j), 'Timeout on job submission: job is still not finished'
            self.assertEqual(j.status, 'completed')
示例#4
0
    def setUp(self):
        super(TestFileChecker, self).setUp()
        from Ganga.GPI import Job, FileChecker, Executable, Local

        self.c = FileChecker()
        self.jobslice = []
        args = ['1', '2', '12']
        for arg in args:
            j = Job(application=Executable(), backend=Local())
            # write string to tmpfile
            j.application.args = [arg]
            self.jobslice.append(j)

        for j in self.jobslice:
            j.submit()
            assert run_until_completed(j), 'Timeout on job submission: job is still not finished'
            self.assertEqual(j.status, 'completed')
示例#5
0
    def test_h_PostProcessors(self):

        from Ganga.GPI import Job, RootMerger, TextMerger, CustomMerger, SmartMerger, RootFileChecker, FileChecker, \
            Notifier, CustomChecker

        j = Job()

        # -- POSTPROCESSORS APPEND START
        j.postprocessors.append(RootMerger(files = ['thesis_data.root'],ignorefailed = True,overwrite = True))
        # -- POSTPROCESSORS APPEND STOP

        # -- POSTPROCESSORS TEXTMERGER START
        TextMerger(compress = True)
        # -- POSTPROCESSORS TEXTMERGER STOP

        # -- POSTPROCESSORS ROOTMERGER START
        RootMerger(args = '-T')
        # -- POSTPROCESSORS ROOTMERGER STOP

        # -- POSTPROCESSORS CUSTOMMERGER START
        CustomMerger().module = '~/mymerger.py'
        # -- POSTPROCESSORS CUSTOMMERGER STOP

        # -- POSTPROCESSORS SMARTMERGER START
        SmartMerger(files = ['thesis_data.root','stdout'],overwrite = True)
        # -- POSTPROCESSORS SMARTMERGER STOP

        # -- POSTPROCESSORS SMARTMERGERAPPEND START
        j.postprocessors.append(SmartMerger(files = ['thesis_data.root','stdout'],overwrite = True))
        # -- POSTPROCESSORS SMARTMERGERAPPEND STOP

        # -- POSTPROCESSORS SMARTMERGERAPPEND2 START
        j.postprocessors.append(TextMerger(files = ['stdout'],overwrite = True))
        j.postprocessors.append(RootMerger(files = ['thesis_data.root'],overwrite = False))
        # -- POSTPROCESSORS SMARTMERGERAPPEND2 STOP

        # -- POSTPROCESSORS FILECHECKER START
        fc = FileChecker(files = ['stdout'], searchStrings = ['Segmentation'])
        # -- POSTPROCESSORS FILECHECKER STOP

        # -- POSTPROCESSORS FILECHECKERMUSTEXIST START
        fc.filesMustExist = True
        # -- POSTPROCESSORS FILECHECKERMUSTEXIST STOP

        # -- POSTPROCESSORS FILECHECKEROPTS START
        fc.searchStrings = ['SUCCESS']
        fc.failIfFound = False
        # -- POSTPROCESSORS FILECHECKEROPTS STOP

        # -- POSTPROCESSORS FILECHECKEROPTS START
        rfc = RootFileChecker(files = ["*.root"])
        rfc.files = ["*.root"]
        j.postprocessors.append(rfc)
        # -- POSTPROCESSORS FILECHECKEROPTS STOP

        # -- POSTPROCESSORS CUSTOMCHECKER START
        cc = CustomChecker(module = '~/mychecker.py')
        # -- POSTPROCESSORS CUSTOMCHECKER STOP

        # -- POSTPROCESSORS NOTIFIER START
        n = Notifier(address = 'myaddress.cern.ch')
        # -- POSTPROCESSORS NOTIFIER STOP

        # -- POSTPROCESSORS NOTIFIEROPTS START
        n.verbose = True
        # -- POSTPROCESSORS NOTIFIEROPTS STOP

        # -- POSTPROCESSORS MULTIPLE START
        tm = TextMerger(files=['stdout'], compress=True)
        rm = RootMerger(files=['thesis_data.root'], args='-f6')
        fc = FileChecker(files=['stdout'], searchStrings=['Segmentation'])
        cc = CustomChecker(module='~/mychecker.py')
        n = Notifier(address='myadress.cern.ch')

        j.postprocessors = [tm, rm, fc, cc, n]
        # -- POSTPROCESSORS MULTIPLE STOP

        # -- POSTPROCESSORS MULTIPLE2 START
        j.postprocessors.append(fc)
        j.postprocessors.append(tm)
        j.postprocessors.append(rm)
        j.postprocessors.append(cc)
        j.postprocessors.append(n)
        # -- POSTPROCESSORS MULTIPLE2 STOP

        j.postprocessors.remove(FileChecker())
示例#6
0
    def test_h_PostProcessors(self):

        from Ganga.GPI import Job, RootMerger, TextMerger, CustomMerger, SmartMerger, RootFileChecker, FileChecker, \
            Notifier, CustomChecker

        j = Job()

        # -- POSTPROCESSORS APPEND START
        j.postprocessors.append(
            RootMerger(files=['thesis_data.root'],
                       ignorefailed=True,
                       overwrite=True))
        # -- POSTPROCESSORS APPEND STOP

        # -- POSTPROCESSORS TEXTMERGER START
        TextMerger(compress=True)
        # -- POSTPROCESSORS TEXTMERGER STOP

        # -- POSTPROCESSORS ROOTMERGER START
        RootMerger(args='-T')
        # -- POSTPROCESSORS ROOTMERGER STOP

        # -- POSTPROCESSORS CUSTOMMERGER START
        CustomMerger().module = '~/mymerger.py'
        # -- POSTPROCESSORS CUSTOMMERGER STOP

        # -- POSTPROCESSORS SMARTMERGER START
        SmartMerger(files=['thesis_data.root', 'stdout'], overwrite=True)
        # -- POSTPROCESSORS SMARTMERGER STOP

        # -- POSTPROCESSORS SMARTMERGERAPPEND START
        j.postprocessors.append(
            SmartMerger(files=['thesis_data.root', 'stdout'], overwrite=True))
        # -- POSTPROCESSORS SMARTMERGERAPPEND STOP

        # -- POSTPROCESSORS SMARTMERGERAPPEND2 START
        j.postprocessors.append(TextMerger(files=['stdout'], overwrite=True))
        j.postprocessors.append(
            RootMerger(files=['thesis_data.root'], overwrite=False))
        # -- POSTPROCESSORS SMARTMERGERAPPEND2 STOP

        # -- POSTPROCESSORS FILECHECKER START
        fc = FileChecker(files=['stdout'], searchStrings=['Segmentation'])
        # -- POSTPROCESSORS FILECHECKER STOP

        # -- POSTPROCESSORS FILECHECKERMUSTEXIST START
        fc.filesMustExist = True
        # -- POSTPROCESSORS FILECHECKERMUSTEXIST STOP

        # -- POSTPROCESSORS FILECHECKEROPTS START
        fc.searchStrings = ['SUCCESS']
        fc.failIfFound = False
        # -- POSTPROCESSORS FILECHECKEROPTS STOP

        # -- POSTPROCESSORS FILECHECKEROPTS START
        rfc = RootFileChecker(files=["*.root"])
        rfc.files = ["*.root"]
        j.postprocessors.append(rfc)
        # -- POSTPROCESSORS FILECHECKEROPTS STOP

        # -- POSTPROCESSORS CUSTOMCHECKER START
        cc = CustomChecker(module='~/mychecker.py')
        # -- POSTPROCESSORS CUSTOMCHECKER STOP

        # -- POSTPROCESSORS NOTIFIER START
        n = Notifier(address='myaddress.cern.ch')
        # -- POSTPROCESSORS NOTIFIER STOP

        # -- POSTPROCESSORS NOTIFIEROPTS START
        n.verbose = True
        # -- POSTPROCESSORS NOTIFIEROPTS STOP

        # -- POSTPROCESSORS MULTIPLE START
        tm = TextMerger(files=['stdout'], compress=True)
        rm = RootMerger(files=['thesis_data.root'], args='-f6')
        fc = FileChecker(files=['stdout'], searchStrings=['Segmentation'])
        cc = CustomChecker(module='~/mychecker.py')
        n = Notifier(address='myadress.cern.ch')

        j.postprocessors = [tm, rm, fc, cc, n]
        # -- POSTPROCESSORS MULTIPLE STOP

        # -- POSTPROCESSORS MULTIPLE2 START
        j.postprocessors.append(fc)
        j.postprocessors.append(tm)
        j.postprocessors.append(rm)
        j.postprocessors.append(cc)
        j.postprocessors.append(n)
        # -- POSTPROCESSORS MULTIPLE2 STOP

        j.postprocessors.remove(FileChecker())