@@ -13338,9 +13338,11 @@ def test_live_migration_monitor_force_complete_postcopy(self,
13338
13338
@mock.patch.object(fakelibvirt.Connection, "_mark_running")
13339
13339
@mock.patch.object(libvirt_driver.LibvirtDriver,
13340
13340
"_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):
13344
13346
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
13345
13347
instance = objects.Instance(**self.test_instance)
13346
13348
@@ -13353,16 +13355,23 @@ def test_live_migration_main(self, mock_copy_disk_path, mock_running,
13353
13355
mock_copy_disk_path.return_value = disks_to_copy
13354
13356
13355
13357
mock_guest.return_value = guest
13358
+ mock_monitor.side_effect = mon_side_effect
13356
13359
13357
13360
def fake_post():
13358
13361
pass
13359
13362
13360
13363
def fake_recover():
13361
13364
pass
13362
13365
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
+
13366
13375
mock_copy_disk_path.assert_called_once_with(self.context, instance,
13367
13376
guest)
13368
13377
@@ -13379,6 +13388,12 @@ def __eq__(self, other):
13379
13388
fake_post, fake_recover, True,
13380
13389
migrate_data, AnyEventletEvent(), disks_to_copy[0])
13381
13390
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
+
13382
13397
@mock.patch('os.path.exists', return_value=False)
13383
13398
@mock.patch('nova.virt.libvirt.utils.create_image')
13384
13399
@mock.patch.object(libvirt_driver.LibvirtDriver,
0 commit comments