From 1f4df7c7ad27b23773ad9cdbe4db1632ce388cf1 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Mon, 17 Dec 2018 12:43:02 -0800 Subject: [VVP] updating validation scripts in dublin - adding backlog of new validation scripts for dublin - updating existing tests - removing outdated tests Issue-ID: VVP-123 Change-Id: Ib8260889ac957c1dd28d8ede450fc8edc6fb0ec0 Signed-off-by: stark, steven --- .../tests/test_volume_templates_outputs.py | 45 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'ice_validator/tests/test_volume_templates_outputs.py') 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 + ) -- cgit 1.2.3-korg