Cleanup common.debug
The debug module has a list of iptables tables but not used it. This
commit fixes it.
Change-Id: Iefb1d6a17ddc01823d5c0a524ffda8723df4d9da
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
index 6a496c2..228be7a 100644
--- a/tempest/common/debug.py
+++ b/tempest/common/debug.py
@@ -20,7 +20,7 @@
CONF = config.CONF
LOG = logging.getLogger(__name__)
-tables = ['filter', 'nat', 'mangle']
+TABLES = ['filter', 'nat', 'mangle']
def log_ip_ns():
@@ -28,14 +28,14 @@
return
LOG.info("Host Addr:\n" + commands.ip_addr_raw())
LOG.info("Host Route:\n" + commands.ip_route_raw())
- for table in ['filter', 'nat', 'mangle']:
+ for table in TABLES:
LOG.info('Host %s table:\n%s', table, commands.iptables_raw(table))
ns_list = commands.ip_ns_list()
LOG.info("Host ns list" + str(ns_list))
for ns in ns_list:
LOG.info("ns(%s) Addr:\n%s", ns, commands.ip_ns_addr(ns))
LOG.info("ns(%s) Route:\n%s", ns, commands.ip_ns_route(ns))
- for table in ['filter', 'nat', 'mangle']:
+ for table in TABLES:
LOG.info('ns(%s) table(%s):\n%s', ns, table,
commands.iptables_ns(ns, table))
diff --git a/tempest/tests/common/test_debug.py b/tempest/tests/common/test_debug.py
index cd9936c..8a880f2 100644
--- a/tempest/tests/common/test_debug.py
+++ b/tempest/tests/common/test_debug.py
@@ -53,15 +53,14 @@
self.useFixture(mockpatch.PatchObject(test.CONF.debug,
'enable', True))
- tables = ['filter', 'nat', 'mangle']
self.ip_ns_list_mock.return_value = [1, 2]
debug.log_ip_ns()
self.ip_addr_raw_mock.assert_called_with()
self.assertTrue(self.log_mock.info.called)
self.ip_route_raw_mock.assert_called_with()
- self.assertEqual(len(tables), self.iptables_raw_mock.call_count)
- for table in tables:
+ self.assertEqual(len(debug.TABLES), self.iptables_raw_mock.call_count)
+ for table in debug.TABLES:
self.assertIn(mock.call(table),
self.iptables_raw_mock.call_args_list)
@@ -76,10 +75,11 @@
self.assertIn(mock.call(ns),
self.ip_ns_route_mock.call_args_list)
- self.assertEqual(len(tables) * len(self.ip_ns_list_mock.return_value),
+ self.assertEqual(len(debug.TABLES) *
+ len(self.ip_ns_list_mock.return_value),
self.iptables_ns_mock.call_count)
for ns in self.ip_ns_list_mock.return_value:
- for table in tables:
+ for table in debug.TABLES:
self.assertIn(mock.call(ns, table),
self.iptables_ns_mock.call_args_list)