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