test_amqp_log_source randomly failing

Bug #922017 reported by beatpanic
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenQuake (deprecated)
Fix Released
Medium
Anton Gritsay

Bug Description

When running ./run_tests -x on ubuntu 11.10 I get randomly this test failing

======================================================================
FAIL: test_amqp_log_source (tests.logs_unittest.PythonAMQPLogTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/kpanic/src/openquake-kpanic/tests/logs_unittest.py", line 308, in test_amqp_log_source
    self.assertEqual(len(handler.buffer), 1)
AssertionError: 0 != 1

----------------------------------------------------------------------

Revision history for this message
Anton Gritsay (angri) wrote :

That seems to happen because of longer round trip time "python - amqp - python". This should solve the problem even for slower machines:

diff --git a/tests/logs_unittest.py b/tests/logs_unittest.py
index a9977b3..87981ce 100644
--- a/tests/logs_unittest.py
+++ b/tests/logs_unittest.py
@@ -274,9 +274,8 @@ class PythonAMQPLogTestCase(unittest.TestCase):
                 if self.stop_on_timeout:
                     raise StopIteration()

- logsource = _AMQPLogSource('oq.testlogger.#', timeout=0.1)
+ logsource = _AMQPLogSource('oq.testlogger.#', timeout=1.0)
         logsource_thread = threading.Thread(target=logsource.run)
- logsource_thread.start()
         handler = logging.handlers.BufferingHandler(float('inf'))
         logger = logging.getLogger('oq.testlogger')
         logger.addHandler(handler)
@@ -294,6 +293,7 @@ class PythonAMQPLogTestCase(unittest.TestCase):
             )
             self.producer.publish(msg.copy(),
                                   routing_key='oq.testlogger.sublogger')
+ logsource_thread.start()
             timeout.wait()
             timeout.clear()
             # raising minimum level to make sure that info message

Changed in openquake:
status: New → Confirmed
beatpanic (kpanic)
Changed in openquake:
assignee: nobody → Anton Gritsay (angri)
John Tarter (toh2)
Changed in openquake:
milestone: none → 0.5.1
Revision history for this message
Anton Gritsay (angri) wrote :
Changed in openquake:
status: Confirmed → In Progress
Anton Gritsay (angri)
Changed in openquake:
status: In Progress → Fix Committed
John Tarter (toh2)
Changed in openquake:
importance: Undecided → Medium
Changed in openquake:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.