diff options
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 1 | ||||
| -rw-r--r-- | nova/tests/test_db_api.py | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 451fc3d87..9465816ed 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3980,6 +3980,7 @@ class ComputeAPITestCase(BaseTestCase): instance = self._create_fake_instance(dict(host='host2')) instance = db.instance_get_by_uuid(self.context, instance['uuid']) instance = jsonutils.to_primitive(instance) + instance['instance_type']['extra_specs'] = [] orig_instance_type = instance['instance_type'] self.compute.run_instance(self.context, instance=instance) # We need to set the host to something 'known'. Unfortunately, diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 92eae023a..0b0fed805 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -304,6 +304,41 @@ class DbApiTestCase(test.TestCase): self.assertEquals("building", old_ref["vm_state"]) self.assertEquals("needscoffee", new_ref["vm_state"]) + def test_instance_update_with_extra_specs(self): + """Ensure _extra_specs are returned from _instance_update""" + ctxt = context.get_admin_context() + + # create a flavor + inst_type_dict = dict( + name="test_flavor", + memory_mb=1, + vcpus=1, + root_gb=1, + ephemeral_gb=1, + flavorid=105) + inst_type_ref = db.instance_type_create(ctxt, inst_type_dict) + + # add some extra spec to our flavor + spec = {'test_spec': 'foo'} + db.instance_type_extra_specs_update_or_create( + ctxt, + inst_type_ref['flavorid'], + spec) + + # create instance, just populates db, doesn't pull extra_spec + instance = db.instance_create( + ctxt, + {'instance_type_id': inst_type_ref['id']}) + self.assertNotIn('extra_specs', instance) + + # update instance, used when starting instance to set state, etc + (old_ref, new_ref) = db.instance_update_and_get_original( + ctxt, + instance['uuid'], + {}) + self.assertEquals(spec, old_ref['extra_specs']) + self.assertEquals(spec, new_ref['extra_specs']) + def test_instance_fault_create(self): """Ensure we can create an instance fault""" ctxt = context.get_admin_context() |
