Merge "Avoid redundant validations"
This commit is contained in:
commit
f1b53ea325
@ -828,7 +828,14 @@ class Stack(collections.Mapping):
|
||||
else:
|
||||
iter_rsc = six.itervalues(resources)
|
||||
|
||||
unique_definitions = set(res.t for res in six.itervalues(resources))
|
||||
unique_defn_names = set(defn.name for defn in unique_definitions)
|
||||
|
||||
for res in iter_rsc:
|
||||
# Don't validate identical definitions multiple times
|
||||
if res.name not in unique_defn_names:
|
||||
continue
|
||||
|
||||
try:
|
||||
if self.resource_validate:
|
||||
result = res.validate()
|
||||
|
@ -2715,9 +2715,15 @@ class StackTest(common.HeatTestCase):
|
||||
with mock.patch('heat.engine.stack.dependencies',
|
||||
new_callable=mock.PropertyMock) as mock_dependencies:
|
||||
mock_dependency = mock.MagicMock()
|
||||
mock_dependency.name = 'res'
|
||||
mock_dependency.validate.side_effect = AssertionError(expected_msg)
|
||||
mock_dependencies.Dependencies.return_value = [mock_dependency]
|
||||
stc = stack.Stack(self.ctx, utils.random_name(), self.tmpl)
|
||||
mock_res = mock.Mock()
|
||||
mock_res.name = mock_dependency.name
|
||||
mock_res.t = mock.Mock()
|
||||
mock_res.t.name = mock_res.name
|
||||
stc._resources = {mock_res.name: mock_res}
|
||||
expected_exception = self.assertRaises(AssertionError,
|
||||
stc.validate)
|
||||
self.assertEqual(expected_msg, six.text_type(expected_exception))
|
||||
|
Loading…
Reference in New Issue
Block a user