Browse Source

Merge "Fix non-existent method of Mock" into stable/queens

tags/17.0.13
Zuul 4 months ago
parent
commit
563a8870d6
5 changed files with 24 additions and 26 deletions
  1. +7
    -6
      nova/tests/unit/compute/test_compute_api.py
  2. +2
    -2
      nova/tests/unit/compute/test_compute_mgr.py
  3. +5
    -5
      nova/tests/unit/pci/test_utils.py
  4. +8
    -11
      nova/tests/unit/virt/libvirt/test_driver.py
  5. +2
    -2
      nova/tests/unit/virt/libvirt/test_vif.py

+ 7
- 6
nova/tests/unit/compute/test_compute_api.py View File

@@ -5283,24 +5283,25 @@ class _ComputeAPIUnitTestMixIn(object):
return migration

@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')
def test_live_migrate_abort_succeeded(self,
mock_get_migration,
mock_lm_abort,
mock_rec_action):
instance = self._create_instance_obj()
instance.task_state = task_states.MIGRATING
migration = self._get_migration(21, 'running', 'live-migration')
mock_get_migration.return_value = migration

self.compute_api.live_migrate_abort(self.context,
instance,
migration.id)
with mock.patch.object(self.compute_api.compute_rpcapi,
'live_migration_abort') as mock_lm_abort:
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,
instance,
instance_actions.LIVE_MIGRATION_CANCEL)
mock_lm_abort.called_once_with(self.context, instance, migration.id)

@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
def test_live_migration_abort_wrong_migration_status(self,

+ 2
- 2
nova/tests/unit/compute/test_compute_mgr.py View File

@@ -7792,8 +7792,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):

mock_remove_conn.assert_called_once_with(self.context, instance,
bdm.volume_id, None)
mock_attach_delete.called_once_with(self.context,
new_attachment_id)
mock_attach_delete.assert_called_once_with(self.context,
new_attachment_id)
self.assertEqual(bdm.attachment_id, orig_attachment_id)
self.assertEqual(orig_attachment_id, bdm.connection_info)
bdm.save.assert_called_once_with()

+ 5
- 5
nova/tests/unit/pci/test_utils.py View File

@@ -289,15 +289,15 @@ class GetNetNameByVfPciAddressTestCase(test.NoDBTestCase):
self.mock_get_ifname.return_value = self.if_name
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
self.assertEqual(ref_net_name, net_name)
self.mock_get_mac.called_once_with(self.pci_address)
self.mock_get_ifname.called_once_with(self.pci_address)
self.mock_get_mac.assert_called_once_with(self.pci_address)
self.mock_get_ifname.assert_called_once_with(self.pci_address)

def test_wrong_mac(self):
self.mock_get_mac.side_effect = (
exception.PciDeviceNotFoundById(self.pci_address))
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
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()

def test_wrong_ifname(self):
@@ -306,5 +306,5 @@ class GetNetNameByVfPciAddressTestCase(test.NoDBTestCase):
exception.PciDeviceNotFoundById(self.pci_address))
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
self.assertIsNone(net_name)
self.mock_get_mac.called_once_with(self.pci_address)
self.mock_get_ifname.called_once_with(self.pci_address)
self.mock_get_mac.assert_called_once_with(self.pci_address)
self.mock_get_ifname.assert_called_once_with(self.pci_address)

+ 8
- 11
nova/tests/unit/virt/libvirt/test_driver.py View File

@@ -7121,8 +7121,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
drvr._disconnect_volume(self.context, connection_info, instance,
encryption=encryption)
drvr._host.delete_secret.assert_not_called()
mock_encryptor.detach_volume.called_once_with(self.context,
**encryption)
mock_encryptor.detach_volume.assert_called_once_with(**encryption)

@mock.patch.object(libvirt_driver.LibvirtDriver, '_detach_encryptor')
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
@@ -11739,9 +11738,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
self.assertEqual(info[1]['over_committed_disk_size'], 18146236825)

vdmock.XMLDesc.assert_called_once_with(0)
mock_qemu_img_info.called_once_with('/test/disk.local')
mock_stat.called_once_with('/test/disk')
mock_get_size.called_once_with('/test/disk')
mock_qemu_img_info.assert_called_once_with('/test/disk.local')
mock_stat.assert_called_once_with('/test/disk')
mock_get_size.assert_called_once_with('/test/disk')

def test_post_live_migration(self):
vol1_conn_info = {'data': {'test_data': mock.sentinel.vol1},
@@ -14454,8 +14453,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
"rxvlan", "txvlan"]
}
self.assertEqual(expect_vf, actualvf)
mock_get_net_name.called_once_with(parent_address)
mock_dev_lookup.called_once_with(dev_name)
mock_get_net_name.assert_called_once_with(parent_address)
mock_dev_lookup.assert_called_once_with(dev_name)

def test_get_pcidev_info(self):

@@ -16289,7 +16288,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
self.assertRaises(test.TestingException,
drvr._cleanup_failed_start,
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)
self.assertTrue(guest.poweroff.called)

@@ -18438,10 +18437,9 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
mock.patch.object(os.path, 'exists'),
mock.patch.object(libvirt_utils, 'get_instance_path'),
mock.patch.object(utils, 'execute'),
mock.patch.object(shutil, 'rmtree'),
mock.patch.object(drvr.image_backend, 'remove_snap')) as (
mock_volume_backed, mock_exists, mock_get_path,
mock_exec, mock_rmtree, mock_remove):
mock_exec, mock_remove):
mock_exists.return_value = True
mock_get_path.return_value = '/fake/inst'

@@ -18451,7 +18449,6 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
mock_exec.assert_called_once_with('rm', '-rf', '/fake/inst_resize',
delay_on_retry=True, attempts=5)
self.assertFalse(mock_remove.called)
mock_rmtree.called_once_with('/fake/inst')

def test_get_instance_disk_info_exception(self):
instance = self._create_instance()

+ 2
- 2
nova/tests/unit/virt/libvirt/test_vif.py View File

@@ -1076,7 +1076,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
'tap', run_as_root=True, check_exit_code=[0, 2, 254]),
mock.call('ip', 'link', 'set', 'tap-xxx-yyy-zzz', 'up',
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,
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
'NovaVMPort', self.vif_vrouter['devname'],
@@ -1099,7 +1099,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
multiqueue=True)

mock_plug_contrail.called_once_with(
mock_plug_contrail.assert_called_once_with(
instance.project_id, instance.uuid, instance.display_name,
self.vif_vrouter['id'], self.vif_vrouter['network']['id'],
'NovaVMPort', self.vif_vrouter['devname'],

Loading…
Cancel
Save