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)
class IpLibTestFramework(base.BaseLinuxTestCase):
def setUp(self):
super(IpLibTestFramework, self).setUp()
- self.check_sudo_enabled()
self._configure()
def _configure(self):
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()
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',
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()
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')
"""
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
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')
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()