@@ -569,22 +569,23 @@ def test_a_s_service_host_up(self):
569
569
host .max_check_attempts = 1
570
570
host .event_handler_enabled = False
571
571
572
- svc = self ._scheduler .services .find_srv_by_name_and_hostname (
573
- "test_host_00" , "test_ok_0" )
572
+ svc = self ._scheduler .services .find_srv_by_name_and_hostname ("test_host_00" , "test_ok_0" )
574
573
# To make tests quicker we make notifications send very quickly
575
574
svc .notification_interval = 0.001
576
575
svc .max_check_attempts = 1
577
576
svc .checks_in_progress = []
578
577
svc .event_handler_enabled = False
579
578
580
579
self .scheduler_loop (1 , [[host , 0 , 'UP' ], [svc , 0 , 'OK' ]])
581
- time .sleep (0.1 )
580
+ time .sleep (1.0 )
581
+ self .scheduler_loop (1 )
582
582
assert 0 == svc .current_notification_number , 'All OK no notifications'
583
583
self .assert_actions_count (0 )
584
- self .assert_checks_count (10 )
584
+ self .assert_checks_count (12 )
585
585
586
586
self .scheduler_loop (1 , [[svc , 2 , 'CRITICAL' ]])
587
- time .sleep (0.1 )
587
+ time .sleep (1.0 )
588
+ self .scheduler_loop (1 )
588
589
assert "HARD" == svc .state_type
589
590
assert "OK" == svc .state
590
591
self .assert_actions_count (0 )
@@ -599,18 +600,29 @@ def test_a_s_service_host_up(self):
599
600
self .assert_checks_match (11 , 'waitdep' , 'status' )
600
601
601
602
self .scheduler_loop (1 , [[host , 0 , 'UP' ]])
602
- time .sleep (0.1 )
603
+ time .sleep (1.0 )
604
+ self .scheduler_loop (1 )
603
605
assert "HARD" == svc .state_type
604
606
assert "CRITICAL" == svc .state
605
607
assert 1 == svc .current_notification_number , 'Critical HARD'
606
608
self .assert_actions_count (2 )
607
609
608
- self .assert_actions_match (0 , 'notifier.pl --hostname test_host_00 --servicedesc test_ok_0 --notificationtype PROBLEM --servicestate CRITICAL --serviceoutput CRITICAL' , 'command' )
609
- self .assert_actions_match (0 , 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact, NOTIFICATIONISESCALATED=False, NOTIFICATIONAUTHOR=n/a, NOTIFICATIONAUTHORNAME=n/a, NOTIFICATIONAUTHORALIAS=n/a, NOTIFICATIONCOMMENT=n/a, HOSTNOTIFICATIONNUMBER=1, SERVICENOTIFICATIONNUMBER=1' , 'command' )
610
+ self .assert_actions_match (0 ,
611
+ 'notifier.pl --hostname test_host_00 --servicedesc test_ok_0 '
612
+ '--notificationtype PROBLEM --servicestate CRITICAL '
613
+ '--serviceoutput CRITICAL' ,
614
+ 'command' )
615
+ self .assert_actions_match (0 ,
616
+ 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact, '
617
+ 'NOTIFICATIONISESCALATED=False, NOTIFICATIONAUTHOR=n/a, '
618
+ 'NOTIFICATIONAUTHORNAME=n/a, NOTIFICATIONAUTHORALIAS=n/a, '
619
+ 'NOTIFICATIONCOMMENT=n/a, HOSTNOTIFICATIONNUMBER=1, '
620
+ 'SERVICENOTIFICATIONNUMBER=1' ,
621
+ 'command' )
610
622
611
623
self .assert_actions_match (1 , 'VOID' , 'command' )
612
624
613
- self .assert_checks_count (10 )
625
+ self .assert_checks_count (12 )
614
626
615
627
def test_a_s_service_host_down (self ):
616
628
""" Test dependency (checks and notifications) between the service and the host (case 2)
@@ -981,7 +993,7 @@ def test_a_m_services(self):
981
993
982
994
print ("====================== host UP ===================" )
983
995
self .scheduler_loop (1 , [[host , 0 , 'UP' ]])
984
- time .sleep (0.1 )
996
+ time .sleep (1.0 )
985
997
self .scheduler_loop (1 )
986
998
assert "UP" == host .state
987
999
assert "CRITICAL" == svc1 .state
@@ -993,11 +1005,29 @@ def test_a_m_services(self):
993
1005
self .assert_actions_count (4 )
994
1006
995
1007
# Both services have a notification
996
- self .assert_actions_match (- 1 , 'notifier.pl --hostname test_host_00 --servicedesc test_ok_0 --notificationtype PROBLEM --servicestate CRITICAL --serviceoutput CRITICAL' , 'command' )
997
- self .assert_actions_match (- 1 , 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact, NOTIFICATIONISESCALATED=False, NOTIFICATIONAUTHOR=n/a, NOTIFICATIONAUTHORNAME=n/a, NOTIFICATIONAUTHORALIAS=n/a, NOTIFICATIONCOMMENT=n/a, HOSTNOTIFICATIONNUMBER=1, SERVICENOTIFICATIONNUMBER=1' , 'command' )
998
-
999
- self .assert_actions_match (- 1 , 'notifier.pl --hostname test_host_00 --servicedesc test_ok_1 --notificationtype PROBLEM --servicestate CRITICAL --serviceoutput CRITICAL' , 'command' )
1000
- self .assert_actions_match (- 1 , 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact, NOTIFICATIONISESCALATED=False, NOTIFICATIONAUTHOR=n/a, NOTIFICATIONAUTHORNAME=n/a, NOTIFICATIONAUTHORALIAS=n/a, NOTIFICATIONCOMMENT=n/a, HOSTNOTIFICATIONNUMBER=1, SERVICENOTIFICATIONNUMBER=1' , 'command' )
1008
+ self .assert_actions_match (- 1 ,
1009
+ 'notifier.pl --hostname test_host_00 --servicedesc test_ok_0 '
1010
+ '--notificationtype PROBLEM --servicestate CRITICAL '
1011
+ '--serviceoutput CRITICAL' ,
1012
+ 'command' )
1013
+ self .assert_actions_match (- 1 ,
1014
+ 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact' ,
1015
+ 'command' )
1016
+ self .assert_actions_match (- 1 ,
1017
+ 'HOSTNOTIFICATIONNUMBER=1, SERVICENOTIFICATIONNUMBER=1' ,
1018
+ 'command' )
1019
+
1020
+ self .assert_actions_match (- 1 ,
1021
+ 'notifier.pl --hostname test_host_00 --servicedesc test_ok_1 '
1022
+ '--notificationtype PROBLEM --servicestate CRITICAL '
1023
+ '--serviceoutput CRITICAL' ,
1024
+ 'command' )
1025
+ self .assert_actions_match (- 1 ,
1026
+ 'NOTIFICATIONTYPE=PROBLEM, NOTIFICATIONRECIPIENTS=test_contact' ,
1027
+ 'command' )
1028
+ self .assert_actions_match (- 1 ,
1029
+ 'HOSTNOTIFICATIONNUMBER=1, SERVICENOTIFICATIONNUMBER=1' ,
1030
+ 'command' )
1001
1031
1002
1032
self .assert_actions_match (2 , 'VOID' , 'command' )
1003
1033
self .assert_actions_match (3 , 'VOID' , 'command' )
0 commit comments