diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-27 15:02:34 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-27 15:02:34 +0000 |
| commit | 218ecc090940c599dd5246eb078cbcf1868194fb (patch) | |
| tree | 3271ffc4f1da83a8a3493b9b13f22f0c2df4019a /nova/tests | |
| parent | ef5d5951d891171d385eefee7562383ef59cb6d3 (diff) | |
| parent | 01985dd44d1b29c7ad7cb0932a1d30f7b6fe1911 (diff) | |
Merge "Send a full instance in pre_live_migration."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 53 | ||||
| -rw-r--r-- | nova/tests/compute/test_rpcapi.py | 9 |
2 files changed, 34 insertions, 28 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 54e588f92..3bdc24c54 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1532,12 +1532,13 @@ class ComputeTestCase(BaseTestCase): """Confirm raising exception if instance doesn't have fixed_ip.""" # creating instance testdata context = self.context.elevated() - inst_ref = self._create_fake_instance() - inst_id = inst_ref["id"] + instance = jsonutils.to_primitive(self._create_fake_instance()) + inst_id = instance["id"] self.mox.ReplayAll() self.assertRaises(exception.FixedIpNotFoundForInstance, - self.compute.pre_live_migration, context, inst_id) + self.compute.pre_live_migration, context, + instance=instance) def test_pre_live_migration_works_correctly(self): """Confirm setup_compute_volume is called when volume is mounted.""" @@ -1548,38 +1549,40 @@ class ComputeTestCase(BaseTestCase): '_get_instance_nw_info', stupid) # creating instance testdata - inst_ref = self._create_fake_instance({'host': 'dummy'}) - inst_id = inst_ref['id'] + instance = jsonutils.to_primitive(self._create_fake_instance( + {'host': 'dummy'})) + inst_id = instance['id'] c = context.get_admin_context() nw_info = fake_network.fake_get_instance_nw_info(self.stubs) # creating mocks self.mox.StubOutWithMock(self.compute.driver, 'pre_live_migration') - self.compute.driver.pre_live_migration(mox.IsA(c), mox.IsA(inst_ref), + self.compute.driver.pre_live_migration(mox.IsA(c), mox.IsA(instance), {'block_device_mapping': []}, mox.IgnoreArg()) self.mox.StubOutWithMock(self.compute.driver, 'ensure_filtering_rules_for_instance') self.compute.driver.ensure_filtering_rules_for_instance( - mox.IsA(inst_ref), nw_info) + mox.IsA(instance), nw_info) # start test self.mox.ReplayAll() - ret = self.compute.pre_live_migration(c, inst_id) + ret = self.compute.pre_live_migration(c, instance=instance) self.assertEqual(ret, None) # cleanup - db.instance_destroy(c, inst_ref['uuid']) + db.instance_destroy(c, instance['uuid']) def test_live_migration_dest_raises_exception(self): """Confirm exception when pre_live_migration fails.""" # creating instance testdata - inst_ref = self._create_fake_instance({'host': 'dummy'}) - inst_uuid = inst_ref['uuid'] - inst_id = inst_ref['id'] + instance_ref = self._create_fake_instance({'host': 'dummy'}) + instance = jsonutils.to_primitive(instance_ref) + inst_uuid = instance['uuid'] + inst_id = instance['id'] c = context.get_admin_context() - topic = rpc.queue_get_for(c, FLAGS.compute_topic, inst_ref['host']) + topic = rpc.queue_get_for(c, FLAGS.compute_topic, instance['host']) # creating volume testdata volume_id = db.volume_create(c, {'size': 1})['id'] @@ -1595,12 +1598,12 @@ class ComputeTestCase(BaseTestCase): self.mox.StubOutWithMock(self.compute.driver, 'get_instance_disk_info') - self.compute.driver.get_instance_disk_info(inst_ref.name) + self.compute.driver.get_instance_disk_info(instance['name']) self.mox.StubOutWithMock(self.compute.compute_rpcapi, 'pre_live_migration') - self.compute.compute_rpcapi.pre_live_migration(c, mox.IsA(inst_ref), - True, None, inst_ref['host']).AndRaise( + self.compute.compute_rpcapi.pre_live_migration(c, + mox.IsA(instance_ref), True, None, instance['host']).AndRaise( rpc.common.RemoteError('', '', '')) # mocks for rollback @@ -1622,7 +1625,7 @@ class ComputeTestCase(BaseTestCase): self.mox.ReplayAll() self.assertRaises(rpc_common.RemoteError, self.compute.live_migration, - c, inst_id, inst_ref['host'], True) + c, inst_id, instance['host'], True) # cleanup for bdms in db.block_device_mapping_get_all_by_instance( @@ -1635,24 +1638,26 @@ class ComputeTestCase(BaseTestCase): """Confirm live_migration() works as expected correctly.""" # creating instance testdata c = context.get_admin_context() - inst_ref = self._create_fake_instance({'host': 'dummy'}) - inst_uuid = inst_ref['uuid'] - inst_id = inst_ref['id'] + 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)) # create self.mox.StubOutWithMock(rpc, 'call') - topic = rpc.queue_get_for(c, FLAGS.compute_topic, inst_ref['host']) + topic = rpc.queue_get_for(c, FLAGS.compute_topic, instance['host']) rpc.call(c, topic, {"method": "pre_live_migration", - "args": {'instance_id': inst_id, + "args": {'instance': instance, 'block_migration': False, 'disk': None}, - "version": compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION}, + "version": '1.23'}, None) # start test self.mox.ReplayAll() - ret = self.compute.live_migration(c, inst_id, inst_ref['host']) + ret = self.compute.live_migration(c, inst_id, instance['host']) self.assertEqual(ret, None) # cleanup diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 7f8d02871..8620f81be 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -56,8 +56,9 @@ class ComputeRpcAPITestCase(test.TestCase): 'get_console_output', 'get_diagnostics', 'get_vnc_console', 'inject_file', 'inject_network_info', 'pause_instance', 'post_live_migration_at_destination', 'power_off_instance', - 'power_on_instance', 'reboot_instance', 'start_instance', - 'stop_instance', 'suspend_instance', 'unpause_instance' + 'power_on_instance', 'pre_live_migration', 'reboot_instance', + 'start_instance', 'stop_instance', 'suspend_instance', + 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -83,7 +84,7 @@ class ComputeRpcAPITestCase(test.TestCase): instance = expected_msg['args']['instance'] del expected_msg['args']['instance'] if method in ['rollback_live_migration_at_destination', - 'pre_live_migration', 'remove_volume_connection']: + 'remove_volume_connection']: expected_msg['args']['instance_id'] = instance['id'] else: expected_msg['args']['instance_uuid'] = instance['uuid'] @@ -224,7 +225,7 @@ class ComputeRpcAPITestCase(test.TestCase): def test_pre_live_migration(self): self._test_compute_api('pre_live_migration', 'call', instance=self.fake_instance, block_migration='block_migration', - disk='disk', host='host') + disk='disk', host='host', version='1.23') def test_reboot_instance(self): self._test_compute_api('reboot_instance', 'cast', |
