X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=blobdiff_plain;f=ice_validator%2Ftests%2Ftest_volume_templates_outputs.py;h=19fd1e978549cb96a09f279eccd05b7b1982df4f;hp=1a779c6386db8300b348c382b207fbbecae99718;hb=1f4df7c7ad27b23773ad9cdbe4db1632ce388cf1;hpb=ca9085f0f77d442d3741a8c754e65cc45b6a318d diff --git a/ice_validator/tests/test_volume_templates_outputs.py b/ice_validator/tests/test_volume_templates_outputs.py index 1a779c6..19fd1e9 100644 --- a/ice_validator/tests/test_volume_templates_outputs.py +++ b/ice_validator/tests/test_volume_templates_outputs.py @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # org.onap.vvp/validation-scripts # =================================================================== -# Copyright © 2018 AT&T Intellectual Property. All rights reserved. +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. # =================================================================== # # Unless otherwise specified, all software contained herein is licensed @@ -37,14 +37,51 @@ # # ECOMP is a trademark and service mark of AT&T Intellectual Property. # +import pytest from tests import cached_yaml as yaml +from .helpers import validates +@validates("R-89913") def test_volume_templates_contains_outputs(volume_template): - ''' + """ Check that all volume templates include outputs - ''' + """ with open(volume_template) as fh: yml = yaml.load(fh) - assert "outputs" in yml + + resources = yml.get("resources") + volume_resources = [] + invalid_resource_ids = [] + output_resources = [] + + if not resources: + pytest.skip("No resources detected in template") + + for rid, rprop in resources.items(): + rtype = rprop.get("type") + if not rtype: + continue + if rtype == "OS::Cinder::Volume": + volume_resources.append(rid) + + outputs = yml.get("outputs") + if not outputs: + pytest.fail("No outputs detected in volume template") + + for k1, v1 in outputs.items(): + output_value = v1.get("value", {}).get("get_resource") + if not output_value: + continue + output_resources.append(output_value) + + for rid in volume_resources: + if rid not in output_resources: + invalid_resource_ids.append(rid) + + assert ( + not invalid_resource_ids + ), "volumes resource IDs not found in outputs of volume module {}".format( + invalid_resource_ids + )