<NME> test_unknown_do_not_change.py
<BEF> ADDFILE
<MSG> Add : test before changing the hard/bad -> unknonw->bad way of launch notifications.

<DFF> @@ -0,0 +1,78 @@
+#!/usr/bin/env python2.6
+#Copyright (C) 2009-2010 :
+#    Gabes Jean, naparuba@gmail.com
+#    Gerhard Lausser, Gerhard.Lausser@consol.de
+#
+#This file is part of Shinken.
+#
+#Shinken is free software: you can redistribute it and/or modify
+#it under the terms of the GNU Affero General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#Shinken is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU Affero General Public License for more details.
+#
+#You should have received a copy of the GNU Affero General Public License
+#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# This file is used to test reading and processing of config files
+#
+
+#It's ugly I know....
+from shinken_test import *
+
+
+class TestUnknownNotChangeState(ShinkenTest):
+    #Uncomment this is you want to use a specific configuration
+    #for your test
+    #def setUp(self):
+    #    self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
+
+    
+    # We got problem with unknown results on bad connexions 
+    # for critical services and host : if it was in a notification pass
+    # then the notification is restarted, but it's just a missing data,
+    # not a reason to warn about it
+    def test_unknown_do_not_change_state(self):
+        host = self.sched.hosts.find_by_name("test_host_0")
+        host.checks_in_progress = []
+        host.act_depend_of = [] # ignore the router
+        router = self.sched.hosts.find_by_name("test_router_0")
+        router.checks_in_progress = []
+        router.act_depend_of = [] # ignore the router
+        svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
+        svc.checks_in_progress = []
+        svc.act_depend_of = [] # no hostchecks on critical checkresults
+
+        self.scheduler_loop(2, [[host, 0, 'UP | value1=1 value2=2'], [router, 0, 'UP | rtt=10'], [svc, 0, 'OK | value1=0 value2=0']])
+        self.assert_(svc.state == 'OK')
+        self.assert_(svc.state_type == 'HARD')
+
+        # Ok we are UP, now we seach to go in trouble
+        self.scheduler_loop(1, [[svc, 2, 'PROBLEM | value1=1 value2=2']])
+        # CRITICAL/SOFT
+        self.assert_(svc.state == 'CRITICAL')
+        self.assert_(svc.state_type == 'SOFT')
+        # And again and again :)
+        self.scheduler_loop(2, [[svc, 2, 'PROBLEM | value1=1 value2=2']])
+        # CRITICAL/HARD
+        self.assert_(svc.state == 'CRITICAL')
+        self.assert_(svc.state_type == 'HARD')
+
+        # Should have a notification about it
+        self.assert_(self.any_log_match('SERVICE NOTIFICATION.*;CRITICAL'))
+        self.show_and_clear_logs()
+
+        # Then we make it as a unknown state
+        self.scheduler_loop(1, [[svc, 3, 'Unknown | value1=1 value2=2']])
+        self.assert_(self.any_log_match('SERVICE NOTIFICATION.*;UNKNOWN'))
+        self.show_and_clear_logs()
+
+
+if __name__ == '__main__':
+    unittest.main()
+

{'commit': 'diff --git a/test/quick_tests.sh b/test/quick_tests.sh\nindex 9091b6eca..0daa2b4bf 100755\n--- a/test/quick_tests.sh\n+++ b/test/quick_tests.sh\n@@ -87,6 +87,7 @@ launch_and_assert test_nullinheritance.py\n launch_and_assert test_create_link_from_ext_cmd.py\n launch_and_assert test_dispatcher.py\n launch_and_assert test_module_hot_dependencies_arbiter.py\n+launch_and_assert test_unknown_do_not_change.py\n \n #Live status is a bit longer than the previous, so we put it at the end.\n launch_and_assert test_livestatus.py\ndiff --git a/test/test_unknown_do_not_change.py b/test/test_unknown_do_not_change.py\nnew file mode 100755\nindex 000000000..02dd999d0\n--- /dev/null\n+++ b/test/test_unknown_do_not_change.py\n@@ -0,0 +1,78 @@\n+#!/usr/bin/env python2.6\n+#Copyright (C) 2009-2010 :\n+#    Gabes Jean, naparuba@gmail.com\n+#    Gerhard Lausser, Gerhard.Lausser@consol.de\n+#\n+#This file is part of Shinken.\n+#\n+#Shinken is free software: you can redistribute it and/or modify\n+#it under the terms of the GNU Affero General Public License as published by\n+#the Free Software Foundation, either version 3 of the License, or\n+#(at your option) any later version.\n+#\n+#Shinken is distributed in the hope that it will be useful,\n+#but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+#GNU Affero General Public License for more details.\n+#\n+#You should have received a copy of the GNU Affero General Public License\n+#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.\n+\n+#\n+# This file is used to test reading and processing of config files\n+#\n+\n+#It\'s ugly I know....\n+from shinken_test import *\n+\n+\n+class TestUnknownNotChangeState(ShinkenTest):\n+    #Uncomment this is you want to use a specific configuration\n+    #for your test\n+    #def setUp(self):\n+    #    self.setup_with_file(\'etc/nagios_1r_1h_1s.cfg\')\n+\n+    \n+    # We got problem with unknown results on bad connexions \n+    # for critical services and host : if it was in a notification pass\n+    # then the notification is restarted, but it\'s just a missing data,\n+    # not a reason to warn about it\n+    def test_unknown_do_not_change_state(self):\n+        host = self.sched.hosts.find_by_name("test_host_0")\n+        host.checks_in_progress = []\n+        host.act_depend_of = [] # ignore the router\n+        router = self.sched.hosts.find_by_name("test_router_0")\n+        router.checks_in_progress = []\n+        router.act_depend_of = [] # ignore the router\n+        svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")\n+        svc.checks_in_progress = []\n+        svc.act_depend_of = [] # no hostchecks on critical checkresults\n+\n+        self.scheduler_loop(2, [[host, 0, \'UP | value1=1 value2=2\'], [router, 0, \'UP | rtt=10\'], [svc, 0, \'OK | value1=0 value2=0\']])\n+        self.assert_(svc.state == \'OK\')\n+        self.assert_(svc.state_type == \'HARD\')\n+\n+        # Ok we are UP, now we seach to go in trouble\n+        self.scheduler_loop(1, [[svc, 2, \'PROBLEM | value1=1 value2=2\']])\n+        # CRITICAL/SOFT\n+        self.assert_(svc.state == \'CRITICAL\')\n+        self.assert_(svc.state_type == \'SOFT\')\n+        # And again and again :)\n+        self.scheduler_loop(2, [[svc, 2, \'PROBLEM | value1=1 value2=2\']])\n+        # CRITICAL/HARD\n+        self.assert_(svc.state == \'CRITICAL\')\n+        self.assert_(svc.state_type == \'HARD\')\n+\n+        # Should have a notification about it\n+        self.assert_(self.any_log_match(\'SERVICE NOTIFICATION.*;CRITICAL\'))\n+        self.show_and_clear_logs()\n+\n+        # Then we make it as a unknown state\n+        self.scheduler_loop(1, [[svc, 3, \'Unknown | value1=1 value2=2\']])\n+        self.assert_(self.any_log_match(\'SERVICE NOTIFICATION.*;UNKNOWN\'))\n+        self.show_and_clear_logs()\n+\n+\n+if __name__ == \'__main__\':\n+    unittest.main()\n+\n', 'commit_subject': 'Add : test before changing the hard/bad -> unknonw->bad way of launch notifications.', 'repo_name': 'naparuba/shinken', 'committer': {'name': 'Gabes Jean', 'email': 'c8e019fb2d4dd0d355144f4fa37aa9b8f4b57451@users.sourceforge.net', 'time_sec': '1296630308', 'tz_offset': '60', 'date': {'seconds': '1296630308'}}, 'commit_tree': '95070cbd222008d3d4da0e582b65105f0afe737b', 'commit_message': 'Add : test before changing the hard/bad -> unknonw->bad way of launch notifications.\n', 'language_name': 'Java', 'license': 'agpl-3.0', 'hunks': '@@ -0,0 +1,78 @@\n+#!/usr/bin/env python2.6\n+#Copyright (C) 2009-2010 :\n+#    Gabes Jean, naparuba@gmail.com\n+#    Gerhard Lausser, Gerhard.Lausser@consol.de\n+#\n+#This file is part of Shinken.\n+#\n+#Shinken is free software: you can redistribute it and/or modify\n+#it under the terms of the GNU Affero General Public License as published by\n+#the Free Software Foundation, either version 3 of the License, or\n+#(at your option) any later version.\n+#\n+#Shinken is distributed in the hope that it will be useful,\n+#but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+#GNU Affero General Public License for more details.\n+#\n+#You should have received a copy of the GNU Affero General Public License\n+#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.\n+\n+#\n+# This file is used to test reading and processing of config files\n+#\n+\n+#It\'s ugly I know....\n+from shinken_test import *\n+\n+\n+class TestUnknownNotChangeState(ShinkenTest):\n+    #Uncomment this is you want to use a specific configuration\n+    #for your test\n+    #def setUp(self):\n+    #    self.setup_with_file(\'etc/nagios_1r_1h_1s.cfg\')\n+\n+    \n+    # We got problem with unknown results on bad connexions \n+    # for critical services and host : if it was in a notification pass\n+    # then the notification is restarted, but it\'s just a missing data,\n+    # not a reason to warn about it\n+    def test_unknown_do_not_change_state(self):\n+        host = self.sched.hosts.find_by_name("test_host_0")\n+        host.checks_in_progress = []\n+        host.act_depend_of = [] # ignore the router\n+        router = self.sched.hosts.find_by_name("test_router_0")\n+        router.checks_in_progress = []\n+        router.act_depend_of = [] # ignore the router\n+        svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")\n+        svc.checks_in_progress = []\n+        svc.act_depend_of = [] # no hostchecks on critical checkresults\n+\n+        self.scheduler_loop(2, [[host, 0, \'UP | value1=1 value2=2\'], [router, 0, \'UP | rtt=10\'], [svc, 0, \'OK | value1=0 value2=0\']])\n+        self.assert_(svc.state == \'OK\')\n+        self.assert_(svc.state_type == \'HARD\')\n+\n+        # Ok we are UP, now we seach to go in trouble\n+        self.scheduler_loop(1, [[svc, 2, \'PROBLEM | value1=1 value2=2\']])\n+        # CRITICAL/SOFT\n+        self.assert_(svc.state == \'CRITICAL\')\n+        self.assert_(svc.state_type == \'SOFT\')\n+        # And again and again :)\n+        self.scheduler_loop(2, [[svc, 2, \'PROBLEM | value1=1 value2=2\']])\n+        # CRITICAL/HARD\n+        self.assert_(svc.state == \'CRITICAL\')\n+        self.assert_(svc.state_type == \'HARD\')\n+\n+        # Should have a notification about it\n+        self.assert_(self.any_log_match(\'SERVICE NOTIFICATION.*;CRITICAL\'))\n+        self.show_and_clear_logs()\n+\n+        # Then we make it as a unknown state\n+        self.scheduler_loop(1, [[svc, 3, \'Unknown | value1=1 value2=2\']])\n+        self.assert_(self.any_log_match(\'SERVICE NOTIFICATION.*;UNKNOWN\'))\n+        self.show_and_clear_logs()\n+\n+\n+if __name__ == \'__main__\':\n+    unittest.main()\n+\n', 'addition_count': 78, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/test/test_unknown_do_not_change.py', 'file_extension': '.py', 'before_file': 'ADDFILE', 'message': 'Add : test before changing the hard/bad -> unknonw->bad way of launch notifications.\n', 'author_name': 'Gabes Jean', 'lang': 'py'}