Пример #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))