def testMonitorStopBeforeTimeout(self): from Products.LongRequestLogger.monitor import Monitor m = Monitor() # sleep just a little to let the other thread start s = Sleeper(0.01) s.sleep() self.assertTrue(m.isAlive()) m.stop() self.assertFalse(m.isAlive()) # unless this test is so slow that there were 2 seconds interval # between starting the monitor and stopping it, there should be no # logged messages self.assertFalse(self.loghandler.records)
def testMonitorConfigurationDisabled(self): from Products.LongRequestLogger.monitor import Monitor from Products.LongRequestLogger.dumper import DEFAULT_TIMEOUT from Products.LongRequestLogger.dumper import DEFAULT_INTERVAL os.environ['longrequestlogger_file'] = '' m = Monitor() s = Sleeper(DEFAULT_TIMEOUT + 2 * DEFAULT_INTERVAL + 0.5) # sleep a little more than timeout + intervals s.sleep() # the thread shouldn't run disabled self.assertFalse(m.isAlive()) # stopping shouldn't break nonetheless m.stop() self.assertFalse(m.isAlive()) # and there should be no records self.assertFalse(self.loghandler.records)