Merge "Check whether sudo is enabled in BaseSudoTestCase.setUpClass"

This commit is contained in:
Jenkins 2015-02-28 11:16:21 +00:00 committed by Gerrit Code Review
commit 5f903cf993
8 changed files with 12 additions and 28 deletions

View File

@ -161,10 +161,6 @@ class BaseIPVethTestCase(BaseLinuxTestCase):
DST_ADDRESS = '192.168.0.2'
BROADCAST_ADDRESS = '192.168.0.255'
def setUp(self):
super(BaseIPVethTestCase, self).setUp()
self.check_sudo_enabled()
@staticmethod
def _set_ip_up(device, cidr, broadcast, ip_version=4):
device.addr.add(ip_version=ip_version, cidr=cidr, broadcast=broadcast)

View File

@ -33,7 +33,6 @@ Device = collections.namedtuple('Device', 'name ip_cidr mac_address namespace')
class IpLibTestFramework(base.BaseLinuxTestCase):
def setUp(self):
super(IpLibTestFramework, self).setUp()
self.check_sudo_enabled()
self._configure()
def _configure(self):

View File

@ -17,15 +17,12 @@ from oslo_config import cfg
from neutron.agent.linux import external_process
from neutron.agent.linux import keepalived
from neutron.tests.functional import base as functional_base
from neutron.tests import base
from neutron.tests.unit.agent.linux import test_keepalived
class KeepalivedManagerTestCase(functional_base.BaseSudoTestCase,
class KeepalivedManagerTestCase(base.BaseTestCase,
test_keepalived.KeepalivedConfBaseMixin):
def setUp(self):
super(KeepalivedManagerTestCase, self).setUp()
self.check_sudo_enabled()
def test_keepalived_spawn(self):
expected_config = self._get_config()

View File

@ -49,7 +49,6 @@ class BaseMonitorTest(linux_base.BaseOVSLinuxTestCase):
self.bridge = self.create_ovs_bridge()
def _check_test_requirements(self):
self.check_sudo_enabled()
self.check_command(['ovsdb-client', 'list-dbs'],
'Exit code: 1',
'password-less sudo not granted for ovsdb-client',

View File

@ -17,14 +17,14 @@ from oslo_config import cfg
from six import moves
from neutron.agent.linux import external_process
from neutron.tests import base
from neutron.tests.functional.agent.linux import simple_daemon
from neutron.tests.functional import base
UUID_FORMAT = "test-uuid-%d"
class BaseTestProcessMonitor(base.BaseSudoTestCase):
class BaseTestProcessMonitor(base.BaseTestCase):
def setUp(self):
super(BaseTestProcessMonitor, self).setUp()

View File

@ -53,7 +53,6 @@ METADATA_REQUEST_TIMEOUT = 60
class L3AgentTestFramework(base.BaseOVSLinuxTestCase):
def setUp(self):
super(L3AgentTestFramework, self).setUp()
self.check_sudo_enabled()
mock.patch('neutron.agent.l3.agent.L3PluginApi').start()
self.agent = self._configure_agent('agent1')

View File

@ -27,12 +27,10 @@ class BaseSudoTestCase(base.BaseTestCase):
"""
Base class for tests requiring invocation of commands via a root helper.
Inheritors of this class should call check_sudo_enabled() in
setUp() to ensure that tests requiring sudo are skipped unless
OS_SUDO_TESTING is set to '1' or 'True' in the test execution
environment. This is intended to allow developers to run the
functional suite (e.g. tox -e functional) without test failures if
sudo invocations are not allowed.
This class skips (during setUp) its tests unless sudo is enabled, ie:
OS_SUDO_TESTING is set to '1' or 'True' in the test execution environment.
This is intended to allow developers to run the functional suite (e.g. tox
-e functional) without test failures if sudo invocations are not allowed.
Running sudo tests in the upstream gate jobs
(*-neutron-dsvm-functional) requires the additional step of
@ -48,14 +46,13 @@ class BaseSudoTestCase(base.BaseTestCase):
def setUp(self):
super(BaseSudoTestCase, self).setUp()
self.sudo_enabled = base.bool_from_env('OS_SUDO_TESTING')
if not base.bool_from_env('OS_SUDO_TESTING'):
self.skipTest('Testing with sudo is not enabled')
self.fail_on_missing_deps = (
base.bool_from_env('OS_FAIL_ON_MISSING_DEPS'))
config.register_root_helper(cfg.CONF)
self.config(group='AGENT',
root_helper=os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD))
def check_sudo_enabled(self):
if not self.sudo_enabled:
self.skipTest('testing with sudo is not enabled')

View File

@ -43,9 +43,6 @@ class SanityTestCaseRoot(functional_base.BaseSudoTestCase):
neutron-sanity-check runs without throwing an exception, as in the case
where someone modifies the API without updating the check script.
"""
def setUp(self):
super(SanityTestCaseRoot, self).setUp()
self.check_sudo_enabled()
def test_ovs_vxlan_support_runs(self):
checks.ovs_vxlan_supported()