From 057138540df2b067bd3cd2857cceb97d1ecd86d0 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 2 Nov 2011 10:58:45 -0700 Subject: APIs should not wait on scheduler for builds in single zone deployment Fixes bug 885349 We can short circuit waiting on the scheduler if we're in a single zone deployment and only building 1 instance. This patch checks for that case and creates the instance DB entry directly in the API (in compute/api) without the call to the scheduler. Change-Id: I98b27156167f057d11fbc56a9ff99d4e2ec423d3 --- nova/tests/api/ec2/test_cloud.py | 5 +++-- nova/tests/api/openstack/test_servers.py | 8 +++++--- nova/tests/test_compute.py | 19 ------------------- 3 files changed, 8 insertions(+), 24 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index c0f3d44d7..f76690831 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -1013,8 +1013,6 @@ class CloudTestCase(test.TestCase): self.assertDictListUnorderedMatch(result['blockDeviceMapping'], self._expected_bdms2, 'deviceName') - self.stubs.UnsetAll() - def test_describe_image_attribute(self): describe_image_attribute = self.cloud.describe_image_attribute @@ -1216,6 +1214,9 @@ class CloudTestCase(test.TestCase): self.stubs.UnsetAll() self.stubs.Set(fake._FakeImageService, 'show', fake_show) + # NOTE(comstud): Make 'cast' behave like a 'call' which will + # ensure that operations complete + self.stubs.Set(rpc, 'cast', rpc.call) result = run_instances(self.context, **kwargs) instance = result['instancesSet'][0] diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 4518ef8e2..31c87e630 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -1354,7 +1354,7 @@ class ServersControllerCreateTest(test.TestCase): self.instance_cache_num += 1 instance = { 'id': self.instance_cache_num, - 'display_name': 'server_test', + 'display_name': inst['display_name'] or 'test', 'uuid': FAKE_UUID, 'instance_type': dict(inst_type), 'access_ip_v4': '1.2.3.4', @@ -1390,8 +1390,10 @@ class ServersControllerCreateTest(test.TestCase): request_spec['instance_properties'])) return instances - def server_update(context, id, params): - return instance_create(context, id) + def server_update(context, instance_id, params): + inst = self.instance_cache[instance_id] + inst.update(params) + return inst def fake_method(*args, **kwargs): pass diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index addb6084d..7295c9f1f 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1409,25 +1409,6 @@ class ComputeTestCase(test.TestCase): self.assertEqual(instance['reservation_id'], resv_id) db.instance_destroy(self.context, instance['id']) - def test_reservation_ids_two_instances_no_wait(self): - """Verify building 2 instances at once without waiting for - instance IDs results in a reservation_id being returned equal - to reservation id set in both instances - """ - (refs, resv_id) = self.compute_api.create(self.context, - instance_types.get_default_instance_type(), None, - min_count=2, max_count=2, wait_for_instances=False) - try: - self.assertEqual(refs, None) - self.assertNotEqual(resv_id, None) - finally: - instances = self.compute_api.get_all(self.context, - search_opts={'reservation_id': resv_id}) - self.assertEqual(len(instances), 2) - for instance in instances: - self.assertEqual(instance['reservation_id'], resv_id) - db.instance_destroy(self.context, instance['id']) - def test_create_with_specified_reservation_id(self): """Verify building instances with a specified reservation_id results in the correct reservation_id -- cgit