Module: check_mk
Branch: master
Commit: d93266af7d1e5d33563b95d2d1d8c34594aebcdc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d93266af7d1e5d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 19 09:40:59 2017 +0200
Enabled previously failed unreachable tests; Removed some debug output from tests
Change-Id: Ie9824f67c2bcbad084e4bb4cedb846eedd50a7e3
---
.../test_unreachable_notifications.py | 88 +++++++++++++---------
tests/testlib/__init__.py | 4 +-
2 files changed, 55 insertions(+), 37 deletions(-)
diff --git a/tests/notifications/test_unreachable_notifications.py
b/tests/notifications/test_unreachable_notifications.py
index 7f7e50f..589640d 100644
--- a/tests/notifications/test_unreachable_notifications.py
+++ b/tests/notifications/test_unreachable_notifications.py
@@ -69,8 +69,6 @@ def scenario(request, web, site):
site.live.command("[%d] DISABLE_HOST_CHECK;notify-test-child" %
time.time())
site.live.command("[%d] DISABLE_FLAP_DETECTION" % time.time())
- #set_initial_state(site, core)
-
yield request.param
finally:
#
@@ -330,9 +328,6 @@ def test_child_down_after_parent_recovers(scenario, site,
initial_state):
# - Set parent UP (again), expect DOWN notification for child
site.send_host_check_result("notify-test-parent", STATE_UP,
"UP")
- # Seems the child notification is not processed immediately (TODO check this)
- #time.sleep(1)
-
log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;DOWN;check-mk-notify;")
@@ -341,36 +336,58 @@ def test_child_down_after_parent_recovers(scenario, site,
initial_state):
# b) Child goes down and becomes unreachable
# c) Parent goes up
# d) Child goes up
-# TODO: Broken: test_child_up_after_parent_recovers[cmc-unreachable_disabled]
-#def test_child_up_after_parent_recovers(scenario, site, initial_state):
-# log = HistoryLog(site, scenario.core)
-#
-# # - Set parent down, expect DOWN notification
-# _send_parent_down(scenario, site, log)
-# log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-parent;DOWN;check-mk-notify;")
-#
-# # - set child down, expect UNREACHABLE notification
-# _send_child_down_expect_unreachable(scenario, site, log)
-#
-# # - Set parent up, expect UP notification
-# _send_parent_recovery(scenario, site, log)
-#
-# # - Next service check UP, expect no notification (till next parent check confirms
UP)
-# site.send_host_check_result("notify-test-child", STATE_UP,
"UP")
-# log.check_logged("HOST ALERT: notify-test-child;UP;HARD;1;")
-#
-# # - Set parent UP, expect UP notification for child
-# site.send_host_check_result("notify-test-parent", STATE_UP,
"UP")
-#
-# if scenario.unreachable_enabled:
-# log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP;check-mk-notify;")
-# else:
-# # TODO: Bug: It sends a recovery notification for a problem that has never
-# # been notified before.
-# # Problem: We can not disable the recovery notification since
-# # we don't know whether or not the host was down before it
-# # became unreachable.
-# log.check_not_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP;check-mk-notify;")
+def test_child_up_after_parent_recovers(scenario, site, initial_state):
+ log = HistoryLog(site, scenario.core)
+
+ # - Set parent down, expect DOWN notification
+ _send_parent_down(scenario, site, log)
+ log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-parent;DOWN;check-mk-notify;")
+
+ # - set child down, expect UNREACHABLE notification
+ _send_child_down_expect_unreachable(scenario, site, log)
+
+ # - Set parent up, expect UP notification
+ _send_parent_recovery(scenario, site, log)
+
+ # - Next service check UP, expect no notification (till next parent check confirms
UP)
+ site.send_host_check_result("notify-test-child", STATE_UP, "UP")
+ log.check_logged("HOST ALERT: notify-test-child;UP;HARD;1;")
+
+ # - Set parent UP, expect UP notification for child
+ site.send_host_check_result("notify-test-parent", STATE_UP,
"UP")
+
+ if scenario.unreachable_enabled:
+ log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP;check-mk-notify;")
+ else:
+ log.check_not_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP;check-mk-notify;")
+
+
+# Test the situation where:
+# a) Parent goes down
+# b) Child goes down and becomes unreachable
+# c) Child goes up
+# d) Parent goes up
+def test_child_down_and_up_while_not_reachable(scenario, site, initial_state):
+ log = HistoryLog(site, scenario.core)
+
+ # - Set parent down, expect DOWN notification
+ _send_parent_down(scenario, site, log)
+ log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-parent;DOWN;check-mk-notify;")
+
+ # - set child down, expect UNREACHABLE notification
+ _send_child_down_expect_unreachable(scenario, site, log)
+
+ # - Set child up, expect no notification
+ site.send_host_check_result("notify-test-child", STATE_UP, "UP")
+ log.check_logged("HOST ALERT: notify-test-child;UP;HARD;1;")
+
+ if scenario.unreachable_enabled:
+ log.check_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP;check-mk-notify;")
+ else:
+ log.check_not_logged("HOST NOTIFICATION:
check-mk-notify;notify-test-child;UP")
+
+ # - Set parent up, expect UP notification
+ _send_parent_recovery(scenario, site, log)
# Test the situation where:
@@ -429,6 +446,7 @@ def test_down_child_becomes_unreachable_and_down_again(scenario, site,
initial_s
# a) Child goes down
# b) Parent goes down, child becomes unreachable
# c) Child goes up
+# d) Parent goes up
def test_down_child_becomes_unreachable_then_up(scenario, site, initial_state):
log = HistoryLog(site, scenario.core)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index d0b1b52..2ee739d 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -865,8 +865,8 @@ class WebSession(requests.Session):
response.url, response.headers.get('Location',
"None"))
if response.history:
- print "Followed redirect (%d) %s -> %s" % \
- (response.history[0].status_code, response.history[0].url, response.url)
+ #print "Followed redirect (%d) %s -> %s" % \
+ # (response.history[0].status_code, response.history[0].url,
response.url)
if not allow_redirect_to_login:
assert "check_mk/login.py" not in response.url, \
"Followed redirect (%d) %s -> %s" % \