예제 #1
0
 def _cmd_sleep(self, sleep_streak, quarantined):
   out = {
     'cmd': 'sleep',
     'duration': task_scheduler.exponential_backoff(sleep_streak),
     'quarantined': quarantined,
   }
   self.send_response(out)
예제 #2
0
 def _cmd_sleep(self, sleep_streak, quarantined):
     out = {
         'cmd': 'sleep',
         'duration': task_scheduler.exponential_backoff(sleep_streak),
         'quarantined': quarantined,
     }
     self.send_response(out)
예제 #3
0
 def _cmd_sleep(self, sleep_streak, quarantined):
     duration = task_scheduler.exponential_backoff(sleep_streak)
     logging.debug('Sleep: streak: %d; duration: %ds; quarantined: %s',
                   sleep_streak, duration, quarantined)
     out = {
         'cmd': 'sleep',
         'duration': duration,
         'quarantined': quarantined,
     }
     self.send_response(out)
예제 #4
0
 def test_exponential_backoff(self):
     self.mock(task_scheduler.random, 'random',
               lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK)
     self.mock(utils, 'is_canary', lambda: False)
     data = [
         (0, 2),
         (1, 2),
         (2, 3),
         (3, 5),
         (4, 8),
         (5, 11),
         (6, 17),
         (7, 26),
         (8, 38),
         (9, 58),
         (10, 60),
         (11, 60),
     ]
     for value, expected in data:
         actual = int(round(task_scheduler.exponential_backoff(value)))
         self.assertEqual(expected, actual, (value, expected, actual))
예제 #5
0
 def test_exponential_backoff(self):
   self.mock(
       task_scheduler.random, 'random',
       lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK)
   self.mock(utils, 'is_canary', lambda: False)
   data = [
     (0, 2),
     (1, 2),
     (2, 3),
     (3, 5),
     (4, 8),
     (5, 11),
     (6, 17),
     (7, 26),
     (8, 38),
     (9, 58),
     (10, 60),
     (11, 60),
   ]
   for value, expected in data:
     actual = int(round(task_scheduler.exponential_backoff(value)))
     self.assertEqual(expected, actual, (value, expected, actual))
예제 #6
0
 def test_exponential_backoff_quick(self):
   self.mock(
       task_scheduler.random, 'random',
       lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK - 0.01)
   self.assertEqual(1.0, task_scheduler.exponential_backoff(235))
예제 #7
0
 def _cmd_sleep(self, sleep_streak, quarantined):
     out = {"cmd": "sleep", "duration": task_scheduler.exponential_backoff(sleep_streak), "quarantined": quarantined}
     self.send_response(out)
예제 #8
0
 def test_exponential_backoff_quick(self):
     self.mock(task_scheduler.random, 'random',
               lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK - 0.01)
     self.assertEqual(1.0, task_scheduler.exponential_backoff(235))