diff options
author | Zane Bitter <zbitter@redhat.com> | 2017-07-11 10:59:26 -0400 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2017-07-21 10:44:51 -0400 |
commit | b0916ad5bb458a69f860fc0ebc1cc257a2020838 (patch) | |
tree | 7157d31c327e2065f6e14f1c0dec2904d3650c5a /heat/tests/test_rsrc_defn.py | |
parent | 6b6d3779cd23c188c808387b9f4095ea75da3284 (diff) | |
download | heat-b0916ad5bb458a69f860fc0ebc1cc257a2020838.tar.gz |
Cache names of required resources in ResourceDefinition
In order to calculate the dependencies of a ResourceDefinition, we have to
pass it a Stack object. This means we can't infer anything about the
resource's dependencies without instantiating the whole stack, and it means
we can't easily cache the result so we have to walk the entire
properties/metadata every time we need the dependencies.
This change splits a required_resource_names() method (the same as added to
OutputDefinition in the previous patch) out of the dependencies() method.
This new method calculates as much as we can know from the resource
definition alone and caches the result, while the dependencies() method
uses the (cached) result to calculate the graph dependencies for a given
Stack.
This also opens the way in future to changing the Function API to return
dependencies by name instead of as ResourceProxy objects.
Change-Id: Icdd0b2dd41116adae5e57ff3ef0e662ba75e6e2c
Diffstat (limited to 'heat/tests/test_rsrc_defn.py')
-rw-r--r-- | heat/tests/test_rsrc_defn.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/heat/tests/test_rsrc_defn.py b/heat/tests/test_rsrc_defn.py index 37f505c44..9109e10db 100644 --- a/heat/tests/test_rsrc_defn.py +++ b/heat/tests/test_rsrc_defn.py @@ -92,11 +92,13 @@ class ResourceDefinitionTest(common.HeatTestCase): def test_dependencies_default(self): rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType') stack = {'foo': 'FOO', 'bar': 'BAR'} + self.assertEqual(set(), rd.required_resource_names()) self.assertEqual([], list(rd.dependencies(stack))) def test_dependencies_explicit(self): rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType', depends=['foo']) stack = {'foo': 'FOO', 'bar': 'BAR'} + self.assertEqual({'foo'}, rd.required_resource_names()) self.assertEqual(['FOO'], list(rd.dependencies(stack))) def test_dependencies_explicit_ext(self): @@ -117,6 +119,7 @@ class ResourceDefinitionTest(common.HeatTestCase): t = template_format.parse(TEMPLATE_WITH_INVALID_EXPLICIT_DEPEND) stack = utils.parse_stack(t) rd = stack.t.resource_definitions(stack)['test3'] + self.assertEqual({'test2'}, rd.required_resource_names()) self.assertRaises(exception.InvalidTemplateReference, lambda: list(rd.dependencies(stack))) |