diff options
author | Crag Wolfe <cwolfe@redhat.com> | 2017-04-06 21:49:40 -0400 |
---|---|---|
committer | Crag Wolfe <cwolfe@redhat.com> | 2017-04-19 20:51:02 -0400 |
commit | 93fab308e8057ab95ca0e98a6515f2cf9648ed3e (patch) | |
tree | 00935047b75b636fe0270154258c15170f570d5f /heat/tests/test_resource.py | |
parent | 157ede194942673f162615e4748d1abdf87aeff2 (diff) | |
download | heat-93fab308e8057ab95ca0e98a6515f2cf9648ed3e.tar.gz |
Load "lighter" db resources when appropriate
Sometimes we know we will only access particular fields of a resource
object, rather than *all* of them. This commit allows the caller to
specify (optionally) the fields that should be populated when the
resource object is instantiated. This saves memory, trips to the db,
and in some cases avoids extra join queries (e.g. for resource.data or
resource.rsrc_prop_data).
Change-Id: I405888f46451d2657aa28f610f8ca555215ff5cf
Partial-Bug: #1680658
Diffstat (limited to 'heat/tests/test_resource.py')
-rw-r--r-- | heat/tests/test_resource.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index 714bb0d58..68c856a54 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -582,6 +582,16 @@ class ResourceTest(common.HeatTestCase): res.store() self.assertIsNotNone(res.updated_time) + def test_resource_object_get_obj_fields(self): + snippet = rsrc_defn.ResourceDefinition('aresource', + 'GenericResourceType') + res = resource.Resource('aresource', snippet, self.stack) + res.store() + res_obj = resource_objects.Resource.get_obj( + res.context, res.id, refresh=False, fields=('status', )) + self.assertEqual(res_obj.status, res.COMPLETE) + self.assertRaises(AttributeError, getattr, res_obj, 'action') + def test_resource_object_resource_properties_data(self): cfg.CONF.set_override('encrypt_parameters_and_properties', True, enforce_type=True) |