Beispiel #1
0
 def test_retry_timeout(self):
     """Test retry behaviour when timeout"""
     action = Action("start", command="/bin/sleep 0.5", timeout=0.1)
     action.delay = 0.1
     action.maxretry = 2
     service = Service("retry")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.tries, 3)
     self.assertEqual(action.status, TIMEOUT)
     self.assertTrue(0.6 < action.duration < 0.8, "%.3f is not between 0.6 and 0.8" % action.duration)
Beispiel #2
0
 def test_retry_error(self):
     """Test retry behaviour when errors"""
     action = Action("start", command="/bin/false")
     action.delay = 0.1
     action.maxretry = 3
     service = Service("retry")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.tries, 4)
     self.assertEqual(action.status, ERROR)
     self.assertTrue(0.3 < action.duration < 0.5, "%.3f is not between 0.3 and 0.5" % action.duration)
Beispiel #3
0
 def test_retry_timeout(self):
     """Test retry behaviour when timeout"""
     action = Action('start', command='/bin/sleep 0.5', timeout=0.1)
     action.delay = 0.1
     action.maxretry = 2
     service = Service('retry')
     service.add_action(action)
     service.run('start')
     self.assertEqual(action.tries, 3)
     self.assertEqual(action.status, TIMEOUT)
     self.assertTrue(0.59 <= action.duration <= 0.8,
                     "%.3f is not between 0.59 and 0.8" % action.duration)
Beispiel #4
0
 def test_retry_timeout(self):
     """Test retry behaviour when timeout"""
     action = Action('start', command='/bin/sleep 0.5', timeout=0.1)
     action.delay = 0.1
     action.maxretry = 2
     service = Service('retry')
     service.add_action(action)
     service.run('start')
     self.assertEqual(action.tries, 3)
     self.assertEqual(action.status, TIMEOUT)
     self.assertTrue(0.59 <= action.duration <= 0.8,
                     "%.3f is not between 0.59 and 0.8" % action.duration)
Beispiel #5
0
 def test_retry_error(self):
     """Test retry behaviour when errors"""
     action = Action('start', command='/bin/false')
     action.delay = 0.1
     action.maxretry = 3
     service = Service('retry')
     service.add_action(action)
     service.run('start')
     self.assertEqual(action.tries, 4)
     self.assertEqual(action.status, ERROR)
     self.assertTrue(0.3 < action.duration < 0.5,
                     "%.3f is not between 0.3 and 0.5" % action.duration)
Beispiel #6
0
 def test_reset_action(self):
     """Test resest values of an action"""
     action = Action(name="start", target="fortoy5", command="/bin/true", timeout=10, delay=5)
     action.maxretry = 5
     action.tries = 4
     action.worker = "test"
     action.start_time = "00:20:30"
     action.stop_time = "00:20:30"
     action.reset()
     self.assertEqual(action.tries, 0)
     self.assertEqual(action.worker, None)
     self.assertEqual(action.start_time, None)
     self.assertEqual(action.stop_time, None)
     self.assertEqual(action.status, NO_STATUS)
Beispiel #7
0
 def test_reset_action(self):
     '''Test resest values of an action'''
     action = Action(name='start', target='fortoy5', command='/bin/true',
                     timeout=10, delay=5)
     action.maxretry = 5
     action.tries = 4
     action.worker = 'test'
     action.start_time = 1444253681.36017
     action.stop_time = 1444253681.36017
     action.reset()
     self.assertEqual(action.tries, 0)
     self.assertEqual(action.worker, None)
     self.assertEqual(action.start_time, None)
     self.assertEqual(action.stop_time, None)
     self.assertEqual(action.status, NO_STATUS)
Beispiel #8
0
 def test_reset_service_group(self):
     '''Test the ability to reset values of a service group'''
     group = ServiceGroup('GROUP')
     ser1 = Service('I1')
     action = Action(name='start', delay=3)
     action.maxretry = 5
     action.tries = 3
     action.status = DONE
     ser1.add_action(action)
     ser1.status = ERROR
     group.add_inter_dep(target=ser1)
     group.status = DEP_ERROR
     group.reset()
     self.assertEqual(group.status, NO_STATUS)
     self.assertEqual(ser1.status, NO_STATUS)
     self.assertEqual(action.status, NO_STATUS)
     self.assertEqual(action.tries, 0)
Beispiel #9
0
 def test_reset_service_group(self):
     '''Test the ability to reset values of a service group'''
     group = ServiceGroup('GROUP')
     ser1 = Service('I1')
     action = Action(name='start', delay=3)
     action.maxretry = 5
     action.tries = 3
     action.status = DONE
     ser1.add_action(action)
     ser1.status = ERROR
     group.add_inter_dep(target=ser1)
     group.status = DEP_ERROR
     group.reset()
     self.assertEqual(group.status, NO_STATUS)
     self.assertEqual(ser1.status, NO_STATUS)
     self.assertEqual(action.status, NO_STATUS)
     self.assertEqual(action.tries, 0)
Beispiel #10
0
 def test_reset_action(self):
     '''Test resest values of an action'''
     action = Action(name='start',
                     target='fortoy5',
                     command='/bin/true',
                     timeout=10,
                     delay=5)
     action.maxretry = 5
     action.tries = 4
     action.worker = 'test'
     action.start_time = 1444253681.36017
     action.stop_time = 1444253681.36017
     action.reset()
     self.assertEqual(action.tries, 0)
     self.assertEqual(action.worker, None)
     self.assertEqual(action.start_time, None)
     self.assertEqual(action.stop_time, None)
     self.assertEqual(action.status, NO_STATUS)