Author: aconway
Date: Wed Jan  7 18:03:37 2015
New Revision: 1650131

URL: http://svn.apache.org/r1650131
Log:
DISPATCH-93: Multiple log entries in config file prevent qdroutrerd from 
starting

Fixed bug in configuration code: modifying a list while iterating over it caused
logging configuration entries to be missed when creating default log entities
and then duplicated later when the missed entities were processed.

Modified:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
    qpid/dispatch/trunk/tests/management/qdrouter.py
    qpid/dispatch/trunk/tests/system_test.py
    qpid/dispatch/trunk/tests/system_tests_management.py

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py?rev=1650131&r1=1650130&r2=1650131&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py Wed 
Jan  7 18:03:37 2015
@@ -115,10 +115,9 @@ class Config(object):
             self.entities = entities
 
     def by_type(self, entity_type):
-        """Iterator over entities of given type"""
+        """Return entities of given type"""
         entity_type = self.schema.long_name(entity_type)
-        for e in self.entities:
-            if e['type'] == entity_type: yield e
+        return [e for e in self.entities if e['type'] == entity_type]
 
     def remove(self, entity):
         self.entities.remove(entity)
@@ -148,15 +147,16 @@ def configure_dispatch(dispatch, lib_han
     for m in modules: agent.create(attributes=dict(type="log", module=m))
 
     # Configure and prepare container and router before we can activate the 
agent.
-    configure(config.by_type('container').next())
-    configure(config.by_type('router').next())
+    configure(config.by_type('container')[0])
+    configure(config.by_type('router')[0])
     qd.qd_dispatch_prepare(dispatch)
     agent.activate("$management")
     qd.qd_router_setup_late(dispatch) # Actions requiring active management 
agent.
 
     # Remaining configuration
     for t in "fixedAddress", "listener", "connector", "waypoint":
-        for a in list(config.by_type(t)): configure(a)
-    for e in list(config.entities): configure(e)
+        for a in config.by_type(t): configure(a)
+    for e in config.entities:
+        configure(e)
 
 

Modified: qpid/dispatch/trunk/tests/management/qdrouter.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/qdrouter.py?rev=1650131&r1=1650130&r2=1650131&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/management/qdrouter.py (original)
+++ qpid/dispatch/trunk/tests/management/qdrouter.py Wed Jan  7 18:03:37 2015
@@ -101,7 +101,7 @@ class QdrouterTest(unittest.TestCase):
         self.assertEqual(content, expect)
 
         conf.load(text.split(u"\n"))
-        router = conf.by_type('router').next()
+        router = conf.by_type('router')[0]
         listeners = list(conf.by_type('listener'))
         self.assertEqual(len(listeners), 3)
 

Modified: qpid/dispatch/trunk/tests/system_test.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1650131&r1=1650130&r2=1650131&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Wed Jan  7 18:03:37 2015
@@ -300,7 +300,7 @@ class Qdrouterd(Process):
             return [p for n, p in self if n == name]
 
         def defaults(self):
-            """Fill in default values in configuration"""
+            """Fill in default values in gconfiguration"""
             for name, props in self:
                 if name in Qdrouterd.Config.DEFAULTS:
                     for n,p in Qdrouterd.Config.DEFAULTS[name].iteritems():
@@ -321,7 +321,8 @@ class Qdrouterd(Process):
         @keyword wait: wait for router to be ready (call self.wait_ready())
         """
         self.config = copy(config)
-        if not [l for l in config if l[0] == 'log']:
+        default_log = [l for l in config if (l[0] == 'log' and l[1]['module'] 
== 'DEFAULT')]
+        if not default_log:
             config.append(
                 ('log', {'module':'DEFAULT', 'enable':'trace+', 'source': 
'true', 'output':name+'.log'}))
         if not pyinclude and os.environ['QPID_DISPATCH_HOME']:

Modified: qpid/dispatch/trunk/tests/system_tests_management.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1650131&r1=1650130&r2=1650131&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_management.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_management.py Wed Jan  7 18:03:37 
2015
@@ -419,5 +419,14 @@ class ManagementTest(system_test.TestCas
         self.assertTrue(r.wait() != 0)
 
 
+    def test_config_many_logs(self):
+        """Regression test for DISPATCH-93, multiple log entries in config 
file cause errors"""
+        conf = Qdrouterd.Config([
+            ('listener', {'port': self.get_port(), 'role':'normal'}),
+            ('log', { 'module': 'AGENT', 'enable': 'debug+'}),
+            ('log', { 'module': 'MESSAGE', 'enable': 'trace+'})])
+        router = self.qdrouterd("multi_log_conf", conf, wait=True)
+
+
 if __name__ == '__main__':
     unittest.main(system_test.main_module())



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to