[VVP] remove tests for 88540, 20947, 54458
[vvp/validation-scripts.git] / ice_validator / tests / test_contrail_vmi_resource_id.py
1 # -*- coding: utf8 -*-
2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6 # ===================================================================
7 #
8 # Unless otherwise specified, all software contained herein is licensed
9 # under the Apache License, Version 2.0 (the "License");
10 # you may not use this software except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #             http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 #
21 #
22 #
23 # Unless otherwise specified, all documentation contained herein is licensed
24 # under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 # you may not use this documentation except in compliance with the License.
26 # You may obtain a copy of the License at
27 #
28 #             https://creativecommons.org/licenses/by/4.0/
29 #
30 # Unless required by applicable law or agreed to in writing, documentation
31 # distributed under the License is distributed on an "AS IS" BASIS,
32 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 # See the License for the specific language governing permissions and
34 # limitations under the License.
35 #
36 # ============LICENSE_END============================================
37 #
38 #
39
40 """
41 resources:
42 {vm-type}_server_{vm-type_index}
43 """
44 import pytest
45
46 from .structures import Heat
47 from .structures import ContrailV2VirtualMachineInterfaceProcessor
48 from .helpers import validates
49
50 VERSION = "2.0.0"
51
52
53 def run_test(heat_template, regex_name, network_flavor):
54     """run test
55     """
56     heat = Heat(filepath=heat_template)
57     heat_object_class = ContrailV2VirtualMachineInterfaceProcessor
58     resource_type = heat_object_class.resource_type
59     resources = heat.get_resource_by_type(resource_type=resource_type)
60     if not resources:
61         pytest.skip("No %s resources found" % resource_type)
62     bad = []
63     heat_object = heat_object_class()
64     rid_pattern = heat_object.get_rid_patterns()[regex_name]
65     for rid, resource in resources.items():
66         flavor = heat_object.get_network_flavor(resource)
67         if flavor != network_flavor:
68             continue
69         name = heat_object.get_rid_match_tuple(rid)[0]
70         if name == regex_name:
71             continue
72         bad.append(rid)
73     assert not bad, "%s resource ids %s must match %s" % (
74         network_flavor,
75         bad,
76         [rid_pattern],
77     )
78
79
80 # pylint: disable=invalid-name
81
82
83 @validates("R-96253")
84 def test_contrail_instance_ip_resource_id_external(yaml_file):
85     """
86     A VNF's Heat Orchestration Template's Resource
87     OS::ContrailV2::VirtualMachineInterface that is attaching to an
88     external network
89     Resource ID **MUST** use the naming convention
90
91     {vm-type}_{vm-type_index}_{network-role}_vmi_{vmi_index}
92     """
93     run_test(
94         yaml_file,
95         regex_name="vmi_external",
96         network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_external,
97     )
98
99
100 @validates("R-50468")
101 def test_contrail_instance_ip_resource_id_internal(yaml_file):
102     """
103     A VNF's Heat Orchestration Template's Resource
104     OS::ContrailV2::VirtualMachineInterface that is attaching to an
105     internal network
106     Resource ID **MUST** use the naming convention
107
108     {vm-type}_{vm-type_index}_int_{network-role}_vmi_{vmi_index}
109     """
110     run_test(
111         yaml_file,
112         regex_name="vmi_internal",
113         network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_internal,
114     )