Example #1
0
 def add_log(self, job_id, name, attempt):
     if attempt > 1:
         name += '_retry%d' % (attempt - 1)
     filename = os.path.join(self.logdir, name + '.log')
     log      = Logfile(name, filename, self.mode, self.delete)
     log.started()
     self.logs[job_id].append(log)
     return log
Example #2
0
class LogfileTest(LogTest):
    CORRELATE = Logfile

    def setUp(self):
        self.tempdir   = mkdtemp()
        self.logfile   = os.path.join(self.tempdir, 'test.log')
        self.errorfile = self.logfile + '.error'
        self.log       = Logfile('testme', self.logfile)

    def tearDown(self):
        rmtree(self.tempdir)

    def testConstructor(self):
        self.assertEqual('testme', self.log.get_name())
        self.assertEqual('', str(self.log))
        self.assertFalse(os.path.exists(self.logfile))
        self.assertFalse(os.path.exists(self.errorfile))

    def testStarted(self):
        LogTest.testStarted(self)
        self.assertTrue(os.path.exists(self.logfile))
        self.assertFalse(os.path.exists(self.errorfile))

    def testAborted(self):
        LogTest.testAborted(self)
        self.assertTrue(os.path.exists(self.logfile))
        self.assertTrue(os.path.exists(self.errorfile))

    def testSucceeded(self):
        LogTest.testSucceeded(self)
        self.assertTrue(os.path.exists(self.logfile))
        self.assertFalse(os.path.exists(self.errorfile))
Example #3
0
class LogfileTest(LogTest):
    CORRELATE = Logfile

    def setUp(self):
        self.tempdir = mkdtemp()
        self.logfile = os.path.join(self.tempdir, 'test.log')
        self.errorfile = self.logfile + '.error'
        self.log = Logfile('testme', self.logfile)

    def tearDown(self):
        rmtree(self.tempdir)

    def testConstructor(self):
        self.assertEqual('testme', self.log.get_name())
        self.assertEqual('', str(self.log))
        self.failIf(os.path.exists(self.logfile))
        self.failIf(os.path.exists(self.errorfile))

    def testStarted(self):
        LogTest.testStarted(self)
        self.assert_(os.path.exists(self.logfile))
        self.failIf(os.path.exists(self.errorfile))

    def testAborted(self):
        LogTest.testAborted(self)
        self.assert_(os.path.exists(self.logfile))
        self.assert_(os.path.exists(self.errorfile))

    def testSucceeded(self):
        LogTest.testSucceeded(self)
        self.assert_(os.path.exists(self.logfile))
        self.failIf(os.path.exists(self.errorfile))
Example #4
0
 def setUp(self):
     self.tempdir   = mkdtemp()
     self.logfile   = os.path.join(self.tempdir, 'test.log')
     self.errorfile = self.logfile + '.error'
     self.log       = Logfile('testme', self.logfile)
Example #5
0
 def setUp(self):
     self.tempdir = mkdtemp()
     self.logfile = os.path.join(self.tempdir, 'test.log')
     self.errorfile = self.logfile + '.error'
     self.log = Logfile('testme', self.logfile)