-from tests import cached_yaml as yaml
-
-VERSION = "1.0.0"
-
-# pylint: disable=invalid-name
-
-
-def check_parameter_exists(pattern, parameters):
- if not parameters:
- return False
-
- for param in parameters:
- if pattern.search(param):
- return True
-
- return False
-
-
-def check_param_in_env_file(environment_pair, param, DESIRED, exclude_parameter=None):
-
- # workaround for internal/external parameters
- if exclude_parameter and re.match(exclude_parameter, param):
- return False
-
- if not environment_pair:
- pytest.skip("No heat/env pair could be identified")
-
- env_file = environment_pair.get("eyml")
-
- pattern = re.compile(r"^{}$".format(param))
-
- if "parameters" not in env_file:
- pytest.skip("No parameters specified in the environment file")
-
- return (
- check_parameter_exists(pattern, env_file.get("parameters", {})) is not DESIRED
- )
-
-
-"""
-This function supports this structure, deviations
-may or may not work without enhancement
-
-resource_id:
- type: <resource_type>
- properties:
- prop0: { get_param: parameter_0 }
- prop1: # this is a list of dicts
- - nested_prop_0: { get_param: parameter_1 }
- - nested_prop_1: { get_param: [parameter_2, {index}] }
- prop2: # this is a dict of dicts
- nested_prop_0: { get_param: parameter_1 }
- prop3: { get_param: [parameter_3, 0]}
-"""
-
-
-def check_resource_parameter(
- environment_pair,
- prop,
- DESIRED,
- resource_type,
- resource_type_inverse=False,
- nested_prop="",
- exclude_resource="",
- exclude_parameter="",
-):
- if not environment_pair:
- pytest.skip("No heat/env pair could be identified")
-
- env_file = environment_pair.get("eyml")
- template_file = environment_pair.get("yyml")
-
- if "parameters" not in env_file:
- pytest.skip("No parameters specified in the environment file")
-
+from tests.helpers import (
+ prop_iterator,
+ get_param,
+ get_environment_pair,
+ validates,
+ find_environment_file,
+ categories,
+)
+from tests.structures import Heat
+from tests.utils.nested_files import file_is_a_nested_template
+
+
+# Whats persistent mean? It means it goes in env.
+# When adding an additional case, note the ","
+# 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": (r"^(.+?)_net_fqdn$",), "persistent": False, "kwargs": {}},
+ ],
+ "ALL": [{"property": ("name",), "persistent": False, "kwargs": {}}],
+ "OS::Nova::Server": [
+ {"property": ("image",), "persistent": True, "kwargs": {}},
+ {"property": ("flavor",), "persistent": True, "kwargs": {}},
+ {"property": ("availability_zone",), "persistent": False, "kwargs": {}},
+ ],
+ "OS::Neutron::Port": [
+ {"property": ("network",), "persistent": False, "kwargs": {}},
+ {
+ "property": ("fixed_ips", "ip_address"),
+ "persistent": False,
+ "network_type": "external",
+ "kwargs": {"exclude_parameter": re.compile(r"^(.+?)_int_(.+?)$")},
+ },
+ {
+ "property": ("fixed_ips", "ip_address"),
+ "persistent": True,
+ "network_type": "internal",
+ "kwargs": {"exclude_parameter": re.compile(r"^((?!_int_).)*$")},
+ },
+ {"property": ("fixed_ips", "subnet"), "persistent": False, "kwargs": {}},
+ {
+ "property": ("allowed_address_pairs", "ip_address"),
+ "persistent": False,
+ "network_type": "external",
+ "kwargs": {"exclude_parameter": re.compile(r"^(.+?)_int_(.+?)$")},
+ },
+ {
+ "property": ("allowed_address_pairs", "ip_address"),
+ "persistent": True,
+ "network_type": "internal",
+ "kwargs": {"exclude_parameter": re.compile(r"^((?!_int_).)*$")},
+ },
+ ],
+ "OS::ContrailV2::InterfaceRouteTable": [
+ {
+ "property": (
+ "interface_route_table_routes",
+ "interface_route_table_routes_route",
+ ),
+ "persistent": False,
+ "kwargs": {},
+ }
+ ],
+ "OS::Heat::ResourceGroup": [
+ {
+ "property": ("count",),
+ "persistent": True,
+ "kwargs": {
+ "exclude_resource": re.compile(
+ r"^(.+?)_subint_(.+?)_port_(.+?)_subinterfaces$"
+ )
+ },
+ }
+ ],
+ "OS::ContrailV2::InstanceIp": [
+ {
+ "property": ("instance_ip_address",),
+ "persistent": False,
+ "network_type": "external",
+ "kwargs": {"exclude_resource": re.compile(r"^.*_int_.*$")},
+ },
+ {
+ "property": ("instance_ip_address",),
+ "persistent": True,
+ "network_type": "internal",
+ "kwargs": {"exclude_resource": re.compile(r"(?!.*_int_.*)")},
+ },
+ {
+ "property": ("subnet_uuid",),
+ "persistent": False,
+ "network_type": "internal",
+ "kwargs": {"exclude_resource": re.compile(r"(?!.*_int_.*)")},
+ },
+ ],
+ "OS::ContrailV2::VirtualMachineInterface": [
+ {
+ "property": (
+ "virtual_machine_interface_allowed_address_pairs",
+ "virtual_machine_interface_allowed_address_pairs_allowed_address_pair",
+ "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip",
+ "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix",
+ ),
+ "persistent": False,
+ "network_type": "external",
+ "kwargs": {"exclude_resource": re.compile(r"(?!.*_int_.*)")},
+ }
+ ],
+}
+
+
+def run_test_parameter(yaml_file, resource_type, *prop, **kwargs):
+ template_parameters = []