summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2012-06-25 21:14:11 +0000
committerChris Behrens <cbehrens@codestud.com>2012-06-26 01:51:46 +0000
commit936140de2c42b8e1b4cf1edde1e6fb25bcd75c59 (patch)
treedc1ee9ae9d94ea10eb1cd37660fcfd2b52391931 /nova/tests
parentca1f1d39b8ee85f55d5b656f7db946f855be5cb2 (diff)
Re-factor instance DB creation
This patch speeds up the DB creation process considerably in deployments with a considerable amount of instances. It also cleans up a lot of the code which ends up creating the instance DB record. The biggest improvement in this patch is removing unnecessary joins in security_groups DB calls. This also reduces the number of DB calls needed to create an instance DB record in general. Side effect of this patch is the default 'display_name' for an instance when it (or hostname) is not specified is now 'Server <uuid>' vs 'Server <id>'. Because of the use of 'id', it required creating the DB record, then updating the record later after we new the 'id'. This is gone. Fixes bug 1017722 Change-Id: I9b7d48644a7abe075545c2c11399351b6a37939c
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index c816acc95..e77b0fcdb 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -2159,7 +2159,20 @@ class ComputeAPITestCase(BaseTestCase):
len(db.instance_get_all(context.get_admin_context())))
def test_default_hostname_generator(self):
- cases = [(None, 'server-1'), ('Hello, Server!', 'hello-server'),
+ fake_uuids = [str(utils.gen_uuid()) for x in xrange(4)]
+
+ orig_populate = self.compute_api._populate_instance_for_create
+
+ def _fake_populate(base_options, *args, **kwargs):
+ base_options['uuid'] = fake_uuids.pop(0)
+ return orig_populate(base_options, *args, **kwargs)
+
+ self.stubs.Set(self.compute_api,
+ '_populate_instance_for_create',
+ _fake_populate)
+
+ cases = [(None, 'server-%s' % fake_uuids[0]),
+ ('Hello, Server!', 'hello-server'),
('<}\x1fh\x10e\x08l\x02l\x05o\x12!{>', 'hello'),
('hello_server', 'hello-server')]
for display_name, hostname in cases: