summaryrefslogtreecommitdiffstats
path: root/nova/tests/conductor
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2013-06-18 21:13:01 +0000
committerDan Smith <danms@us.ibm.com>2013-06-20 19:07:26 -0700
commita02766e28101381207ea7a48396a9448ca610348 (patch)
treebc4a2700d59508dfd76d1513dedad6d1cea86516 /nova/tests/conductor
parent022bd8d6c16a1a06a3996f1fa827bc17b4272af7 (diff)
downloadnova-a02766e28101381207ea7a48396a9448ca610348.tar.gz
nova-a02766e28101381207ea7a48396a9448ca610348.tar.xz
nova-a02766e28101381207ea7a48396a9448ca610348.zip
Make sure instance_type has extra_specs
Make sure that when scheduling, the instance_type used in filters contains the 'extra_specs'. This is a bit ugly, but will get cleaned up with objects. Fixes bug 1192331 Change-Id: I3614f3a858840c9561b4e618fc30f3d3ae5ac689
Diffstat (limited to 'nova/tests/conductor')
-rw-r--r--nova/tests/conductor/test_conductor.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index 9bb2c00ec..a2a015313 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -1183,18 +1183,28 @@ class _BaseTaskTestCase(object):
def test_build_instances(self):
instance_type = flavors.get_default_flavor()
system_metadata = flavors.save_flavor_info({}, instance_type)
- # NOTE(alaski): instance_type -> system_metadata -> instance_type loses
- # some data (extra_specs) so we need both for testing.
- instance_type_extract = flavors.extract_flavor(
+ # NOTE(alaski): instance_type -> system_metadata -> instance_type
+ # loses some data (extra_specs). This build process is using
+ # scheduler/utils:build_request_spec() which extracts flavor from
+ # system_metadata and will re-query the DB for extra_specs.. so
+ # we need to test this properly
+ expected_instance_type = flavors.extract_flavor(
{'system_metadata': system_metadata})
+ expected_instance_type['extra_specs'] = 'fake-specs'
+
+ self.mox.StubOutWithMock(db, 'instance_type_extra_specs_get')
self.mox.StubOutWithMock(self.conductor_manager.scheduler_rpcapi,
'run_instance')
+
+ db.instance_type_extra_specs_get(
+ self.context,
+ instance_type['flavorid']).AndReturn('fake-specs')
self.conductor_manager.scheduler_rpcapi.run_instance(self.context,
request_spec={
'image': {'fake_data': 'should_pass_silently'},
'instance_properties': {'system_metadata': system_metadata,
'uuid': 'fakeuuid'},
- 'instance_type': instance_type_extract,
+ 'instance_type': expected_instance_type,
'instance_uuids': ['fakeuuid', 'fakeuuid2'],
'block_device_mapping': 'block_device_mapping',
'security_group': 'security_groups'},