def _test(self, pin_source, pin_cond, expect_success=True): self.start_compute(hostname='source', host_info=fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=2, cpu_cores=1, cpu_threads=1, kB_mem=10740000)) self.start_compute(hostname='dest', host_info=fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=2, cpu_cores=1, cpu_threads=1, kB_mem=10740000)) ctxt = context.get_admin_context() src_mgr = self.computes['source'].manager cond_mgr = self.conductor.manager.compute_task_mgr if pin_source: src_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.2') if pin_cond: cond_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.2') self.assertEqual( not pin_source, src_mgr.compute_rpcapi.router.client(ctxt).can_send_version('5.3')) self.assertEqual( not pin_cond, cond_mgr.compute_rpcapi.router.client(ctxt).can_send_version( '5.3')) extra_spec = {'hw:numa_nodes': 1, 'hw:cpu_policy': 'dedicated'} flavor = self._create_flavor(vcpu=2, extra_spec=extra_spec) server1 = self._create_server(flavor_id=flavor, networks='none') server2 = self._create_server(flavor_id=flavor, networks='none') if self.get_host(server1['id']) == 'source': self.migrating_server = server1 else: self.migrating_server = server2 self.api.post_server_action( self.migrating_server['id'], { 'os-migrateLive': { 'host': 'dest', 'block_migration': 'auto', 'force': True } }) self._wait_for_state_change(self.migrating_server, 'ACTIVE') if expect_success: final_host = 'dest' self._wait_for_migration_status(self.migrating_server, ['completed']) else: final_host = 'source' self._wait_for_migration_status(self.migrating_server, ['failed']) self.assertEqual(final_host, self.get_host(self.migrating_server['id'])) self.assertTrue(self.migrate_stub_ran)
def _rpc_pin_host(self, hostname): ctxt = context.get_admin_context() dest_mgr = self.computes[hostname].manager dest_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI('5.2') self.assertFalse( dest_mgr.compute_rpcapi.router.client(ctxt).can_send_version( '5.3'))
def _test(self, pin_source, pin_cond, expect_success=True): self.start_compute( hostname='source', host_info=fakelibvirt.HostInfo()) self.start_compute( 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 if pin_source: src_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.2') else: # Since we upgraded the RPC API to 6.0, we somehow need to pin the # compute service here to 5.max to verify the legacy behaviours. # TODO(sbauza): Remove this cruft src_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.13') if pin_cond: cond_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.2') else: # Since we upgraded the RPC API to 6.0, we somehow need to pin the # compute service here to 5.max to verify the legacy behaviours. # TODO(sbauza): Remove this cruft cond_mgr.compute_rpcapi = integrated_helpers.StubComputeRPCAPI( '5.13') self.assertEqual( not pin_source, src_mgr.compute_rpcapi.router.client( ctxt).can_send_version('5.3')) self.assertEqual( not pin_cond, cond_mgr.compute_rpcapi.router.client( ctxt).can_send_version('5.3')) extra_spec = {'hw:numa_nodes': 1, 'hw:cpu_policy': 'dedicated'} flavor = self._create_flavor(vcpu=2, extra_spec=extra_spec) server1 = self._create_server(flavor_id=flavor, networks='none') 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', 'block_migration': 'auto', 'force': True}}) self._wait_for_state_change(self.migrating_server, 'ACTIVE') if expect_success: final_host = 'dest' self._wait_for_migration_status(self.migrating_server, ['completed']) else: final_host = 'source' self._wait_for_migration_status(self.migrating_server, ['failed']) self.assertEqual(final_host, self.get_host(self.migrating_server['id'])) self.assertTrue(self.migrate_stub_ran)