Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enable OVS and NETNS utilities to perform logging
Fixes bug 1118517

Change-Id: I041e61505475da2383b34eaeb16dd3b0e9750898
  • Loading branch information
Gary Kotton committed Feb 9, 2013
1 parent d2a85e6 commit 8755cb3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion quantum/agent/netns_cleanup_util.py
Expand Up @@ -53,7 +53,6 @@ def setup_conf():
conf = cfg.CommonConfigOpts()
conf.register_opts(opts)
conf.register_opts(dhcp.OPTS)
config.setup_logging(conf)
return conf


Expand Down Expand Up @@ -147,6 +146,7 @@ def main():

conf = setup_conf()
conf(sys.argv)
config.setup_logging(conf)

# Identify namespaces that are candidates for deletion.
candidates = [ns for ns in
Expand Down
2 changes: 1 addition & 1 deletion quantum/agent/ovs_cleanup_util.py
Expand Up @@ -51,7 +51,6 @@ def setup_conf():
conf.register_opts(l3_agent.L3NATAgent.OPTS)
conf.register_opts(interface.OPTS)
conf.register_opts(agent_opts, 'AGENT')
config.setup_logging(conf)
return conf


Expand All @@ -63,6 +62,7 @@ def main():

conf = setup_conf()
conf(sys.argv)
config.setup_logging(conf)

configuration_bridges = set([conf.ovs_integration_bridge,
conf.external_network_bridge])
Expand Down
38 changes: 20 additions & 18 deletions quantum/tests/unit/test_agent_netns_cleanup.py
Expand Up @@ -184,20 +184,21 @@ def test_main(self):
with mock.patch.multiple(util, **methods_to_mock) as mocks:
mocks['eligible_for_deletion'].return_value = True
mocks['setup_conf'].return_value = conf
util.main()
with mock.patch('quantum.common.config.setup_logging'):
util.main()

mocks['eligible_for_deletion'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])
mocks['eligible_for_deletion'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])

mocks['destroy_namespace'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])
mocks['destroy_namespace'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])

ip_wrap.assert_has_calls(
[mock.call.get_namespaces('sudo')])
ip_wrap.assert_has_calls(
[mock.call.get_namespaces('sudo')])

eventlet_sleep.assert_called_once_with(2)
eventlet_sleep.assert_called_once_with(2)

def test_main_no_candidates(self):
namespaces = ['ns1', 'ns2']
Expand All @@ -216,15 +217,16 @@ def test_main_no_candidates(self):
with mock.patch.multiple(util, **methods_to_mock) as mocks:
mocks['eligible_for_deletion'].return_value = False
mocks['setup_conf'].return_value = conf
util.main()
with mock.patch('quantum.common.config.setup_logging'):
util.main()

ip_wrap.assert_has_calls(
[mock.call.get_namespaces('sudo')])
ip_wrap.assert_has_calls(
[mock.call.get_namespaces('sudo')])

mocks['eligible_for_deletion'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])
mocks['eligible_for_deletion'].assert_has_calls(
[mock.call(conf, 'ns1', False),
mock.call(conf, 'ns2', False)])

self.assertFalse(mocks['destroy_namespace'].called)
self.assertFalse(mocks['destroy_namespace'].called)

self.assertFalse(eventlet_sleep.called)
self.assertFalse(eventlet_sleep.called)
11 changes: 5 additions & 6 deletions quantum/tests/unit/test_agent_ovs_cleanup.py
Expand Up @@ -24,12 +24,11 @@

class TestOVSCleanup(unittest.TestCase):
def test_setup_conf(self):
with mock.patch('quantum.common.config.setup_logging'):
conf = util.setup_conf()
self.assertEqual(conf.external_network_bridge, 'br-ex')
self.assertEqual(conf.ovs_integration_bridge, 'br-int')
self.assertFalse(conf.ovs_all_ports)
self.assertEqual(conf.AGENT.root_helper, 'sudo')
conf = util.setup_conf()
self.assertEqual(conf.external_network_bridge, 'br-ex')
self.assertEqual(conf.ovs_integration_bridge, 'br-int')
self.assertFalse(conf.ovs_all_ports)
self.assertEqual(conf.AGENT.root_helper, 'sudo')

def test_main(self):
with mock.patch('quantum.common.config.setup_logging'):
Expand Down

0 comments on commit 8755cb3

Please sign in to comment.