summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-01-02 13:07:04 -0800
committerDan Smith <danms@us.ibm.com>2013-01-04 08:11:36 -0800
commite034a126dade15f05014f6a9eb85562f59714f63 (patch)
tree68d098f335791e298a565dd4fd4f3d442d6d7c9c /nova/tests
parent10daa81057b2cfc0a3e21624b50b0b5d610b4db2 (diff)
Remove system_metadata db calls from compute manager
The compute/manager makes several unnecessary db calls to fetch the instance system_metadata, which is available in the instance object itself now. This patch replaces those uses, avoiding the need to farm them out to conductor. Related to bp/no-db-compute Related to bp/no-db-compute-manager Change-Id: I26ff77be17eb538a4fcd238ffe52f8bde4fbe3e0
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute_utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute_utils.py b/nova/tests/compute/test_compute_utils.py
index b3f7ea3df..5acc1cc53 100644
--- a/nova/tests/compute/test_compute_utils.py
+++ b/nova/tests/compute/test_compute_utils.py
@@ -260,6 +260,7 @@ class UsageInfoTestCase(test.TestCase):
'other_data': 'meow'}
db.instance_system_metadata_update(self.context, instance['uuid'],
sys_metadata, False)
+ instance = db.instance_get(self.context, instance_id)
compute_utils.notify_usage_exists(self.context, instance)
self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
msg = test_notifier.NOTIFICATIONS[0]
@@ -378,3 +379,14 @@ class UsageInfoTestCase(test.TestCase):
image_ref_url = "%s/images/1" % utils.generate_glance_url()
self.assertEquals(payload['image_ref_url'], image_ref_url)
self.compute.terminate_instance(self.context, instance)
+
+
+class MetadataToDictTestCase(test.TestCase):
+ def test_metadata_to_dict(self):
+ self.assertEqual(compute_utils.metadata_to_dict(
+ [{'key': 'foo1', 'value': 'bar'},
+ {'key': 'foo2', 'value': 'baz'}]),
+ {'foo1': 'bar', 'foo2': 'baz'})
+
+ def test_metadata_to_dict_empty(self):
+ self.assertEqual(compute_utils.metadata_to_dict([]), {})