From 4b3ca6fbf3e89adfd92bdfcd02768f50152e68cf Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 27 Jul 2012 15:39:29 -0400 Subject: Send a full instance in reset_network. Change the reset_network method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: Iaae16e63da9d48d86e3bfc80f6c0cdb9f9bd3ddd --- nova/tests/compute/test_compute.py | 15 ++++++++++----- nova/tests/compute/test_rpcapi.py | 7 ++++--- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index de02a9d85..a6da5439c 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -707,19 +707,24 @@ class ComputeTestCase(BaseTestCase): def test_reset_network(self): """Ensure we can reset networking on an instance""" - called = {'reset': False} + called = {'count': 0} def fake_driver_reset_network(self, instance): - called['reset'] = True + called['count'] += 1 self.stubs.Set(nova.virt.fake.FakeDriver, 'reset_network', fake_driver_reset_network) - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) instance_uuid = instance['uuid'] self.compute.run_instance(self.context, instance_uuid) - self.compute.reset_network(self.context, instance_uuid) - self.assertTrue(called['reset']) + + # Make sure it works with both an instance and instance_uuid + self.compute.reset_network(self.context, instance=instance) + self.compute.reset_network(self.context, instance_uuid=instance_uuid) + + self.assertEqual(called['count'], 2) + self.compute.terminate_instance(self.context, instance_uuid) def test_agent_update(self): diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 27d379eed..0ab62d76a 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -58,8 +58,9 @@ class ComputeRpcAPITestCase(test.TestCase): 'post_live_migration_at_destination', 'power_off_instance', 'power_on_instance', 'pre_live_migration', 'reboot_instance', 'rebuild_instance', 'remove_fixed_ip_from_instance', - 'remove_volume_connection', 'rescue_instance', 'start_instance', - 'stop_instance', 'suspend_instance', 'unpause_instance' + 'remove_volume_connection', 'rescue_instance', 'reset_network', + 'start_instance', 'stop_instance', 'suspend_instance', + 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -271,7 +272,7 @@ class ComputeRpcAPITestCase(test.TestCase): def test_reset_network(self): self._test_compute_api('reset_network', 'cast', - instance=self.fake_instance) + instance=self.fake_instance, version='1.28') def test_resize_instance(self): self._test_compute_api('resize_instance', 'cast', -- cgit From 9302771de4324ac86aad4a8ec0dfe13d4ec3a0cc Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 27 Jul 2012 16:14:00 -0400 Subject: Send a full instance in resize_instance. Change the resize_instance method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: I5ed8707b2d018559ab4e983f8528dac8377783c7 --- nova/tests/compute/test_compute.py | 22 +++++++++++----------- nova/tests/compute/test_rpcapi.py | 7 ++++--- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index a6da5439c..831763f13 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1206,8 +1206,8 @@ class ComputeTestCase(BaseTestCase): migration_ref = db.migration_get_by_instance_and_status(context, instance['uuid'], 'pre-migrating') - self.compute.resize_instance(context, instance['uuid'], - migration_ref['id'], {}) + self.compute.resize_instance(context, migration_ref['id'], {}, + instance=instance) timeutils.set_time_override(cur_time) test_notifier.NOTIFICATIONS = [] @@ -1304,7 +1304,7 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(self.compute.driver, 'migrate_disk_and_power_off', throw_up) - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) context = self.context.elevated() self.compute.run_instance(self.context, instance['uuid']) @@ -1316,7 +1316,7 @@ class ComputeTestCase(BaseTestCase): #verify self.assertRaises(test.TestingException, self.compute.resize_instance, - context, instance['uuid'], migration_ref['id'], {}) + context, migration_ref['id'], {}, instance=instance) instance = db.instance_get_by_uuid(context, instance['uuid']) self.assertEqual(instance['vm_state'], vm_states.ERROR) @@ -1324,7 +1324,7 @@ class ComputeTestCase(BaseTestCase): def test_resize_instance(self): """Ensure instance can be migrated/resized""" - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) context = self.context.elevated() self.compute.run_instance(self.context, instance['uuid']) @@ -1334,8 +1334,8 @@ class ComputeTestCase(BaseTestCase): filter_properties={}) migration_ref = db.migration_get_by_instance_and_status(context, instance['uuid'], 'pre-migrating') - self.compute.resize_instance(context, instance['uuid'], - migration_ref['id'], {}) + self.compute.resize_instance(context, migration_ref['id'], {}, + instance=instance) self.compute.terminate_instance(context, instance['uuid']) def test_finish_revert_resize(self): @@ -1368,8 +1368,8 @@ class ComputeTestCase(BaseTestCase): migration_ref = db.migration_get_by_instance_and_status(context, inst_ref['uuid'], 'pre-migrating') - self.compute.resize_instance(context, inst_ref['uuid'], - migration_ref['id'], {}) + self.compute.resize_instance(context, migration_ref['id'], {}, + instance=jsonutils.to_primitive(inst_ref)) self.compute.finish_resize(context, migration_id=int(migration_ref['id']), disk_info={}, image={}, instance=jsonutils.to_primitive(inst_ref)) @@ -1421,7 +1421,7 @@ class ComputeTestCase(BaseTestCase): 'migrate_disk_and_power_off', raise_migration_failure) - inst_ref = self._create_fake_instance() + inst_ref = jsonutils.to_primitive(self._create_fake_instance()) context = self.context.elevated() self.compute.run_instance(self.context, inst_ref['uuid']) @@ -1431,7 +1431,7 @@ class ComputeTestCase(BaseTestCase): migration_ref = db.migration_get_by_instance_and_status(context, inst_ref['uuid'], 'pre-migrating') self.assertRaises(test.TestingException, self.compute.resize_instance, - context, inst_ref['uuid'], migration_ref['id'], {}) + context, migration_ref['id'], {}, instance=inst_ref) inst_ref = db.instance_get_by_uuid(context, inst_ref['uuid']) self.assertEqual(inst_ref['vm_state'], vm_states.ERROR) self.compute.terminate_instance(context, inst_ref['uuid']) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 0ab62d76a..8defc7608 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -59,8 +59,8 @@ class ComputeRpcAPITestCase(test.TestCase): 'power_on_instance', 'pre_live_migration', 'reboot_instance', 'rebuild_instance', 'remove_fixed_ip_from_instance', 'remove_volume_connection', 'rescue_instance', 'reset_network', - 'start_instance', 'stop_instance', 'suspend_instance', - 'unpause_instance' + 'resize_instance', 'start_instance', 'stop_instance', + 'suspend_instance', 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -276,7 +276,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_resize_instance(self): self._test_compute_api('resize_instance', 'cast', - instance=self.fake_instance, migration_id='id', image='image') + instance=self.fake_instance, migration_id='id', image='image', + version='1.29') def test_resume_instance(self): self._test_compute_api('resume_instance', 'cast', -- cgit From 564def16ba2b684c0fbdaef1861b5fddd9ed4b5c Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 30 Jul 2012 11:26:25 -0400 Subject: Send a full instance in resume_instance. Change the resume_instance method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: I57789eab047de7ff9b84e2bb5367139a9a7b8e40 --- nova/tests/compute/test_compute.py | 7 +++---- nova/tests/compute/test_rpcapi.py | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 831763f13..4e1c57201 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -499,12 +499,11 @@ class ComputeTestCase(BaseTestCase): def test_suspend(self): """ensure instance can be suspended and resumed""" - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) instance_uuid = instance['uuid'] self.compute.run_instance(self.context, instance_uuid) - self.compute.suspend_instance(self.context, - instance=jsonutils.to_primitive(instance)) - self.compute.resume_instance(self.context, instance_uuid) + self.compute.suspend_instance(self.context, instance=instance) + self.compute.resume_instance(self.context, instance=instance) self.compute.terminate_instance(self.context, instance_uuid) def test_suspend_error(self): diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 8defc7608..f47d081be 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -59,8 +59,8 @@ class ComputeRpcAPITestCase(test.TestCase): 'power_on_instance', 'pre_live_migration', 'reboot_instance', 'rebuild_instance', 'remove_fixed_ip_from_instance', 'remove_volume_connection', 'rescue_instance', 'reset_network', - 'resize_instance', 'start_instance', 'stop_instance', - 'suspend_instance', 'unpause_instance' + 'resize_instance', 'resume_instance', 'start_instance', + 'stop_instance', 'suspend_instance', 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -281,7 +281,7 @@ class ComputeRpcAPITestCase(test.TestCase): def test_resume_instance(self): self._test_compute_api('resume_instance', 'cast', - instance=self.fake_instance) + instance=self.fake_instance, version='1.30') def test_revert_resize(self): self._test_compute_api('revert_resize', 'cast', -- cgit From 3359e31b204c9a3ac0f4d8bc400a3d7c4c3c081f Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 30 Jul 2012 11:43:48 -0400 Subject: Send a full instance in revert_resize. Change the revert_resize method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: I55bdc63149c0385fbf151f4f86f40e6c7635cf63 --- nova/tests/compute/test_compute.py | 8 ++++---- nova/tests/compute/test_rpcapi.py | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 4e1c57201..36d001966 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1380,11 +1380,11 @@ class ComputeTestCase(BaseTestCase): self.assertEqual(instance_type_ref['flavorid'], '3') # Finally, revert and confirm the old flavor has been applied - self.compute.revert_resize(context, inst_ref['uuid'], - migration_ref['id']) + rpcinst = jsonutils.to_primitive(inst_ref) + self.compute.revert_resize(context, + migration_id=migration_ref['id'], instance=rpcinst) self.compute.finish_revert_resize(context, - migration_id=migration_ref['id'], - instance=jsonutils.to_primitive(inst_ref)) + migration_id=migration_ref['id'], instance=rpcinst) instance = db.instance_get_by_uuid(context, instance['uuid']) self.assertEqual(instance['vm_state'], vm_states.ACTIVE) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index f47d081be..7a1195fe0 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -59,8 +59,9 @@ class ComputeRpcAPITestCase(test.TestCase): 'power_on_instance', 'pre_live_migration', 'reboot_instance', 'rebuild_instance', 'remove_fixed_ip_from_instance', 'remove_volume_connection', 'rescue_instance', 'reset_network', - 'resize_instance', 'resume_instance', 'start_instance', - 'stop_instance', 'suspend_instance', 'unpause_instance' + 'resize_instance', 'resume_instance', 'revert_resize', + 'start_instance', 'stop_instance', 'suspend_instance', + 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -285,7 +286,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_revert_resize(self): self._test_compute_api('revert_resize', 'cast', - instance=self.fake_instance, migration_id='id', host='host') + instance=self.fake_instance, migration_id='id', host='host', + version='1.31') def test_rollback_live_migration_at_destination(self): self._test_compute_api('rollback_live_migration_at_destination', -- cgit