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_nesting_level/fail/bad-level0.yaml50
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/fail/bad-level3.yaml59
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/fail/level0.yaml (renamed from ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_0.yaml)3
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/fail/level1.yaml (renamed from ice_validator/tests/fixtures/test_nesting_level/fail/bad-level1.yaml)8
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/fail/level2.yaml (renamed from ice_validator/tests/fixtures/test_nesting_level/fail/bad-level2.yaml)4
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/fail/level3.yaml (renamed from ice_validator/tests/fixtures/test_nesting_level/pass/level3.yaml)0
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/pass/level1.yaml6
-rw-r--r--ice_validator/tests/fixtures/test_nesting_level/pass/level2.yaml17
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_0.yaml49
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_1.yaml64
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_2.yaml59
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_1.yaml63
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_2.yaml59
-rw-r--r--ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_3.yaml62
-rw-r--r--ice_validator/tests/structures.py33
-rw-r--r--ice_validator/tests/test_environment_file_parameters.py15
-rw-r--r--ice_validator/tests/test_nesting_level.py45
-rw-r--r--ice_validator/tests/test_nesting_nova_server.py98
-rw-r--r--ice_validator/tests/utils/nested_files.py83
19 files changed, 79 insertions, 698 deletions
diff --git a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level0.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level0.yaml
deleted file mode 100644
index 3e93c1a..0000000
--- a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level0.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- 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:
- server_0:
- type: bad-level1.yaml
- properties:
- name: { get_param: server_name_0 }
- my_resource_group_1:
- type: OS::Heat::ResourceGroup
- properties:
- count: 5
- resource_def: { type: bad-level2.yaml }
diff --git a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level3.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level3.yaml
deleted file mode 100644
index bdd6131..0000000
--- a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level3.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- 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'
----
-heat_template_version: '2013-05-23'
-
-resources:
- volume:
- type: OS::Cinder::Volume
- properties:
- size: 1
-
- volume_attachment:
- type: OS::Cinder::VolumeAttachment
- properties:
- volume_id: { get_resource: volume }
- instance_uuid: { get_resource: instance }
-
- instance:
- type: OS::Nova::Server
- properties:
- image: myimage
- flavor: m1.small
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_0.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/level0.yaml
index 95d0b77..669cce7 100644
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_0.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/fail/level0.yaml
@@ -40,10 +40,11 @@
---
resources:
server_0:
- type: 17528_1.yaml
+ type: level1.yaml
properties:
name: { get_param: server_name_0 }
my_resource_group_1:
type: OS::Heat::ResourceGroup
properties:
count: 5
+ resource_def: { type: level2.yaml }
diff --git a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level1.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/level1.yaml
index e30d89e..821eb13 100644
--- a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level1.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/fail/level1.yaml
@@ -36,7 +36,7 @@
# ============LICENSE_END============================================
#
#
-# VERSION: '1.0.0'
+# VERSION: '1.0.1'
---
nested_template_description: base
@@ -48,14 +48,14 @@ parameters:
resources:
server_0:
- type: bad-level2.yaml
+ type: level3.yaml
properties:
name: {get_param: server_name_0}
my_resource_group_1:
- type: OS::Nova::Server
+ type: OS::Heat::ResourceGroup
properties:
count: 5
- resource_def: { type: bad-level3.yaml }
+ resource_def: { type: level2.yaml }
outputs:
vm_type_volume_id_0:
diff --git a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level2.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/level2.yaml
index 7f56a12..c2f109d 100644
--- a/ice_validator/tests/fixtures/test_nesting_level/fail/bad-level2.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/fail/level2.yaml
@@ -36,7 +36,7 @@
# ============LICENSE_END============================================
#
#
-# VERSION: '1.0.0'
+# VERSION: '1.0.1'
---
nested_template_description: base
@@ -55,7 +55,7 @@ resources:
type: OS::Heat::ResourceGroup
properties:
count: 5
- resource_def: { type: bad-level3.yaml }
+ resource_def: { type: level3.yaml }
outputs:
vm_type_volume_id_0:
diff --git a/ice_validator/tests/fixtures/test_nesting_level/pass/level3.yaml b/ice_validator/tests/fixtures/test_nesting_level/fail/level3.yaml
index bdd6131..bdd6131 100644
--- a/ice_validator/tests/fixtures/test_nesting_level/pass/level3.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/fail/level3.yaml
diff --git a/ice_validator/tests/fixtures/test_nesting_level/pass/level1.yaml b/ice_validator/tests/fixtures/test_nesting_level/pass/level1.yaml
index 1ca1659..0213649 100644
--- a/ice_validator/tests/fixtures/test_nesting_level/pass/level1.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/pass/level1.yaml
@@ -47,12 +47,8 @@ parameters:
type: number
resources:
- server_0:
- type: level3.yaml
- properties:
- name: {get_param: server_name_0}
my_resource_group_1:
- type: OS::Nova::Server
+ type: OS::Heat::ResourceGroup
properties:
count: 5
resource_def: { type: level2.yaml }
diff --git a/ice_validator/tests/fixtures/test_nesting_level/pass/level2.yaml b/ice_validator/tests/fixtures/test_nesting_level/pass/level2.yaml
index c2f109d..fce358a 100644
--- a/ice_validator/tests/fixtures/test_nesting_level/pass/level2.yaml
+++ b/ice_validator/tests/fixtures/test_nesting_level/pass/level2.yaml
@@ -35,8 +35,6 @@
#
# ============LICENSE_END============================================
#
-#
-# VERSION: '1.0.1'
---
nested_template_description: base
@@ -46,17 +44,6 @@ parameters:
vm_type_volume_size_0:
type: number
-resources:
- server_0:
- type: not_a_template_file
- properties:
- name: {get_param: server_name_0}
- my_resource_group_1:
- type: OS::Heat::ResourceGroup
- properties:
- count: 5
- resource_def: { type: level3.yaml }
-
outputs:
- vm_type_volume_id_0:
- value: {get_resource: vm_type_volume_0}
+ vm_type_volume_name_0:
+ value: {get_param: vm_type_volume_name_0}
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_0.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_0.yaml
deleted file mode 100644
index c5ab87c..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_0.yaml
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- 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:
- server_0:
- type: bad-17528_1.yaml
- properties:
- name: { get_param: server_name_0 }
- my_resource_group_1:
- type: OS::Heat::ResourceGroup
- properties:
- count: 5
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_1.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_1.yaml
deleted file mode 100644
index c00e1e3..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_1.yaml
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- 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.1'
----
-nested_template_description: base
-
-parameters:
- vm_type_volume_name_0:
- type: string
- vm_type_volume_size_0:
- type: number
-
-resources:
- server_0:
- type: not_a_template_file
- properties:
- name: {get_param: server_name_0}
- my_resource_group_1:
- type: OS::Nova::Server
- properties:
- count: 5
- resource_def: { type: bad-17528_2.yaml }
- my_resource_group_2:
- type: OS::Nova::Server
-
-outputs:
- vm_type_volume_id_0:
- value: {get_resource: vm_type_volume_0}
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_2.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_2.yaml
deleted file mode 100644
index 7dd2f64..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/fail/bad-17528_2.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- 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.1'
----
-heat_template_version: '2013-05-23'
-
-resources:
- volume:
- type: OS::Cinder::Volume
- properties:
- size: 1
-
- volume_attachment:
- type: OS::Cinder::VolumeAttachment
- properties:
- volume_id: { get_resource: volume }
- instance_uuid: { get_resource: instance }
-
- instance:
- type: OS::Nova::NotServer
- properties:
- image: myimage
- flavor: m1.small
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_1.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_1.yaml
deleted file mode 100644
index 3e2546f..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_1.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- 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'
----
-nested_template_description: base
-
-parameters:
- vm_type_volume_name_0:
- type: string
- vm_type_volume_size_0:
- type: number
-
-resources:
- server_0:
- type: not_a_template_file
- properties:
- name: {get_param: server_name_0}
- my_resource_group_1:
- type: OS::Nova::Server
- properties:
- count: 5
- #resource_def: { type: 17528_3.yaml }
- resource_def: { type: 17528_2.yaml }
-
-outputs:
- vm_type_volume_id_0:
- value: {get_resource: vm_type_volume_0}
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_2.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_2.yaml
deleted file mode 100644
index 1d17164..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_2.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- 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'
----
-heat_template_version: '2013-05-23'
-
-resources:
- volume:
- type: OS::Cinder::Volume
- properties:
- size: 1
-
- volume_attachment:
- type: OS::Cinder::VolumeAttachment
- properties:
- volume_id: { get_resource: volume }
- instance_uuid: { get_resource: instance }
-
- instance:
- type: OS::Nova::NotServer
- properties:
- image: myimage
- flavor: m1.small
diff --git a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_3.yaml b/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_3.yaml
deleted file mode 100644
index a38fd9c..0000000
--- a/ice_validator/tests/fixtures/test_nesting_nova_server/pass/17528_3.yaml
+++ /dev/null
@@ -1,62 +0,0 @@
-# -*- 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'
----
-nested_template_description: base
-
-parameters:
- vm_type_volume_name_0:
- type: string
- vm_type_volume_size_0:
- type: number
-
-resources:
- server_0:
- type: not_a_template_file
- properties:
- name: {get_param: server_name_0}
- my_resource_group_1:
- type: OS::Nova::Server
- properties:
- count: 5
- resource_def: { type: 17528_2.yaml }
-
-outputs:
- vm_type_volume_id_0:
- value: {get_resource: vm_type_volume_0}
diff --git a/ice_validator/tests/structures.py b/ice_validator/tests/structures.py
index 09dd222..aaed8d1 100644
--- a/ice_validator/tests/structures.py
+++ b/ice_validator/tests/structures.py
@@ -36,8 +36,6 @@
# ============LICENSE_END============================================
#
#
-"""structures
-"""
import collections
import inspect
import os
@@ -732,6 +730,31 @@ class Heat(object):
re.search("(^(%(x)s)_)|(_(%(x)s)_)|(_(%(x)s)$)" % dict(x=part), name)
)
+ def iter_nested_heat(self):
+ """
+ Returns an iterable of tuples (int, heat) where the first parameter is the
+ depth of the nested file and the second item is an instance of Heat
+ """
+
+ def walk_nested(heat, level=1):
+ resources = [Resource(r_id, data) for r_id, data in heat.resources.items()]
+ for resource in resources:
+ if resource.is_nested():
+ nested_path = os.path.join(
+ self.dirname, resource.get_nested_filename()
+ )
+ nested_heat = Heat(nested_path)
+ yield level, nested_heat
+ yield from walk_nested(nested_heat, level + 1)
+
+ yield from walk_nested(self)
+
+ def __str__(self):
+ return "Heat({})".format(self.filepath)
+
+ def __repr__(self):
+ return str(self)
+
class Env(Heat):
"""An Environment file
@@ -832,6 +855,12 @@ class Resource(object):
else:
return {}
+ def __str__(self):
+ return "Resource(id={}, type={})".format(self.resource_id, self.resource_type)
+
+ def __repr__(self):
+ return str(self)
+
def get_all_resources(yaml_files):
"""Return a dict, resource id: resource
diff --git a/ice_validator/tests/test_environment_file_parameters.py b/ice_validator/tests/test_environment_file_parameters.py
index 41a2aa1..84c5c34 100644
--- a/ice_validator/tests/test_environment_file_parameters.py
+++ b/ice_validator/tests/test_environment_file_parameters.py
@@ -234,8 +234,11 @@ 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, nested_resources=True))
+ 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
@@ -246,14 +249,18 @@ def get_preload_excluded_parameters(yaml_file, persistent_only=False, env_spec=N
return results
-def get_template_parameters(yaml_file, resource_type, spec, all_resources=False, nested_resources=False):
+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 if not nested_resources else heat.get_all_resources()
else:
- resources = heat.get_resource_by_type(resource_type, all_resources=nested_resources)
+ 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):
diff --git a/ice_validator/tests/test_nesting_level.py b/ice_validator/tests/test_nesting_level.py
index 6c31dbb..bb8c704 100644
--- a/ice_validator/tests/test_nesting_level.py
+++ b/ice_validator/tests/test_nesting_level.py
@@ -34,30 +34,33 @@
# limitations under the License.
#
# ============LICENSE_END============================================
-#
-#
-
-"""
-test nesting level
-0 -> 1 -> 2 -> too many levels.
-"""
+from .structures import Heat
from .utils import nested_files
from .helpers import validates
-VERSION = "1.1.0"
-
-# pylint: disable=invalid-name
-
-@validates("R-60011")
+@validates("R-60011", "R-17528")
def test_nesting_level(yaml_files):
- """
- A VNF's Heat Orchestration Template **MUST** have no more than two
- levels of nesting.
- """
- bad, __, __, __ = nested_files.get_nesting(yaml_files)
- assert not bad, "nesting depth of %d exceeded: %s" % (
- nested_files.MAX_DEPTH,
- ", ".join(bad),
- )
+ errors = set()
+ non_nested_files = [
+ f for f in yaml_files if not nested_files.file_is_a_nested_template(f)
+ ]
+ heats = [Heat(f) for f in non_nested_files]
+ for heat in heats:
+ for depth, nested_heat in heat.iter_nested_heat():
+ if depth >= 3:
+ errors.add(
+ (
+ "{} is nested {} levels deep, but a maximum of {} levels are "
+ "supported."
+ ).format(nested_heat.basename, depth, nested_files.MAX_DEPTH)
+ )
+ if depth == 2 and nested_heat.resources:
+ errors.add(
+ (
+ "{} is a second level nested file, but it includes "
+ "resources. Remove all Heat resources from this file."
+ ).format(nested_heat.basename)
+ )
+ assert not errors, "\n\n".join(errors)
diff --git a/ice_validator/tests/test_nesting_nova_server.py b/ice_validator/tests/test_nesting_nova_server.py
deleted file mode 100644
index cce4c98..0000000
--- a/ice_validator/tests/test_nesting_nova_server.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- 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============================================
-#
-#
-
-"""
-test nesting level
-0 -> 1 -> 2 -> too many levels.
-"""
-
-import pytest
-
-from .utils import nested_files
-from .helpers import validates
-
-VERSION = "1.0.0"
-
-
-def get_nova_server_count(heat):
- """return the number of OS::Nova::Server
- resources in heat
- """
- return len(heat.get_resource_by_type("OS::Nova::Server"))
-
-
-# pylint: disable=invalid-name
-
-
-@validates("R-17528")
-def test_nesting_nova_server(yaml_files):
- """
- A VNF's Heat Orchestration Template's first level Nested YAML file
- **MUST NOT** contain more than one ``OS::Nova::Server`` resource.
- A VNF's Heat Orchestration Template's second level Nested YAML file
- **MUST NOT** contain an ``OS::Nova::Server`` resource.
-
- level: 0 1 2 3
- template -> nested -> nested -> too many levels
- """
- bad, __, heat, depths = nested_files.get_nesting(yaml_files)
- if bad:
- pytest.skip("nesting depth exceeded")
- for parent, depth in depths.items():
- for depth_tuple in depth:
- depth, context = depth_tuple
- if depth > 1:
- fname = context[0]
- nservers = get_nova_server_count(heat[fname])
- if nservers > 1:
- bad.append(
- "nested template %s must have only have 1 "
- "OS::Nova::Server defined, but %s were found"
- % (fname, nservers)
- )
- if depth > 2:
- fname = context[1]
- nservers = get_nova_server_count(heat[fname])
- if nservers > 0:
- bad.append(
- "nested template %s must not have an "
- "OS::Nova::Server defined, but %s were found"
- % (fname, nservers)
- )
- assert not bad, "; ".join(bad)
diff --git a/ice_validator/tests/utils/nested_files.py b/ice_validator/tests/utils/nested_files.py
index e5f5941..e1918ad 100644
--- a/ice_validator/tests/utils/nested_files.py
+++ b/ice_validator/tests/utils/nested_files.py
@@ -34,26 +34,15 @@
# limitations under the License.
#
# ============LICENSE_END============================================
-#
-#
-"""nested files
-"""
from functools import lru_cache
from os import path, listdir
import re
from tests import cached_yaml as yaml
-from tests.structures import Heat
from tests.helpers import load_yaml
-VERSION = "1.4.0"
-
-"""
-test nesting depth
-0 -> 1 -> 2 -> too deep.
-"""
-MAX_DEPTH = 3
+MAX_DEPTH = 2
def check_for_invalid_nesting( # pylint: disable=too-many-branches
@@ -70,7 +59,7 @@ def check_for_invalid_nesting( # pylint: disable=too-many-branches
for v in yml.values():
if isinstance(v, dict) and "type" in v:
t = v["type"]
- if t.endswith(".yml") or t.endswith(".yaml"):
+ if t.lower().endswith(".yml") or t.lower().endswith(".yaml"):
filepath = path.join(dirpath, t)
elif t == "OS::Heat::ResourceGroup":
rd = v["properties"]["resource_def"]
@@ -98,18 +87,6 @@ def check_for_invalid_nesting( # pylint: disable=too-many-branches
return invalid_nesting
-def get_dict_of_nested_files(yml, dirpath):
- """Return dict.
- key: resource id in yml which references a nested file.
- value: the nested file name.
- Nested files are either referenced through "type", or
- for OS::Heat::ResourceGroup, through "resource_def type".
- """
- nested_files = get_type_nested_files(yml, dirpath)
- nested_files.update(get_resourcegroup_nested_files(yml, dirpath))
- return nested_files
-
-
@lru_cache(maxsize=None)
def get_list_of_nested_files(yml_path, dirpath):
"""
@@ -138,62 +115,6 @@ def get_list_of_nested_files(yml_path, dirpath):
return nested_files
-def get_nesting(yaml_files):
- """return bad, files, heat, depths
- bad - list of error messages.
- files - dict: key is filename, value is dict of nested files.
- This is the tree.
- heat - dict,: key is filename, value is Heat instance.
- depths - dict: key is filename, value is a depth tuple
-
- level: 0 1 2 3
- file: template -> nested -> nested -> nested
- depth: 3 2 1 0
- """
- bad = []
- files = {}
- heat = {}
- depths = {}
- for yaml_file in yaml_files:
- dirname, basename = path.split(yaml_file)
- h = Heat(filepath=yaml_file)
- heat[basename] = h
- files[basename] = get_dict_of_nested_files(h.yml, dirname)
- for filename in files:
- depths[filename] = _get_nesting_depth_start(0, filename, files, [])
- for depth in depths[filename]:
- if depth[0] > MAX_DEPTH:
- bad.append("{} {}".format(filename, str(depth[1])))
- return bad, files, heat, depths
-
-
-def _get_nesting_depth_start(depth, filename, files, context):
- depths = []
- for rid, nf in files[filename].items():
- depths.append(_get_nesting_depth(1, nf, files, context))
- return depths
-
-
-def _get_nesting_depth(depth, filename, files, context):
- """Return a depth tuple (max_depth, current_context).
- `context` is the list of filenames.
- `depth` is the length of `context`.
- Finds the max_depth of all the resources of `filename`.
- current_context is the updated list of filenames
- and max_depth is its length.
- """
- max_depth = depth + 1
- current_context = context + [filename]
- if depth <= MAX_DEPTH:
- nested_filenames = files.get(filename, {})
- if nested_filenames:
- max_depth, current_context = max(
- _get_nesting_depth(depth + 1, nested_filename, files, current_context)
- for nested_filename in nested_filenames.values()
- )
- return max_depth, current_context
-
-
def get_resourcegroup_nested_files(yml, dirpath):
"""
return a dict.