tests: Add os-brick fixture
Change-Id: Ic5e513fde04032113f22085ce8012fd456f2f844 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
33be6d4b56
commit
e2d25eb149
|
@ -21,6 +21,7 @@ from .imagebackend import ImageBackendFixture # noqa: F401
|
|||
from .libvirt import LibvirtFixture # noqa: F401
|
||||
from .neutron import NeutronFixture # noqa: F401
|
||||
from .nova import * # noqa: F401, F403
|
||||
from .os_brick import OSBrickFixture # noqa: F401
|
||||
from .policy import OverridePolicyFixture # noqa: F401
|
||||
from .policy import PolicyFixture # noqa: F401
|
||||
from .policy import RealPolicyFixture # noqa: F401
|
||||
|
|
|
@ -10,9 +10,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
|
||||
def get_connector_properties(root_helper, my_ip, multipath, enforce_multipath,
|
||||
host=None):
|
||||
|
||||
def get_connector_properties(
|
||||
root_helper, my_ip, multipath, enforce_multipath, host=None, execute=None,
|
||||
):
|
||||
"""Fake os-brick."""
|
||||
|
||||
props = {}
|
||||
|
@ -31,12 +34,22 @@ def get_connector_properties(root_helper, my_ip, multipath, enforce_multipath,
|
|||
class ISCSIConnector(object):
|
||||
"""Mimick the iSCSI connector."""
|
||||
|
||||
def __init__(self, root_helper, driver=None,
|
||||
execute=None, use_multipath=False,
|
||||
device_scan_attempts=3,
|
||||
*args, **kwargs):
|
||||
def __init__(
|
||||
self, root_helper, driver=None, execute=None, use_multipath=False,
|
||||
device_scan_attempts=3, *args, **kwargs,
|
||||
):
|
||||
self.root_herlp = root_helper,
|
||||
self.execute = execute
|
||||
|
||||
def get_initiator(self):
|
||||
return "fake_iscsi.iqn"
|
||||
|
||||
|
||||
class OSBrickFixture(fixtures.Fixture):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'os_brick.initiator.connector.get_connector_properties',
|
||||
get_connector_properties))
|
|
@ -23,10 +23,10 @@ from nova.compute import resource_tracker as rt
|
|||
from nova import context
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
from nova.tests.fixtures import libvirt as fakelibvirt
|
||||
from nova.tests.functional import integrated_helpers
|
||||
from nova.tests.functional.libvirt import base
|
||||
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -46,6 +46,8 @@ class NUMALiveMigrationBase(base.ServersTestBase,
|
|||
def setUp(self):
|
||||
super(NUMALiveMigrationBase, self).setUp()
|
||||
|
||||
self.useFixture(nova_fixtures.OSBrickFixture())
|
||||
|
||||
# NOTE(artom) There's a specific code path that we want to test.
|
||||
# There's an instance.save() call in the compute manager's
|
||||
# post_live_migration_at_destination(), and another instance.save()
|
||||
|
@ -64,9 +66,6 @@ class NUMALiveMigrationBase(base.ServersTestBase,
|
|||
'nova.compute.manager.ComputeManager.'
|
||||
'_live_migration_cleanup_flags',
|
||||
lambda *args, **kwargs: (True, True)))
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.virt.libvirt.driver.connector',
|
||||
fake_os_brick_connector))
|
||||
|
||||
def _migrate_stub(self, domain, destination, params, flags):
|
||||
raise test.TestingException('_migrate_stub() must be implemented in '
|
||||
|
|
|
@ -36,7 +36,6 @@ from nova.tests.fixtures import libvirt as fakelibvirt
|
|||
from nova.tests.functional.api import client
|
||||
from nova.tests.functional.libvirt import base
|
||||
from nova.tests.unit import fake_notifier
|
||||
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -122,9 +121,7 @@ class SRIOVServersTest(_PCIServersTestBase):
|
|||
# fixture already stubbed.
|
||||
self.neutron = self.useFixture(base.LibvirtNeutronFixture(self))
|
||||
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.virt.libvirt.driver.connector',
|
||||
fake_os_brick_connector))
|
||||
self.useFixture(nova_fixtures.OSBrickFixture())
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
|
||||
self._migrate_stub))
|
||||
|
|
|
@ -18,9 +18,9 @@ from urllib import parse as urlparse
|
|||
from nova import context
|
||||
from nova.network import constants as neutron_constants
|
||||
from nova.network import neutron
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
from nova.tests.fixtures import libvirt as fakelibvirt
|
||||
from nova.tests.functional.libvirt import base as libvirt_base
|
||||
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
|
||||
|
||||
|
||||
class TestLiveMigrationWithoutMultiplePortBindings(
|
||||
|
@ -54,12 +54,8 @@ class TestLiveMigrationWithoutMultiplePortBindings(
|
|||
super().setUp()
|
||||
self.neutron.list_extensions = self.list_extensions
|
||||
self.neutron_api = neutron.API()
|
||||
# TODO(sean-k-mooney): remove after
|
||||
# I275509eb0e0eb9eaf26fe607b7d9a67e1edc71f8
|
||||
# has merged.
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.virt.libvirt.driver.connector',
|
||||
fake_os_brick_connector))
|
||||
|
||||
self.useFixture(nova_fixtures.OSBrickFixture())
|
||||
|
||||
self.start_compute(
|
||||
hostname='start_host',
|
||||
|
|
|
@ -82,15 +82,10 @@ class _FakeDriverBackendTestCase(object):
|
|||
else:
|
||||
self.saved_libvirt = None
|
||||
|
||||
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
|
||||
|
||||
self.useFixture(nova_fixtures.OSBrickFixture())
|
||||
self.useFixture(nova_fixtures.ImageBackendFixture())
|
||||
self.useFixture(nova_fixtures.LibvirtFixture())
|
||||
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.virt.libvirt.driver.connector',
|
||||
fake_os_brick_connector))
|
||||
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.virt.libvirt.host.Host._conn_event_thread',
|
||||
lambda *args: None))
|
||||
|
|
Loading…
Reference in New Issue