diff options
author | Jay Lau <jay.lau.513@gmail.com> | 2013-05-11 21:53:20 +0800 |
---|---|---|
committer | Jay Lau <jay.lau.513@gmail.com> | 2013-05-21 09:48:34 +0800 |
commit | fe8bddc0f25c78af3cd98ba06b0768f2a99b9093 (patch) | |
tree | 1a4c95f4831bcdff414f28b6506a0a776af11f95 /nova/tests | |
parent | eebcd6f2058d78c87dd2ee0a9a90f21f33f44e97 (diff) | |
download | nova-fe8bddc0f25c78af3cd98ba06b0768f2a99b9093.tar.gz nova-fe8bddc0f25c78af3cd98ba06b0768f2a99b9093.tar.xz nova-fe8bddc0f25c78af3cd98ba06b0768f2a99b9093.zip |
Add notification for live migration
Fix bug 1167759
Currently, if live migration failed, nova compute did not send
notification, this causes other services such as nova-scheduler
to have no chance to do some operations
The fix add notification logic for live_migration like other
VM instance operations such as resize, run instance etc.
Change-Id: Iaf61f5268e07284fd7d69ff331ce3bacd380c02b
Diffstat (limited to 'nova/tests')
-rw-r--r-- | nova/tests/compute/test_compute.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 3101e3aa2..3580d4839 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3493,6 +3493,7 @@ class ComputeTestCase(BaseTestCase): self.compute.driver.ensure_filtering_rules_for_instance( mox.IsA(instance), nw_info) + test_notifier.NOTIFICATIONS = [] # start test self.mox.ReplayAll() migrate_data = {'is_shared_storage': False} @@ -3500,6 +3501,13 @@ class ComputeTestCase(BaseTestCase): block_migration=False, migrate_data=migrate_data) self.assertEqual(ret, None) + self.assertEqual(len(test_notifier.NOTIFICATIONS), 2) + msg = test_notifier.NOTIFICATIONS[0] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.pre.start') + msg = test_notifier.NOTIFICATIONS[1] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.pre.end') # cleanup db.instance_destroy(c, instance['uuid']) @@ -3719,11 +3727,20 @@ class ComputeTestCase(BaseTestCase): self.compute.network_api.setup_networks_on_host(self.admin_ctxt, mox.IgnoreArg(), self.compute.host) + test_notifier.NOTIFICATIONS = [] self.mox.ReplayAll() self.compute.post_live_migration_at_destination(self.admin_ctxt, self.instance) + self.assertEqual(len(test_notifier.NOTIFICATIONS), 2) + msg = test_notifier.NOTIFICATIONS[0] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.post.dest.start') + msg = test_notifier.NOTIFICATIONS[1] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.post.dest.end') + return self.compute.conductor_api.instance_get_by_uuid(self.admin_ctxt, self.instance['uuid']) @@ -3749,6 +3766,31 @@ class ComputeTestCase(BaseTestCase): updated = self._finish_post_live_migration_at_destination() self.assertIsNone(updated['node']) + def test_rollback_live_migration_at_destination_correctly(self): + # creating instance testdata + c = context.get_admin_context() + instance_ref = self._create_fake_instance({'host': 'dummy'}) + inst_uuid = instance_ref['uuid'] + inst_id = instance_ref['id'] + + instance = jsonutils.to_primitive(db.instance_get(c, inst_id)) + test_notifier.NOTIFICATIONS = [] + # start test + self.mox.ReplayAll() + ret = self.compute.rollback_live_migration_at_destination(c, + instance=instance) + self.assertEqual(ret, None) + self.assertEqual(len(test_notifier.NOTIFICATIONS), 2) + msg = test_notifier.NOTIFICATIONS[0] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.rollback.dest.start') + msg = test_notifier.NOTIFICATIONS[1] + self.assertEqual(msg['event_type'], + 'compute.instance.live_migration.rollback.dest.end') + + # cleanup + db.instance_destroy(c, inst_uuid) + def test_run_kill_vm(self): # Detect when a vm is terminated behind the scenes. self.stubs.Set(compute_manager.ComputeManager, |