Add sanity check for nova notification support
Since nova notification support adds a runtime dependency on novaclient, add an external sanity check testing the system's ability to import neutron.notifiers.nova Change-Id: I8a72c8763bb69a01178fc4ec91071a64a4648aab Closes-bug: #1334412
This commit is contained in:
parent
52e281c736
commit
a630b3bae8
@ -34,3 +34,11 @@ def patch_supported(root_helper):
|
||||
with ovs_lib.OVSBridge(name, root_helper) as br:
|
||||
port = br.add_patch_port(patch_name, peer_name)
|
||||
return port != ovs_const.INVALID_OFPORT
|
||||
|
||||
|
||||
def nova_notify_supported():
|
||||
try:
|
||||
import neutron.notifiers.nova # noqa since unused
|
||||
return True
|
||||
except ImportError:
|
||||
return False
|
||||
|
@ -51,12 +51,23 @@ def check_ovs_patch():
|
||||
return result
|
||||
|
||||
|
||||
def check_nova_notify():
|
||||
result = checks.nova_notify_supported()
|
||||
if not result:
|
||||
LOG.error(_('Nova notifcations are enabled, but novaclient is not '
|
||||
'installed. Either disable nova notifications or install '
|
||||
'python-novaclient.'))
|
||||
return result
|
||||
|
||||
|
||||
# Define CLI opts to test specific features, with a calback for the test
|
||||
OPTS = [
|
||||
BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
|
||||
help=_('Check for vxlan support')),
|
||||
BoolOptCallback('ovs_patch', check_ovs_patch, default=False,
|
||||
help=_('Check for patch port support')),
|
||||
BoolOptCallback('nova_notify', check_nova_notify, default=False,
|
||||
help=_('Check for nova notification support')),
|
||||
]
|
||||
|
||||
|
||||
@ -72,6 +83,9 @@ def enable_tests_from_config():
|
||||
cfg.CONF.set_override('ovs_patch', True)
|
||||
if not cfg.CONF.OVS.use_veth_interconnection:
|
||||
cfg.CONF.set_override('ovs_patch', True)
|
||||
if (cfg.CONF.notify_nova_on_port_status_changes or
|
||||
cfg.CONF.notify_nova_on_port_data_changes):
|
||||
cfg.CONF.set_override('nova_notify', True)
|
||||
|
||||
|
||||
def all_tests_passed():
|
||||
|
@ -19,26 +19,40 @@ from neutron.cmd.sanity import checks
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class OVSSanityTestCase(base.BaseTestCase):
|
||||
class SanityTestCase(base.BaseTestCase):
|
||||
"""Sanity checks that do not require root access.
|
||||
|
||||
Tests that just call checks.some_function() are to ensure that
|
||||
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(OVSSanityTestCase, self).setUp()
|
||||
super(SanityTestCase, self).setUp()
|
||||
|
||||
def test_nova_notify_runs(self):
|
||||
checks.nova_notify_supported()
|
||||
|
||||
|
||||
class SanityTestCaseRoot(base.BaseTestCase):
|
||||
"""Sanity checks that require root access.
|
||||
|
||||
Tests that just call checks.some_function() are to ensure that
|
||||
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.root_helper = 'sudo'
|
||||
self.check_sudo_enabled()
|
||||
|
||||
def check_sudo_enabled(self):
|
||||
if os.environ.get('OS_SUDO_TESTING') not in base.TRUE_STRING:
|
||||
self.skipTest('testing with sudo is not enabled')
|
||||
|
||||
def test_ovs_vxlan_support_runs(self):
|
||||
"""This test just ensures that the test in neutron-sanity-check
|
||||
can run through without error, without mocking anything out
|
||||
"""
|
||||
self.check_sudo_enabled()
|
||||
checks.vxlan_supported(self.root_helper)
|
||||
|
||||
def test_ovs_patch_support_runs(self):
|
||||
"""This test just ensures that the test in neutron-sanity-check
|
||||
can run through without error, without mocking anything out
|
||||
"""
|
||||
self.check_sudo_enabled()
|
||||
checks.patch_supported(self.root_helper)
|
Loading…
Reference in New Issue
Block a user