def test_threshold_doubles_appropriately(self):
     mt = ThresholdMetric(str(random()), 5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertFalse(mt.is_okay())
         mt.increment()
         mt.increment()
         Services.time.step(30)
         mt.increment()
         mt.increment()
         Services.time.step(50)
         mt.increment()
         mt.increment()
         self.assertFalse(mt.is_okay())
         self.assertTrue(mt.is_okay(True))
Exemple #2
0
 def test_threshold_doubles_appropriately(self):
     mt = ThresholdMetric(str(random()), 5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertFalse(mt.is_okay())
         mt.increment()
         mt.increment()
         Services.time.step(30)
         mt.increment()
         mt.increment()
         Services.time.step(50)
         mt.increment()
         mt.increment()
         self.assertFalse(mt.is_okay())
         self.assertTrue(mt.is_okay(True))
 def test_negative_threshold_returns_to_success(self):
     mt = ThresholdMetric(str(random()), -5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertTrue(mt.is_okay())
         mt.increment()
         Services.time.step(30)
         mt.increment()
         mt.increment()
         mt.increment()
         mt.increment()
         self.assertFalse(mt.is_okay())
         Services.time.step(50)
         self.assertTrue(mt.is_okay())
         mt.increment()
         self.assertFalse(mt.is_okay())
Exemple #4
0
 def test_negative_threshold_returns_to_success(self):
     mt = ThresholdMetric(str(random()), -5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertTrue(mt.is_okay())
         mt.increment()
         Services.time.step(30)
         mt.increment()
         mt.increment()
         mt.increment()
         mt.increment()
         self.assertFalse(mt.is_okay())
         Services.time.step(50)
         self.assertTrue(mt.is_okay())
         mt.increment()
         self.assertFalse(mt.is_okay())
Exemple #5
0
 def check_threshold(self, doubled=False):
     if self.threshold:
         metric = ThresholdMetric(self.basekey,
                                  threshold=self.threshold,
                                  minutes=self.alarm_minutes)
         return metric.is_okay(doubled)
     return True
 def test_threshold_initial_failure(self):
     mt = ThresholdMetric(str(random()), 5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertFalse(mt.is_okay())
Exemple #7
0
 def check_threshold(self, doubled=False):
     if self.threshold:
         metric = ThresholdMetric(self.basekey, threshold=self.threshold, minutes=self.alarm_minutes)
         return metric.is_okay(doubled)
     return True
Exemple #8
0
 def test_threshold_initial_failure(self):
     mt = ThresholdMetric(str(random()), 5, 1)
     with override_service('time', FakeTimeProvider):
         self.assertFalse(mt.is_okay())