[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Gerhard Lausser gerhard.lausser at consol.de
Tue Feb 28 22:17:27 UTC 2012


The following commit has been merged in the debian/master branch:
commit 88e05eefd51e25a99ed6ffcbacd5e860d7f77837
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date:   Sun Jan 29 21:19:17 2012 +0100

    Fix a bug in livestatus WaitCondition (returned too fast)

diff --git a/shinken/modules/livestatus_broker/livestatus_wait_query.py b/shinken/modules/livestatus_broker/livestatus_wait_query.py
index 9710721..2e7a530 100644
--- a/shinken/modules/livestatus_broker/livestatus_wait_query.py
+++ b/shinken/modules/livestatus_broker/livestatus_wait_query.py
@@ -232,4 +232,8 @@ class LiveStatusWaitQuery(LiveStatusQuery):
         return result
 
     def condition_fulfilled(self):
-        return self.launch_query()  # is non-empty when an item matches the filter criteria
+        # The result of launch_query is non-empty when an item matches the filter criteria
+        # We cannot return res, because in most cases it is a generator object, which always
+        # evaluates to a true value.
+        # In order to account for [] we must read the generator
+        return [x for x in self.launch_query()]
diff --git a/test/test_livestatus_trigger.py b/test/test_livestatus_trigger.py
index fe153bb..b586524 100755
--- a/test/test_livestatus_trigger.py
+++ b/test/test_livestatus_trigger.py
@@ -41,6 +41,11 @@ from shinken.comment import Comment
 
 sys.setcheckinterval(10000)
 
+# we have an external process, so we must un-fake time functions
+time.time = original_time_time
+time.sleep = original_time_sleep
+
+
 
 class TestConfig(ShinkenTest):
     def contains_line(self, text, pattern):
@@ -297,21 +302,18 @@ class TestConfigSmall(TestConfig):
 
     def tearDown(self):
         self.stop_nagios()
-        self.livestatus_broker.dbconn.commit()
-        self.livestatus_broker.dbconn.close()
+        self.livestatus_broker.db.commit()
+        self.livestatus_broker.db.close()
         if os.path.exists(self.livelogs):
             os.remove(self.livelogs)
-        if os.path.exists(self.pnp4nagios):
-            shutil.rmtree(self.pnp4nagios)
+        if os.path.exists(self.livestatus_broker.pnp_path):
+            shutil.rmtree(self.livestatus_broker.pnp_path)
         if os.path.exists('var/nagios.log'):
             os.remove('var/nagios.log')
         if os.path.exists('var/retention.dat'):
             os.remove('var/retention.dat')
         if os.path.exists('var/status.dat'):
             os.remove('var/status.dat')
-        to_del = [attr for attr in self.livestatus_broker.livestatus.__class__.out_map['Host'].keys() if attr.startswith('host_')]
-        for attr in to_del:
-            del self.livestatus_broker.livestatus.__class__.out_map['Host'][attr]
         self.livestatus_broker = None
 
 
@@ -394,12 +396,9 @@ ColumnHeaders: off
         # launch the query, which must return an empty result
         query = [q for q in response if q.my_type == "query"][0]
         wait = [q for q in response if q.my_type == "wait"][0]
-        result = wait.launch_query()
-        response = wait.response
-        print response
-        response.format_live_data(result, wait.columns, wait.aliases)
-        output, keepalive = response.respond()
-        self.assert_(not output.strip())
+        result = wait.condition_fulfilled()
+        # not yet...the plugin must run first
+        self.assert_(not result)
 
         #result = query.launch_query()
         #response = query.response
@@ -414,40 +413,19 @@ ColumnHeaders: off
         self.scheduler_loop(3, [[host, 2, 'DOWN']])
         self.update_broker(True)
 
-        print wait.filter_stack.qsize()
-        result = wait.launch_query()
-        response = wait.response
+        result = wait.condition_fulfilled()
+        # not yet...the plugin must run first
+        self.assert_(not result)
+
+        result = query.launch_query()
+        response = query.response
         response.columnheaders = "on"
         print response
-        response.format_live_data(result, wait.columns, wait.aliases)
+        response.format_live_data(result, query.columns, query.aliases)
         output, keepalive = response.respond()
         print "output of the wait is (%s)" % output
         self.assert_(output.strip())
 
-
-
-
-
-
-        query = """
-COMMAND [1303116582] SCHEDULE_FORCED_SVC_CHECK;test_host_0;test_ok_0;1303116582
-
-GET services
-WaitObject: test_host_0 test_ok_0
-WaitCondition: last_check >= 1303116582
-WaitTimeout: 10000
-WaitTrigger: check
-Columns: last_check state plugin_output
-Filter: host_name = test_host_0
-Filter: service_description = test_ok_0
-Localtime: 1303116582
-OutputFormat: python
-KeepAlive: on
-ResponseHeader: fixed16
-ColumnHeaders: off
-"""
-
-
     def test_multiple_externals(self):
         self.print_header()
         now = time.time()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list