@@ -13338,9 +13338,11 @@ def test_live_migration_monitor_force_complete_postcopy(self,
1333813338 @mock.patch.object(fakelibvirt.Connection, "_mark_running")
1333913339 @mock.patch.object(libvirt_driver.LibvirtDriver,
1334013340 "_live_migration_copy_disk_paths")
13341- def test_live_migration_main(self, mock_copy_disk_path, mock_running,
13342- mock_guest, mock_monitor, mock_thread,
13343- mock_conn):
13341+ @mock.patch.object(libvirt_driver.LibvirtDriver, "live_migration_abort")
13342+ def _test_live_migration_main(self, mock_abort, mock_copy_disk_path,
13343+ mock_running, mock_guest, mock_monitor,
13344+ mock_thread, mock_conn,
13345+ mon_side_effect=None):
1334413346 drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
1334513347 instance = objects.Instance(**self.test_instance)
1334613348
@@ -13353,16 +13355,23 @@ def test_live_migration_main(self, mock_copy_disk_path, mock_running,
1335313355 mock_copy_disk_path.return_value = disks_to_copy
1335413356
1335513357 mock_guest.return_value = guest
13358+ mock_monitor.side_effect = mon_side_effect
1335613359
1335713360 def fake_post():
1335813361 pass
1335913362
1336013363 def fake_recover():
1336113364 pass
1336213365
13363- drvr._live_migration(self.context, instance, "fakehost",
13364- fake_post, fake_recover, True,
13365- migrate_data)
13366+ if mon_side_effect:
13367+ self.assertRaises(mon_side_effect, drvr._live_migration,
13368+ self.context, instance, "fakehost", fake_post,
13369+ fake_recover, True, migrate_data)
13370+ mock_abort.assert_called_once_with(instance)
13371+ else:
13372+ drvr._live_migration(self.context, instance, "fakehost", fake_post,
13373+ fake_recover, True, migrate_data)
13374+
1336613375 mock_copy_disk_path.assert_called_once_with(self.context, instance,
1336713376 guest)
1336813377
@@ -13379,6 +13388,12 @@ def __eq__(self, other):
1337913388 fake_post, fake_recover, True,
1338013389 migrate_data, AnyEventletEvent(), disks_to_copy[0])
1338113390
13391+ def test_live_migration_main(self):
13392+ self._test_live_migration_main()
13393+
13394+ def test_live_migration_main_monitoring_failed(self):
13395+ self._test_live_migration_main(mon_side_effect=Exception)
13396+
1338213397 @mock.patch('os.path.exists', return_value=False)
1338313398 @mock.patch('nova.virt.libvirt.utils.create_image')
1338413399 @mock.patch.object(libvirt_driver.LibvirtDriver,
0 commit comments