Merge "Fix non-existent method of Mock" into stable/rocky
This commit is contained in:
commit
dd11c90689
|
@ -5475,33 +5475,32 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
return migration
|
return migration
|
||||||
|
|
||||||
@mock.patch('nova.compute.api.API._record_action_start')
|
@mock.patch('nova.compute.api.API._record_action_start')
|
||||||
@mock.patch.object(compute_rpcapi.ComputeAPI, 'live_migration_abort')
|
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
||||||
def test_live_migrate_abort_succeeded(self,
|
def test_live_migrate_abort_succeeded(self,
|
||||||
mock_get_migration,
|
mock_get_migration,
|
||||||
mock_lm_abort,
|
|
||||||
mock_rec_action):
|
mock_rec_action):
|
||||||
instance = self._create_instance_obj()
|
instance = self._create_instance_obj()
|
||||||
instance.task_state = task_states.MIGRATING
|
instance.task_state = task_states.MIGRATING
|
||||||
migration = self._get_migration(21, 'running', 'live-migration')
|
migration = self._get_migration(21, 'running', 'live-migration')
|
||||||
mock_get_migration.return_value = migration
|
mock_get_migration.return_value = migration
|
||||||
|
|
||||||
self.compute_api.live_migrate_abort(self.context,
|
with mock.patch.object(self.compute_api.compute_rpcapi,
|
||||||
instance,
|
'live_migration_abort') as mock_lm_abort:
|
||||||
migration.id)
|
self.compute_api.live_migrate_abort(self.context,
|
||||||
|
instance,
|
||||||
|
migration.id)
|
||||||
|
mock_lm_abort.assert_called_once_with(self.context, instance,
|
||||||
|
migration.id)
|
||||||
mock_rec_action.assert_called_once_with(self.context,
|
mock_rec_action.assert_called_once_with(self.context,
|
||||||
instance,
|
instance,
|
||||||
instance_actions.LIVE_MIGRATION_CANCEL)
|
instance_actions.LIVE_MIGRATION_CANCEL)
|
||||||
mock_lm_abort.called_once_with(self.context, instance, migration.id)
|
|
||||||
|
|
||||||
@mock.patch('nova.compute.api.API._record_action_start')
|
@mock.patch('nova.compute.api.API._record_action_start')
|
||||||
@mock.patch.object(compute_rpcapi.ComputeAPI, 'live_migration_abort')
|
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
||||||
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
||||||
def test_live_migrate_abort_in_queue_succeeded(self,
|
def test_live_migrate_abort_in_queue_succeeded(self,
|
||||||
mock_get_service,
|
mock_get_service,
|
||||||
mock_get_migration,
|
mock_get_migration,
|
||||||
mock_lm_abort,
|
|
||||||
mock_rec_action):
|
mock_rec_action):
|
||||||
service_obj = objects.Service()
|
service_obj = objects.Service()
|
||||||
service_obj.version = (
|
service_obj.version = (
|
||||||
|
@ -5513,16 +5512,18 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
migration = self._get_migration(
|
migration = self._get_migration(
|
||||||
21, migration_status, 'live-migration')
|
21, migration_status, 'live-migration')
|
||||||
mock_get_migration.return_value = migration
|
mock_get_migration.return_value = migration
|
||||||
self.compute_api.live_migrate_abort(self.context,
|
|
||||||
instance,
|
with mock.patch.object(self.compute_api.compute_rpcapi,
|
||||||
migration.id,
|
'live_migration_abort') as mock_lm_abort:
|
||||||
support_abort_in_queue=True)
|
self.compute_api.live_migrate_abort(
|
||||||
|
self.context, instance, migration.id,
|
||||||
|
support_abort_in_queue=True)
|
||||||
|
mock_lm_abort.assert_called_once_with(self.context, instance,
|
||||||
|
migration.id)
|
||||||
mock_rec_action.assert_called_once_with(
|
mock_rec_action.assert_called_once_with(
|
||||||
self.context, instance, instance_actions.LIVE_MIGRATION_CANCEL)
|
self.context, instance, instance_actions.LIVE_MIGRATION_CANCEL)
|
||||||
mock_lm_abort.called_once_with(self.context, instance, migration)
|
|
||||||
mock_get_migration.reset_mock()
|
mock_get_migration.reset_mock()
|
||||||
mock_rec_action.reset_mock()
|
mock_rec_action.reset_mock()
|
||||||
mock_lm_abort.reset_mock()
|
|
||||||
|
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
||||||
def test_live_migration_abort_in_queue_old_microversion_fails(
|
def test_live_migration_abort_in_queue_old_microversion_fails(
|
||||||
|
|
|
@ -8515,8 +8515,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
mock_remove_conn.assert_called_once_with(self.context, instance,
|
mock_remove_conn.assert_called_once_with(self.context, instance,
|
||||||
bdm.volume_id, None)
|
bdm.volume_id, None)
|
||||||
mock_attach_delete.called_once_with(self.context,
|
mock_attach_delete.assert_called_once_with(self.context,
|
||||||
new_attachment_id)
|
new_attachment_id)
|
||||||
self.assertEqual(bdm.attachment_id, orig_attachment_id)
|
self.assertEqual(bdm.attachment_id, orig_attachment_id)
|
||||||
self.assertEqual(orig_attachment_id, bdm.connection_info)
|
self.assertEqual(orig_attachment_id, bdm.connection_info)
|
||||||
bdm.save.assert_called_once_with()
|
bdm.save.assert_called_once_with()
|
||||||
|
|
|
@ -109,7 +109,7 @@ class NovaProxyRequestHandlerDBTestCase(test.TestCase):
|
||||||
return_value=ctxt):
|
return_value=ctxt):
|
||||||
self.wh.new_websocket_client()
|
self.wh.new_websocket_client()
|
||||||
|
|
||||||
mock_validate.called_once_with(ctxt, '123-456-789')
|
mock_validate.assert_called_once_with(ctxt, '123-456-789')
|
||||||
mock_validate_port.assert_called_once_with(
|
mock_validate_port.assert_called_once_with(
|
||||||
ctxt, mock_inst_get.return_value, str(db_obj['port']),
|
ctxt, mock_inst_get.return_value, str(db_obj['port']),
|
||||||
db_obj['console_type'])
|
db_obj['console_type'])
|
||||||
|
|
|
@ -291,15 +291,15 @@ class GetNetNameByVfPciAddressTestCase(test.NoDBTestCase):
|
||||||
self.mock_get_ifname.return_value = self.if_name
|
self.mock_get_ifname.return_value = self.if_name
|
||||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||||
self.assertEqual(ref_net_name, net_name)
|
self.assertEqual(ref_net_name, net_name)
|
||||||
self.mock_get_mac.called_once_with(self.pci_address)
|
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||||
self.mock_get_ifname.called_once_with(self.pci_address)
|
self.mock_get_ifname.assert_called_once_with(self.pci_address)
|
||||||
|
|
||||||
def test_wrong_mac(self):
|
def test_wrong_mac(self):
|
||||||
self.mock_get_mac.side_effect = (
|
self.mock_get_mac.side_effect = (
|
||||||
exception.PciDeviceNotFoundById(self.pci_address))
|
exception.PciDeviceNotFoundById(self.pci_address))
|
||||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||||
self.assertIsNone(net_name)
|
self.assertIsNone(net_name)
|
||||||
self.mock_get_mac.called_once_with(self.pci_address)
|
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||||
self.mock_get_ifname.assert_not_called()
|
self.mock_get_ifname.assert_not_called()
|
||||||
|
|
||||||
def test_wrong_ifname(self):
|
def test_wrong_ifname(self):
|
||||||
|
@ -308,5 +308,5 @@ class GetNetNameByVfPciAddressTestCase(test.NoDBTestCase):
|
||||||
exception.PciDeviceNotFoundById(self.pci_address))
|
exception.PciDeviceNotFoundById(self.pci_address))
|
||||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||||
self.assertIsNone(net_name)
|
self.assertIsNone(net_name)
|
||||||
self.mock_get_mac.called_once_with(self.pci_address)
|
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||||
self.mock_get_ifname.called_once_with(self.pci_address)
|
self.mock_get_ifname.assert_called_once_with(self.pci_address)
|
||||||
|
|
|
@ -7600,8 +7600,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
drvr._disconnect_volume(self.context, connection_info, instance,
|
drvr._disconnect_volume(self.context, connection_info, instance,
|
||||||
encryption=encryption)
|
encryption=encryption)
|
||||||
drvr._host.delete_secret.assert_not_called()
|
drvr._host.delete_secret.assert_not_called()
|
||||||
mock_encryptor.detach_volume.called_once_with(self.context,
|
mock_encryptor.detach_volume.assert_called_once_with(**encryption)
|
||||||
**encryption)
|
|
||||||
|
|
||||||
@mock.patch.object(libvirt_driver.LibvirtDriver, '_detach_encryptor')
|
@mock.patch.object(libvirt_driver.LibvirtDriver, '_detach_encryptor')
|
||||||
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
|
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
|
||||||
|
@ -12459,9 +12458,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
self.assertEqual(info[1]['over_committed_disk_size'], 18146236825)
|
self.assertEqual(info[1]['over_committed_disk_size'], 18146236825)
|
||||||
|
|
||||||
vdmock.XMLDesc.assert_called_once_with(0)
|
vdmock.XMLDesc.assert_called_once_with(0)
|
||||||
mock_qemu_img_info.called_once_with('/test/disk.local')
|
mock_qemu_img_info.assert_called_once_with('/test/disk.local')
|
||||||
mock_stat.called_once_with('/test/disk')
|
mock_stat.assert_called_once_with('/test/disk')
|
||||||
mock_get_size.called_once_with('/test/disk')
|
mock_get_size.assert_called_once_with('/test/disk')
|
||||||
|
|
||||||
def test_post_live_migration(self):
|
def test_post_live_migration(self):
|
||||||
vol1_conn_info = {'data': {'test_data': mock.sentinel.vol1},
|
vol1_conn_info = {'data': {'test_data': mock.sentinel.vol1},
|
||||||
|
@ -15160,8 +15159,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
"rxvlan", "txvlan"]
|
"rxvlan", "txvlan"]
|
||||||
}
|
}
|
||||||
self.assertEqual(expect_vf, actualvf)
|
self.assertEqual(expect_vf, actualvf)
|
||||||
mock_get_net_name.called_once_with(parent_address)
|
mock_get_net_name.assert_called_once_with(parent_address)
|
||||||
mock_dev_lookup.called_once_with(dev_name)
|
mock_dev_lookup.assert_called_once_with(dev_name)
|
||||||
|
|
||||||
def test_get_pcidev_info(self):
|
def test_get_pcidev_info(self):
|
||||||
self.stub_out('nova.virt.libvirt.host.Host.device_lookup_by_name',
|
self.stub_out('nova.virt.libvirt.host.Host.device_lookup_by_name',
|
||||||
|
@ -17119,7 +17118,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
self.assertRaises(test.TestingException,
|
self.assertRaises(test.TestingException,
|
||||||
drvr._cleanup_failed_start,
|
drvr._cleanup_failed_start,
|
||||||
None, None, None, None, guest, True)
|
None, None, None, None, guest, True)
|
||||||
mock_cleanup.called_once_with(None, None, network_info=None,
|
mock_cleanup.assert_called_once_with(None, None, network_info=None,
|
||||||
block_device_info=None, destroy_disks=True)
|
block_device_info=None, destroy_disks=True)
|
||||||
self.assertTrue(guest.poweroff.called)
|
self.assertTrue(guest.poweroff.called)
|
||||||
|
|
||||||
|
@ -19367,7 +19366,9 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
|
||||||
self.context, ins_ref, _fake_network_info(self, 1))
|
self.context, ins_ref, _fake_network_info(self, 1))
|
||||||
mock_get_path.assert_called_once_with(ins_ref)
|
mock_get_path.assert_called_once_with(ins_ref)
|
||||||
self.assertFalse(mock_remove.called)
|
self.assertFalse(mock_remove.called)
|
||||||
mock_rmtree.called_once_with('/fake/inst')
|
self.assertEqual(5, mock_rmtree.call_count)
|
||||||
|
mock_rmtree.assert_has_calls([mock.call('/fake/inst_resize',
|
||||||
|
ignore_errors=True)] * 5)
|
||||||
|
|
||||||
def test_get_instance_disk_info_exception(self):
|
def test_get_instance_disk_info_exception(self):
|
||||||
instance = self._create_instance()
|
instance = self._create_instance()
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
'tap', run_as_root=True, check_exit_code=[0, 2, 254]),
|
'tap', run_as_root=True, check_exit_code=[0, 2, 254]),
|
||||||
mock.call('ip', 'link', 'set', 'tap-xxx-yyy-zzz', 'up',
|
mock.call('ip', 'link', 'set', 'tap-xxx-yyy-zzz', 'up',
|
||||||
run_as_root=True, check_exit_code=[0, 2, 254])])
|
run_as_root=True, check_exit_code=[0, 2, 254])])
|
||||||
mock_plug_contrail.called_once_with(
|
mock_plug_contrail.assert_called_once_with(
|
||||||
instance.project_id, instance.uuid, instance.display_name,
|
instance.project_id, instance.uuid, instance.display_name,
|
||||||
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
|
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
|
||||||
'NovaVMPort', self.vif_vrouter['devname'],
|
'NovaVMPort', self.vif_vrouter['devname'],
|
||||||
|
@ -1071,7 +1071,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
|
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
|
||||||
multiqueue=True)
|
multiqueue=True)
|
||||||
|
|
||||||
mock_plug_contrail.called_once_with(
|
mock_plug_contrail.assert_called_once_with(
|
||||||
instance.project_id, instance.uuid, instance.display_name,
|
instance.project_id, instance.uuid, instance.display_name,
|
||||||
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
|
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
|
||||||
'NovaVMPort', self.vif_vrouter['devname'],
|
'NovaVMPort', self.vif_vrouter['devname'],
|
||||||
|
|
Loading…
Reference in New Issue