def test_parent_down_child_state_changes(unreachable_enabled, site: Site, initial_state): with WatchLog(site) as log: # - Set parent down, expect DOWN notification _send_parent_down(site, log) log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-parent;DOWN;check-mk-notify;" ) # - set child down, expect UNREACHABLE notification assert site.get_host_state("notify-test-child") == STATE_UP site.send_host_check_result("notify-test-child", STATE_DOWN, "DOWN", expected_state=STATE_UNREACHABLE) log.check_logged("HOST ALERT: notify-test-child;UNREACHABLE;HARD;1;") if unreachable_enabled: log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" ) else: log.check_not_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" ) # - set child up, expect UP notification site.send_host_check_result("notify-test-child", STATE_UP, "UP") log.check_logged("HOST ALERT: notify-test-child;UP;HARD;1;") if unreachable_enabled: log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;") else: log.check_not_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;") # - set child down, expect UNREACHABLE notification assert site.get_host_state("notify-test-child") == STATE_UP site.send_host_check_result("notify-test-child", STATE_DOWN, "DOWN", expected_state=STATE_UNREACHABLE) log.check_logged("HOST ALERT: notify-test-child;UNREACHABLE;HARD;1;") if unreachable_enabled: log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" ) else: log.check_not_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" )
def _send_child_down_expect_unreachable(scenario, site: Site, log): assert site.get_host_state("notify-test-child") == STATE_UP site.send_host_check_result( "notify-test-child", STATE_DOWN, "DOWN", expected_state=STATE_UNREACHABLE ) log.check_logged("HOST ALERT: notify-test-child;UNREACHABLE;HARD;1;") if scenario.unreachable_enabled: log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" ) else: log.check_not_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" )