Merge "fup: Move _migrate_stub into LibvirtMigrationMixin"
commit
10b1dc84f4
|
@ -160,6 +160,31 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase):
|
|||
return hostname
|
||||
|
||||
|
||||
class LibvirtMigrationMixin(object):
|
||||
"""A simple mixin to facilliate successful libvirt live migrations
|
||||
|
||||
Requires that the test class set self.server for the specific test instnace
|
||||
and self.{src,dest} to indicate the direction of the migration. For any
|
||||
scenarios more complex than this they should override _migrate_stub with
|
||||
their own implementation.
|
||||
"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
|
||||
self._migrate_stub))
|
||||
self.migrate_stub_ran = False
|
||||
|
||||
def _migrate_stub(self, domain, destination, params, flags):
|
||||
self.dest.driver._host.get_connection().createXML(
|
||||
params['destination_xml'],
|
||||
'fake-createXML-doesnt-care-about-flags')
|
||||
conn = self.src.driver._host.get_connection()
|
||||
dom = conn.lookupByUUIDString(self.server['id'])
|
||||
dom.complete_job()
|
||||
self.migrate_stub_ran = True
|
||||
|
||||
|
||||
class LibvirtNeutronFixture(nova_fixtures.NeutronFixture):
|
||||
"""A custom variant of the stock neutron fixture with more networks.
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ from nova.compute import manager as compute_manager
|
|||
from nova.compute import resource_tracker as rt
|
||||
from nova import context
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.fixtures import libvirt as fakelibvirt
|
||||
from nova.tests.functional import integrated_helpers
|
||||
from nova.tests.functional.libvirt import base
|
||||
|
@ -32,8 +31,11 @@ CONF = cfg.CONF
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NUMALiveMigrationBase(base.ServersTestBase,
|
||||
integrated_helpers.InstanceHelperMixin):
|
||||
class NUMALiveMigrationBase(
|
||||
base.LibvirtMigrationMixin,
|
||||
base.ServersTestBase,
|
||||
integrated_helpers.InstanceHelperMixin
|
||||
):
|
||||
"""Base for all the test classes here. Gives us the NUMATopologyFilter and
|
||||
small helper methods.
|
||||
"""
|
||||
|
@ -64,11 +66,6 @@ class NUMALiveMigrationBase(base.ServersTestBase,
|
|||
'_live_migration_cleanup_flags',
|
||||
lambda *args, **kwargs: (True, True)))
|
||||
|
||||
def _migrate_stub(self, domain, destination, params, flags):
|
||||
raise test.TestingException('_migrate_stub() must be implemented in '
|
||||
' tests that expect the live migration '
|
||||
' to start.')
|
||||
|
||||
def get_host(self, server_id):
|
||||
server = self.api.get_server(server_id)
|
||||
return server['OS-EXT-SRV-ATTR:host']
|
||||
|
@ -104,10 +101,6 @@ class NUMALiveMigrationPositiveBase(NUMALiveMigrationBase):
|
|||
|
||||
def setUp(self):
|
||||
super(NUMALiveMigrationPositiveBase, self).setUp()
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
|
||||
self._migrate_stub))
|
||||
self.migrate_stub_ran = False
|
||||
|
||||
def start_computes_and_servers(self):
|
||||
# Start 2 computes
|
||||
|
@ -469,6 +462,11 @@ class NUMALiveMigrationLegacyBase(NUMALiveMigrationPositiveBase):
|
|||
hostname='dest',
|
||||
host_info=fakelibvirt.HostInfo())
|
||||
|
||||
# This duplication is required to let the LibvirtMigrationMixin know
|
||||
# which host is which in terms of the migration.
|
||||
self.src = self.computes['source']
|
||||
self.dest = self.computes['dest']
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
src_mgr = self.computes['source'].manager
|
||||
cond_mgr = self.conductor.manager.compute_task_mgr
|
||||
|
@ -507,8 +505,10 @@ class NUMALiveMigrationLegacyBase(NUMALiveMigrationPositiveBase):
|
|||
server2 = self._create_server(flavor_id=flavor, networks='none')
|
||||
if self.get_host(server1['id']) == 'source':
|
||||
self.migrating_server = server1
|
||||
self.server = server1
|
||||
else:
|
||||
self.migrating_server = server2
|
||||
self.server = server2
|
||||
self.api.post_server_action(
|
||||
self.migrating_server['id'],
|
||||
{'os-migrateLive': {'host': 'dest',
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from nova import context
|
||||
|
@ -24,6 +22,7 @@ from nova.tests.functional.libvirt import base
|
|||
|
||||
|
||||
class TestLiveMigrateUpdateDevicePath(
|
||||
base.LibvirtMigrationMixin,
|
||||
base.ServersTestBase,
|
||||
integrated_helpers.InstanceHelperMixin
|
||||
):
|
||||
|
@ -43,12 +42,6 @@ class TestLiveMigrateUpdateDevicePath(
|
|||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# TODO(lyarwood): Move into base.ServersTestBase to allow live
|
||||
# migrations to pass without changes by the test classes.
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
|
||||
self._migrate_stub))
|
||||
|
||||
self.start_compute(
|
||||
hostname='src',
|
||||
host_info=fakelibvirt.HostInfo(
|
||||
|
@ -58,15 +51,8 @@ class TestLiveMigrateUpdateDevicePath(
|
|||
host_info=fakelibvirt.HostInfo(
|
||||
cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=1))
|
||||
|
||||
def _migrate_stub(self, domain, destination, params, flags):
|
||||
dest = self.computes['dest']
|
||||
dest.driver._host.get_connection().createXML(
|
||||
params['destination_xml'],
|
||||
'fake-createXML-doesnt-care-about-flags')
|
||||
source = self.computes['src']
|
||||
conn = source.driver._host.get_connection()
|
||||
dom = conn.lookupByUUIDString(self.server['id'])
|
||||
dom.complete_job()
|
||||
self.src = self.computes['src']
|
||||
self.dest = self.computes['dest']
|
||||
|
||||
def test_live_migrate_update_device_path(self):
|
||||
self.server = self._create_server(host='src', networks='none')
|
||||
|
|
Loading…
Reference in New Issue