Merge "Remove network debug"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 3c6eb44..86dda80 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -517,9 +517,6 @@
# From tempest.config
#
-# Enable diagnostic commands (boolean value)
-#enable = true
-
# A regex to determine which requests should be traced. This is a
# regex to match the caller for rest client requests to be able to
# selectively trace calls out of specific classes and methods. It
diff --git a/tempest/common/commands.py b/tempest/common/commands.py
index 6583475..e68c20e 100644
--- a/tempest/common/commands.py
+++ b/tempest/common/commands.py
@@ -19,63 +19,6 @@
LOG = logging.getLogger(__name__)
-# NOTE(afazekas):
-# These commands assumes the tempest node is the same as
-# the only one service node. all-in-one installation.
-
-
-def sudo_cmd_call(cmd):
- args = shlex.split(cmd.encode('utf-8'))
- subprocess_args = {'stdout': subprocess.PIPE,
- 'stderr': subprocess.STDOUT}
- proc = subprocess.Popen(['/usr/bin/sudo', '-n'] + args,
- **subprocess_args)
- stdout = proc.communicate()[0]
- if proc.returncode != 0:
- LOG.error(("Command {0} returned with exit status {1},"
- "output {2}").format(cmd, proc.returncode, stdout))
- return stdout
-
-
-def ip_addr_raw():
- return sudo_cmd_call("ip a")
-
-
-def ip_route_raw():
- return sudo_cmd_call("ip r")
-
-
-def ip_ns_raw():
- return sudo_cmd_call("ip netns list")
-
-
-def iptables_raw(table):
- return sudo_cmd_call("iptables --line-numbers -L -nv -t " + table)
-
-
-def ip_ns_list():
- return ip_ns_raw().split()
-
-
-def ip_ns_exec(ns, cmd):
- return sudo_cmd_call(" ".join(("ip netns exec", ns, cmd)))
-
-
-def ip_ns_addr(ns):
- return ip_ns_exec(ns, "ip a")
-
-
-def ip_ns_route(ns):
- return ip_ns_exec(ns, "ip r")
-
-
-def iptables_ns(ns, table):
- return ip_ns_exec(ns, "iptables -v -S -t " + table)
-
-
-def ovs_db_dump():
- return sudo_cmd_call("ovsdb-client dump")
-
def copy_file_to_host(file_from, dest, host, username, pkey):
dest = "%s@%s:%s" % (username, host, dest)
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
deleted file mode 100644
index 16e5ffe..0000000
--- a/tempest/common/debug.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common import commands
-from tempest import config
-from tempest.openstack.common import log as logging
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-TABLES = ['filter', 'nat', 'mangle']
-
-
-def log_ip_ns():
- if not CONF.debug.enable:
- return
- LOG.info("Host Addr:\n" + commands.ip_addr_raw())
- LOG.info("Host Route:\n" + commands.ip_route_raw())
- 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 TABLES:
- LOG.info('ns(%s) table(%s):\n%s', ns, table,
- commands.iptables_ns(ns, table))
-
-
-def log_ovs_db():
- if not CONF.debug.enable or not CONF.service_available.neutron:
- return
- db_dump = commands.ovs_db_dump()
- LOG.info("OVS DB:\n" + db_dump)
-
-
-def log_net_debug():
- log_ip_ns()
- log_ovs_db()
diff --git a/tempest/config.py b/tempest/config.py
index 03346c9..cc6d626 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -926,9 +926,6 @@
title="Debug System")
DebugGroup = [
- cfg.BoolOpt('enable',
- default=True,
- help="Enable diagnostic commands"),
cfg.StrOpt('trace_requests',
default='',
help="""A regex to determine which requests should be traced.
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index e46ec6d..ca89a51 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -24,7 +24,6 @@
from tempest import auth
from tempest import clients
from tempest.common import credentials
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
@@ -326,7 +325,6 @@
linux_client.validate_authentication()
except Exception:
LOG.exception('Initializing SSH connection to %s failed' % ip)
- debug.log_net_debug()
# If we don't explicitely set for which servers we want to
# log the console output then all the servers will be logged.
# See the definition of _log_console_output()
@@ -400,7 +398,6 @@
# network debug is called as part of ssh init
if not isinstance(exc, exceptions.SSHTimeout):
LOG.debug('Network information on a devstack host')
- debug.log_net_debug()
def create_server_snapshot(self, server, name=None):
# Glance client
@@ -510,15 +507,12 @@
username,
private_key,
should_connect=should_connect)
- except Exception as e:
+ except Exception:
ex_msg = 'Public network connectivity check failed'
if msg:
ex_msg += ": " + msg
LOG.exception(ex_msg)
self._log_console_output(servers)
- # network debug is called as part of ssh init
- if not isinstance(e, exceptions.SSHTimeout):
- debug.log_net_debug()
raise
def create_floating_ip(self, thing, pool_name=None):
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index d24eb01..98e3fda 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -18,7 +18,6 @@
import testtools
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -325,7 +324,6 @@
LOG.exception("Unable to access {dest} via ssh to "
"floating-ip {src}".format(dest=remote_ip,
src=floating_ip))
- debug.log_ip_ns()
raise
@test.attr(type='smoke')
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 7e6805c..d8f7a26 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -14,7 +14,6 @@
# under the License.
from tempest import clients
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
@@ -334,15 +333,8 @@
msg = "Timed out waiting for %s to become reachable" % ip
else:
msg = "%s is reachable" % ip
- try:
- self.assertTrue(self._check_remote_connectivity(access_point, ip,
- should_succeed),
- msg)
- except test.exceptions.SSHTimeout:
- raise
- except Exception:
- debug.log_net_debug()
- raise
+ self.assertTrue(self._check_remote_connectivity(access_point, ip,
+ should_succeed), msg)
def _test_in_tenant_block(self, tenant):
access_point_ssh = self._connect_to_access_point(tenant)
diff --git a/tempest/tests/common/test_debug.py b/tempest/tests/common/test_debug.py
deleted file mode 100644
index 8a880f2..0000000
--- a/tempest/tests/common/test_debug.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright 2014 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import mock
-
-from tempest.common import debug
-from tempest import config
-from tempest.openstack.common.fixture import mockpatch
-from tempest import test
-from tempest.tests import base
-from tempest.tests import fake_config
-
-
-class TestDebug(base.TestCase):
-
- def setUp(self):
- super(TestDebug, self).setUp()
- self.useFixture(fake_config.ConfigFixture())
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
-
- common_pre = 'tempest.common.commands'
- self.ip_addr_raw_mock = self.patch(common_pre + '.ip_addr_raw')
- self.ip_route_raw_mock = self.patch(common_pre + '.ip_route_raw')
- self.iptables_raw_mock = self.patch(common_pre + '.iptables_raw')
- self.ip_ns_list_mock = self.patch(common_pre + '.ip_ns_list')
- self.ip_ns_addr_mock = self.patch(common_pre + '.ip_ns_addr')
- self.ip_ns_route_mock = self.patch(common_pre + '.ip_ns_route')
- self.iptables_ns_mock = self.patch(common_pre + '.iptables_ns')
- self.ovs_db_dump_mock = self.patch(common_pre + '.ovs_db_dump')
-
- self.log_mock = self.patch('tempest.common.debug.LOG')
-
- def test_log_ip_ns_debug_disabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- debug.log_ip_ns()
- self.assertFalse(self.ip_addr_raw_mock.called)
- self.assertFalse(self.log_mock.info.called)
-
- def test_log_ip_ns_debug_enabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
-
- 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(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)
-
- self.ip_ns_list_mock.assert_called_with()
- self.assertEqual(len(self.ip_ns_list_mock.return_value),
- self.ip_ns_addr_mock.call_count)
- self.assertEqual(len(self.ip_ns_list_mock.return_value),
- self.ip_ns_route_mock.call_count)
- for ns in self.ip_ns_list_mock.return_value:
- self.assertIn(mock.call(ns),
- self.ip_ns_addr_mock.call_args_list)
- self.assertIn(mock.call(ns),
- self.ip_ns_route_mock.call_args_list)
-
- 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 debug.TABLES:
- self.assertIn(mock.call(ns, table),
- self.iptables_ns_mock.call_args_list)
-
- def test_log_ovs_db_debug_disabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', False))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', False))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', True))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- def test_log_ovs_db_debug_enabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', True))
- debug.log_ovs_db()
- self.ovs_db_dump_mock.assert_called_with()
-
- def test_log_net_debug(self):
- self.log_ip_ns_mock = self.patch('tempest.common.debug.log_ip_ns')
- self.log_ovs_db_mock = self.patch('tempest.common.debug.log_ovs_db')
-
- debug.log_net_debug()
- self.log_ip_ns_mock.assert_called_with()
- self.log_ovs_db_mock.assert_called_with()
diff --git a/tempest/tests/test_commands.py b/tempest/tests/test_commands.py
deleted file mode 100644
index 2379741..0000000
--- a/tempest/tests/test_commands.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import subprocess
-
-import mock
-
-from tempest.common import commands
-from tempest.tests import base
-
-
-class TestCommands(base.TestCase):
-
- def setUp(self):
- super(TestCommands, self).setUp()
- self.subprocess_args = {'stdout': subprocess.PIPE,
- 'stderr': subprocess.STDOUT}
-
- @mock.patch('subprocess.Popen')
- def test_ip_addr_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'a']
- commands.ip_addr_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_route_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'r']
- commands.ip_route_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'list']
- commands.ip_ns_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_iptables_raw(self, mock):
- table = 'filter'
- expected = ['/usr/bin/sudo', '-n', 'iptables', '--line-numbers',
- '-L', '-nv', '-t',
- '%s' % table]
- commands.iptables_raw(table)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_list(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'list']
- commands.ip_ns_list()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_addr(self, mock):
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'ip', 'a']
- commands.ip_ns_addr(ns)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_route(self, mock):
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'ip', 'r']
- commands.ip_ns_route(ns)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_iptables_ns(self, mock):
- table = 'filter'
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'iptables', '-v', '-S', '-t', table]
- commands.iptables_ns(ns, table)
- mock.assert_called_once_with(expected, **self.subprocess_args)