aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ice_validator/tests')
-rw-r--r--ice_validator/tests/fixtures/test_incremental_module/fail/base.yaml47
-rw-r--r--ice_validator/tests/fixtures/test_incremental_module/fail/incremental.yaml46
-rw-r--r--ice_validator/tests/fixtures/test_incremental_module/pass/pass0.yaml50
-rw-r--r--ice_validator/tests/fixtures/test_incremental_module/pass/pass0_base.yaml48
-rw-r--r--ice_validator/tests/test_environment_file_parameters.py44
-rw-r--r--ice_validator/tests/test_incremental_module.py59
6 files changed, 274 insertions, 20 deletions
diff --git a/ice_validator/tests/fixtures/test_incremental_module/fail/base.yaml b/ice_validator/tests/fixtures/test_incremental_module/fail/base.yaml
new file mode 100644
index 0000000..5e3cafd
--- /dev/null
+++ b/ice_validator/tests/fixtures/test_incremental_module/fail/base.yaml
@@ -0,0 +1,47 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+# VERSION: '1.0.0'
+
+---
+parameters:
+
+resources:
+
+ oam_network:
+ type: OS::Neutron::Net
diff --git a/ice_validator/tests/fixtures/test_incremental_module/fail/incremental.yaml b/ice_validator/tests/fixtures/test_incremental_module/fail/incremental.yaml
new file mode 100644
index 0000000..0a77436
--- /dev/null
+++ b/ice_validator/tests/fixtures/test_incremental_module/fail/incremental.yaml
@@ -0,0 +1,46 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+# VERSION: '1.0.0'
+
+---
+parameters:
+
+
+resources:
+
diff --git a/ice_validator/tests/fixtures/test_incremental_module/pass/pass0.yaml b/ice_validator/tests/fixtures/test_incremental_module/pass/pass0.yaml
new file mode 100644
index 0000000..3758c7a
--- /dev/null
+++ b/ice_validator/tests/fixtures/test_incremental_module/pass/pass0.yaml
@@ -0,0 +1,50 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+# VERSION: '1.0.0'
+
+---
+
+resources:
+
+ my_instance:
+ type: OS::Nova::Server
+ properties:
+ key_name: my_key
+ image: F18-x86_64-cfntools
+ flavor: m1.small
diff --git a/ice_validator/tests/fixtures/test_incremental_module/pass/pass0_base.yaml b/ice_validator/tests/fixtures/test_incremental_module/pass/pass0_base.yaml
new file mode 100644
index 0000000..420b06f
--- /dev/null
+++ b/ice_validator/tests/fixtures/test_incremental_module/pass/pass0_base.yaml
@@ -0,0 +1,48 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+# VERSION: '1.0.0'
+
+---
+parameters:
+
+resources:
+
+ oam_network:
+ type: OS::Neutron::Net
+
diff --git a/ice_validator/tests/test_environment_file_parameters.py b/ice_validator/tests/test_environment_file_parameters.py
index 9744b49..99d76a0 100644
--- a/ice_validator/tests/test_environment_file_parameters.py
+++ b/ice_validator/tests/test_environment_file_parameters.py
@@ -59,13 +59,13 @@ from tests.utils.nested_files import file_is_a_nested_template
# at the end of a property to make it a tuple.
ENV_PARAMETER_SPEC = {
"PLATFORM PROVIDED": [
- {"property": ("vnf_id",), "persistent": False, "kwargs": {}},
- {"property": ("vnf_name",), "persistent": False, "kwargs": {}},
- {"property": ("vf_module_id",), "persistent": False, "kwargs": {}},
- {"property": ("vf_module_index",), "persistent": False, "kwargs": {}},
- {"property": ("vf_module_name",), "persistent": False, "kwargs": {}},
- {"property": ("workload_context",), "persistent": False, "kwargs": {}},
- {"property": ("environment_context",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "vnf_id",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "vnf_name",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "vf_module_id",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "vf_module_index",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "vf_module_name",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "workload_context",), "persistent": False, "kwargs": {}},
+ {"property": ("metadata", "environment_context",), "persistent": False, "kwargs": {}},
{"property": (r"^(.+?)_net_fqdn$",), "persistent": False, "kwargs": {}},
],
"ALL": [{"property": ("name",), "persistent": False, "kwargs": {}}],
@@ -90,13 +90,13 @@ ENV_PARAMETER_SPEC = {
},
{"property": ("fixed_ips", "subnet"), "persistent": False, "kwargs": {}},
{
- "property": ("fixed_ips", "allowed_address_pairs"),
+ "property": ("allowed_address_pairs", "ip_address"),
"persistent": False,
"network_type": "external",
"kwargs": {"exclude_parameter": re.compile(r"^(.+?)_int_(.+?)$")},
},
{
- "property": ("fixed_ips", "allowed_address_pairs"),
+ "property": ("allowed_address_pairs", "ip_address"),
"persistent": True,
"network_type": "internal",
"kwargs": {"exclude_parameter": re.compile(r"^((?!_int_).)*$")},
@@ -234,21 +234,26 @@ def get_preload_excluded_parameters(yaml_file, persistent_only=False, env_spec=N
for spec in specs:
if persistent_only and not spec.get("persistent"):
continue
- results.extend(
- get_template_parameters(yaml_file, resource_type, spec, all_resources)
- )
- return {item["param"] for item in results}
-
-
-def get_template_parameters(yaml_file, resource_type, spec, all_resources=False):
+ results.extend(get_template_parameters(yaml_file, resource_type,
+ spec, all_resources, nested_resources=True))
+ results = {item["param"] for item in results}
+ for param in Heat(yaml_file).parameters:
+ # AZs often are manipulated and passed into nested templates making
+ # them difficult to detect by looking for the assignment. We'll
+ # just extract them from the parameters if they are there to be safe
+ if re.match(r"availability_zone_\d+", param):
+ results.add(param)
+ return results
+
+
+def get_template_parameters(yaml_file, resource_type, spec, all_resources=False, nested_resources=False):
parameters = []
heat = Heat(yaml_file)
if all_resources:
- resources = heat.resources
+ resources = heat.resources if not nested_resources else heat.get_all_resources()
else:
- resources = heat.get_resource_by_type(resource_type)
-
+ resources = heat.get_resource_by_type(resource_type, all_resources=nested_resources)
for rid, resource_props in resources.items():
for param in prop_iterator(resource_props, *spec.get("property")):
if param and get_param(param) and param_helper(spec, get_param(param), rid):
@@ -256,7 +261,6 @@ def get_template_parameters(yaml_file, resource_type, spec, all_resources=False)
# then checking if its actually using get_param
# then checking a custom helper function (mostly for internal vs external networks)
parameters.append({"resource": rid, "param": get_param(param)})
-
return parameters
diff --git a/ice_validator/tests/test_incremental_module.py b/ice_validator/tests/test_incremental_module.py
new file mode 100644
index 0000000..606dfe4
--- /dev/null
+++ b/ice_validator/tests/test_incremental_module.py
@@ -0,0 +1,59 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+import os
+
+from tests.helpers import validates
+from tests.utils.incrementals import is_incremental_module
+
+from tests.structures import Heat
+
+
+@validates("R-610030")
+def test_incremental_module_has_server(yaml_files):
+ modules = (f for f in yaml_files if is_incremental_module(f, yaml_files))
+ errors = []
+ for module in modules:
+ servers = Heat(filepath=module).get_resource_by_type(
+ "OS::Nova::Server", all_resources=True
+ )
+ if not servers:
+ errors.append(os.path.basename(module))
+
+ assert not errors, (
+ "The following incremental modules do not contain an OS::Nova::Server "
+ "as required: {}".format(", ".join(errors))
+ )