def test_timeout_ovf(self): # this should work 1 time then fail file = self._get_file() client = self._get_cluster('powerhose.tests.jobs.timeout_overflow', logfile=file) # trying a PING time.sleep(.2) self.assertTrue(client.ping() is not None) try: self.assertEqual(client.execute(self.overflow), 'xx') except Exception: with open(file) as f: raise Exception(f.read()) try: self.assertRaises(TimeoutError, client.execute, self.overflow) except Exception: with open(file) as f: raise Exception(f.read()) # calling it back with the right execution time resets the counter self.assertEqual(client.execute('.1'), 'xx') self.assertEqual(client.execute(self.overflow), 'xx') self.assertRaises(TimeoutError, client.execute, self.overflow)
def test_timeout_ovf(self): # this should work 1 time then fail file = self._get_file() client = self._get_cluster('powerhose.tests.jobs.timeout_overflow', logfile=file) # trying a PING time.sleep(.5) self.assertTrue(client.ping() is not None) try: self.assertEqual(client.execute(self.overflow), 'xx') except Exception: with open(file) as f: raise Exception(f.read()) try: self.assertRaises(TimeoutError, client.execute, self.overflow) except Exception: with open(file) as f: raise Exception(f.read()) # calling it back with the right execution time resets the counter self.assertEqual(client.execute('.1'), 'xx') self.assertEqual(client.execute(self.overflow), 'xx') self.assertRaises(TimeoutError, client.execute, self.overflow)
def test_worker_max_age(self): # a worker with a max age of 1.5 client = self._get_cluster('powerhose.tests.jobs.success', max_age=1.5, max_age_delta=0) self.assertEqual(client.execute('xx'), 'xx') cl = self.clusters[-1] # get the pid of the current worker pid = cl.watchers[1].pids.keys()[0] # wait 3 seconds time.sleep(2.) # should be different self.assertNotEqual(pid, cl.watchers[1].pids.keys()[0])
def test_success(self): client = self._get_cluster('powerhose.tests.jobs.success') self.assertEqual(client.execute('xx'), 'xx')