@@ -319,6 +319,40 @@ def test_object_check_threshold_crossed_for_long_time(self):
319
319
self .assertEqual (om .is_healthy_tolerant , True )
320
320
self .assertEqual (Notification .objects .count (), 2 )
321
321
322
+ def test_object_check_threshold_crossed_historical_data (self ):
323
+ """
324
+ Do not evaluate threshold crossed for historical data
325
+ """
326
+ self ._create_admin ()
327
+ om = self ._create_object_metric (name = 'load' )
328
+ self ._create_alert_settings (
329
+ metric = om , custom_operator = '>' , custom_threshold = 90 , custom_tolerance = 10
330
+ )
331
+
332
+ self ._write_metric (om , 99 , time = start_time - timedelta (minutes = 120 ))
333
+ om .refresh_from_db ()
334
+ self .assertEqual (om .is_healthy , True )
335
+ self .assertEqual (om .is_healthy_tolerant , True )
336
+ self .assertEqual (Notification .objects .count (), 0 )
337
+
338
+ self ._write_metric (om , 99 , time = start_time - timedelta (minutes = 61 ))
339
+ om .refresh_from_db ()
340
+ self .assertEqual (om .is_healthy , True )
341
+ self .assertEqual (om .is_healthy_tolerant , True )
342
+ self .assertEqual (Notification .objects .count (), 0 )
343
+
344
+ self ._write_metric (om , 99 , time = start_time - timedelta (minutes = 60 ))
345
+ om .refresh_from_db ()
346
+ self .assertEqual (om .is_healthy , True )
347
+ self .assertEqual (om .is_healthy_tolerant , True )
348
+ self .assertEqual (Notification .objects .count (), 0 )
349
+
350
+ self ._write_metric (om , 99 , time = start_time - timedelta (minutes = 10 ))
351
+ om .refresh_from_db ()
352
+ self .assertEqual (om .is_healthy , False )
353
+ self .assertEqual (om .is_healthy_tolerant , False )
354
+ self .assertEqual (Notification .objects .count (), 1 )
355
+
322
356
def test_flapping_metric_with_tolerance (self ):
323
357
self ._create_admin ()
324
358
om = self ._create_object_metric (name = 'ping' )
0 commit comments