From 6a3e189d7fac6ec562f8785c71ed87663ef0c311 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Wed, 31 Jan 2024 11:06:56 +0100 Subject: Changes in the packages sort order Issue-ID: TEST-402 Signed-off-by: Lukasz Rajewski Change-Id: I9f8ac40254e6a052c4b3ced5b05e21d7e84fa37f --- pylama.ini | 2 + run_test.py | 46 ++++++++++++++++++--- .../configuration/basic_clamp_settings.py | 4 +- .../configuration/basic_cnf_macro_settings.py | 7 ++-- .../configuration/basic_cnf_yaml_settings.py | 8 ++-- .../basic_network_nomulticloud_settings.py | 10 +++-- .../configuration/basic_onboard_settings.py | 6 ++- .../basic_vm_multicloud_yaml_settings.py | 2 +- src/onaptests/configuration/basic_vm_settings.py | 10 +++-- .../configuration/cba_enrichment_settings.py | 1 + .../cds_resource_resolution_settings.py | 1 + .../clearwater_ims_nomulticloud_settings.py | 8 ++-- .../configuration/multi_vnf_ubuntu_settings.py | 8 ++-- src/onaptests/configuration/pnf_macro_settings.py | 1 + src/onaptests/configuration/status_settings.py | 1 - src/onaptests/scenario/basic_cnf_macro.py | 2 +- src/onaptests/scenario/basic_cps.py | 4 +- src/onaptests/scenario/basic_vm_macro.py | 2 +- src/onaptests/scenario/cds_resource_resolution.py | 3 +- src/onaptests/scenario/multi_vnf_macro.py | 2 +- src/onaptests/scenario/pnf_macro.py | 2 +- src/onaptests/scenario/scenario_base.py | 4 +- src/onaptests/steps/base.py | 2 +- src/onaptests/steps/cloud/check_status.py | 47 ++++++++++++++-------- ...connect_service_subscription_to_cloud_region.py | 5 ++- .../cloud/customer_service_subscription_create.py | 2 +- .../steps/cloud/expose_service_node_port.py | 3 +- .../steps/cloud/k8s_connectivity_info_create.py | 2 +- src/onaptests/steps/cloud/register_cloud.py | 1 + .../steps/instantiate/k8s_profile_create.py | 3 +- src/onaptests/steps/instantiate/sdnc_service.py | 1 + .../steps/instantiate/service_ala_carte.py | 8 ++-- src/onaptests/steps/instantiate/service_macro.py | 22 ++++------ .../steps/instantiate/vf_module_ala_carte.py | 5 ++- src/onaptests/steps/instantiate/vl_ala_carte.py | 5 ++- src/onaptests/steps/instantiate/vnf_ala_carte.py | 3 +- src/onaptests/steps/loop/clamp.py | 6 +-- src/onaptests/steps/loop/instantiate_loop.py | 1 + src/onaptests/steps/onboard/clamp.py | 5 +-- src/onaptests/steps/onboard/msb_k8s.py | 3 +- src/onaptests/steps/onboard/pnf.py | 1 + src/onaptests/steps/onboard/service.py | 2 +- src/onaptests/steps/onboard/vf.py | 3 +- src/onaptests/steps/onboard/vsp.py | 1 + src/onaptests/steps/reports_collection.py | 4 +- .../simulator/pnf_simulator_cnf/pnf_register.py | 2 +- src/onaptests/steps/wrapper/helm_charts.py | 6 +-- src/onaptests/steps/wrapper/start.py | 4 +- src/onaptests/utils/resources.py | 1 + tox.ini | 1 + 50 files changed, 182 insertions(+), 101 deletions(-) diff --git a/pylama.ini b/pylama.ini index b0b7bfa..6c0e0e5 100644 --- a/pylama.ini +++ b/pylama.ini @@ -5,10 +5,12 @@ linters = pylint,pycodestyle,pyflakes,mccabe max_line_length = 100 [pylama:pylint] +known_third_party=onaptests,onapsdk disable = fixme, logging-fstring-interpolation, logging-format-interpolation, + logging-not-lazy, consider-using-f-string, unused-argument, broad-exception-caught, diff --git a/run_test.py b/run_test.py index a7b407d..798d7af 100644 --- a/run_test.py +++ b/run_test.py @@ -1,8 +1,10 @@ import configparser import importlib +import importlib.util import logging.config import os import sys +import glob from onapsdk.exceptions import ModuleError import onaptests.utils.exceptions as onap_test_exceptions @@ -12,7 +14,8 @@ SETTING_FILE_EXCEPTIONS = { "basic_cnf": "basic_cnf_yaml_settings", "basic_cds": "cba_enrichment_settings", "basic_network": "basic_network_nomulticloud_settings", - "multi_vnf_macro": "multi_vnf_ubuntu_settings" + "multi_vnf_macro": "multi_vnf_ubuntu_settings", + "add_pnf_in_running_service": "instantiate_pnf_without_registration_event_settings" } MODULES_TO_RELOAD = [ @@ -23,7 +26,7 @@ MODULES_TO_RELOAD = [ def get_entrypoints(): config = configparser.ConfigParser() config.read('setup.cfg') - entry_points = config['entry_points']['xtesting.testcase'] + entry_points = config['options.entry_points']['xtesting.testcase'] config = configparser.ConfigParser() config.read_string(f"[entry_points]\n{entry_points}") entry_points = config['entry_points'] @@ -36,7 +39,24 @@ def get_entrypoints(): } return entry_points_result +def check_scenarios(scenarios, entry_points): + path = importlib.util.find_spec(scenarios.__name__).submodule_search_locations + modules = glob.glob(f"{path._path[0]}/*.py") + all_mods = [ os.path.basename(f)[:-3] for f in modules if os.path.isfile(f) and not f.endswith('__init__.py')] + for mod_name in all_mods: + full_mod_name = f"{scenarios.__name__}.{mod_name}" + if mod_name != "scenario_base": + exists = False + for test_name, entry_point in entry_points.items(): + if entry_point["module"] == full_mod_name: + exists = True + break + if not exists: + raise onap_test_exceptions.TestConfigurationException( + f"Scenario defined in {full_mod_name}.py is not added to setup.cfg file") + def run_test(test_name, validation, force_cleanup, entry_point): + print(f"Configuring {test_name} test") settings_env = "ONAP_PYTHON_SDK_SETTINGS" if force_cleanup: validation_env = "PYTHON_SDK_TESTS_FORCE_CLEANUP" @@ -67,25 +87,36 @@ def run_test(test_name, validation, force_cleanup, entry_point): logger = logging.getLogger(test_name) logger.info(f"Running {test_name} test") + scenarios = importlib.import_module("onaptests.scenario") test_module = importlib.import_module(entry_point["module"]) test_instance = getattr(test_module, entry_point["class"])() if validation: - validate_scenario_base_class(test_name, test_instance) + validate_scenario_base_class(test_name, test_instance, scenarios) test_instance.run() test_instance.clean() if validation: logger.info(f"Validating {test_name} test") test_instance.validate() + return scenarios -def validate_scenario_base_class(test_name, scenario): +def validate_scenario_base_class(test_name, scenario, scenarios): has_scenario_base = False + if test_name != scenario.case_name: + raise onap_test_exceptions.TestConfigurationException( + f"[{test_name}] Mismatch of scenario case name: {test_name} != {scenario.case_name}") + if scenario.__class__.run != scenarios.scenario_base.ScenarioBase.run: + raise onap_test_exceptions.TestConfigurationException( + f"[{test_name}] scenario class overrides run() method what is forbidden") + if scenario.__class__.clean != scenarios.scenario_base.ScenarioBase.clean: + raise onap_test_exceptions.TestConfigurationException( + f"[{test_name}] scenario class overrides clean() method what is forbidden") for base in scenario.__class__.__bases__: if base.__name__ in "ScenarioBase": has_scenario_base = True break if not has_scenario_base: - raise TestConfigurationException( + raise onap_test_exceptions.TestConfigurationException( f"[{test_name}] {scenario.__class__.__name__} class does not inherit from ScenarioBase") def main(argv): @@ -112,6 +143,7 @@ def main(argv): entry_points = get_entrypoints() if test_name == "all": modules_reload = False + scenarios = None for test_name, entry_point in entry_points.items(): if modules_reload: modules_to_keep = dict() @@ -125,9 +157,11 @@ def main(argv): modules_to_keep[module] = sys.modules[module] sys.modules.clear() sys.modules.update(modules_to_keep) - run_test( + scenarios = run_test( test_name, validation, force_cleanup, entry_point) modules_reload = True + if validation: + check_scenarios(scenarios, entry_points) else: entry_point = entry_points[test_name] run_test(test_name, validation, force_cleanup, entry_point) diff --git a/src/onaptests/configuration/basic_clamp_settings.py b/src/onaptests/configuration/basic_clamp_settings.py index 7563fb6..1277f5f 100644 --- a/src/onaptests/configuration/basic_clamp_settings.py +++ b/src/onaptests/configuration/basic_clamp_settings.py @@ -1,9 +1,9 @@ -from yaml import load, SafeLoader +from yaml import SafeLoader, load + from onaptests.utils.resources import get_resource_location from .settings import * # noqa - CLEANUP_FLAG = False CLAMP_DISTRIBUTION_TIMER = 10 diff --git a/src/onaptests/configuration/basic_cnf_macro_settings.py b/src/onaptests/configuration/basic_cnf_macro_settings.py index 60682ca..a55267c 100644 --- a/src/onaptests/configuration/basic_cnf_macro_settings.py +++ b/src/onaptests/configuration/basic_cnf_macro_settings.py @@ -1,12 +1,13 @@ import os from pathlib import Path from uuid import uuid4 -from yaml import load, SafeLoader -from onaptests.utils.resources import get_resource_location +from yaml import SafeLoader, load + import onaptests.utils.exceptions as onap_test_exceptions -from .settings import * # noqa +from onaptests.utils.resources import get_resource_location +from .settings import * # noqa # Specific basic_cnf_macro with multicloud-k8s and yaml config scenario. SERVICE_DETAILS = ("Onboarding, distribution and instantiation of a Apache CNF " + diff --git a/src/onaptests/configuration/basic_cnf_yaml_settings.py b/src/onaptests/configuration/basic_cnf_yaml_settings.py index 34a1d4d..ec451a1 100644 --- a/src/onaptests/configuration/basic_cnf_yaml_settings.py +++ b/src/onaptests/configuration/basic_cnf_yaml_settings.py @@ -1,9 +1,11 @@ import os -from yaml import load, SafeLoader -from onaptests.utils.resources import get_resource_location + +from yaml import SafeLoader, load + import onaptests.utils.exceptions as onap_test_exceptions -from .settings import * # noqa +from onaptests.utils.resources import get_resource_location +from .settings import * # noqa # Specific basic_cnf with multicloud-k8s and yaml config scenario. SERVICE_DETAILS = ("Onboarding, distribution and instantiation of a CNF" + diff --git a/src/onaptests/configuration/basic_network_nomulticloud_settings.py b/src/onaptests/configuration/basic_network_nomulticloud_settings.py index 7cecb51..9c8c210 100644 --- a/src/onaptests/configuration/basic_network_nomulticloud_settings.py +++ b/src/onaptests/configuration/basic_network_nomulticloud_settings.py @@ -1,11 +1,13 @@ import os + import openstack -from yaml import load, SafeLoader -from onaptests.utils.resources import get_resource_location +from yaml import SafeLoader, load + import onaptests.utils.exceptions as onap_test_exceptions -from .settings import IF_VALIDATION -from .settings import * # noqa +from onaptests.utils.resources import get_resource_location +from .settings import * # noqa +from .settings import IF_VALIDATION # The ONAP part SERVICE_DETAILS = "Onboarding, distribution and instantiation of Basic Network using à la carte" diff --git a/src/onaptests/configuration/basic_onboard_settings.py b/src/onaptests/configuration/basic_onboard_settings.py index e757035..e16bf31 100644 --- a/src/onaptests/configuration/basic_onboard_settings.py +++ b/src/onaptests/configuration/basic_onboard_settings.py @@ -1,12 +1,14 @@ import random import string -from yaml import load, SafeLoader + from jinja2 import Environment, PackageLoader +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions from onaptests.utils.resources import get_resource_location -from .settings import * # noqa + +from .settings import * # noqa # We need to create a service file with a random service name, diff --git a/src/onaptests/configuration/basic_vm_multicloud_yaml_settings.py b/src/onaptests/configuration/basic_vm_multicloud_yaml_settings.py index 1cb1aec..2a8f6f7 100644 --- a/src/onaptests/configuration/basic_vm_multicloud_yaml_settings.py +++ b/src/onaptests/configuration/basic_vm_multicloud_yaml_settings.py @@ -1,6 +1,6 @@ from onaptests.utils.resources import get_resource_location -from .settings import * # noqa +from .settings import * # noqa # Specific Basic VM with multicloud and yaml config scenario. SERVICE_DETAILS = ("Onboarding, distribution and instantiation of a VM" + diff --git a/src/onaptests/configuration/basic_vm_settings.py b/src/onaptests/configuration/basic_vm_settings.py index f26bbd8..41a1dc4 100644 --- a/src/onaptests/configuration/basic_vm_settings.py +++ b/src/onaptests/configuration/basic_vm_settings.py @@ -1,11 +1,13 @@ import os + import openstack -from yaml import load, SafeLoader -from onaptests.utils.resources import get_resource_location +from yaml import SafeLoader, load + import onaptests.utils.exceptions as onap_test_exceptions -from .settings import IF_VALIDATION -from .settings import * # noqa +from onaptests.utils.resources import get_resource_location +from .settings import * # noqa +from .settings import IF_VALIDATION # The ONAP part SERVICE_DETAILS = "Onboarding, distribution and instanitation of an Ubuntu VM using à la carte" diff --git a/src/onaptests/configuration/cba_enrichment_settings.py b/src/onaptests/configuration/cba_enrichment_settings.py index 534ebbe..72cf647 100644 --- a/src/onaptests/configuration/cba_enrichment_settings.py +++ b/src/onaptests/configuration/cba_enrichment_settings.py @@ -1,6 +1,7 @@ from pathlib import Path from onaptests.utils.resources import get_resource_location + from .settings import * # noqa SERVICE_NAME = "CDS blueprint enrichment" diff --git a/src/onaptests/configuration/cds_resource_resolution_settings.py b/src/onaptests/configuration/cds_resource_resolution_settings.py index f7573a6..7b311a1 100644 --- a/src/onaptests/configuration/cds_resource_resolution_settings.py +++ b/src/onaptests/configuration/cds_resource_resolution_settings.py @@ -2,6 +2,7 @@ from pathlib import Path from uuid import uuid4 from onaptests.utils.resources import get_resource_location + from .settings import * # noqa CLEANUP_FLAG = True diff --git a/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py b/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py index 07c966c..2543351 100644 --- a/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py +++ b/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py @@ -1,10 +1,12 @@ import os + import openstack -from yaml import load, SafeLoader +from yaml import SafeLoader, load + from onaptests.utils.resources import get_resource_location -from .settings import IF_VALIDATION -from .settings import * # noqa +from .settings import * # noqa +from .settings import IF_VALIDATION SERVICE_DETAILS = "Onboarding, distribution and instantiation of a Clearwater IMS" # The ONAP part diff --git a/src/onaptests/configuration/multi_vnf_ubuntu_settings.py b/src/onaptests/configuration/multi_vnf_ubuntu_settings.py index a23d72e..bdf6576 100644 --- a/src/onaptests/configuration/multi_vnf_ubuntu_settings.py +++ b/src/onaptests/configuration/multi_vnf_ubuntu_settings.py @@ -1,12 +1,14 @@ -import uuid import os +import uuid from pathlib import Path + import openstack from jinja2 import Environment, PackageLoader + from onaptests.utils.resources import get_resource_location -from .settings import IF_VALIDATION -from .settings import * # noqa +from .settings import * # noqa +from .settings import IF_VALIDATION VNF_FILENAME_PREFIX = "multi-vnf-ubuntu" SERVICE_NAME = f"multivnfubuntu{str(uuid.uuid4().hex)[:6]}" diff --git a/src/onaptests/configuration/pnf_macro_settings.py b/src/onaptests/configuration/pnf_macro_settings.py index 53d22e7..877b569 100644 --- a/src/onaptests/configuration/pnf_macro_settings.py +++ b/src/onaptests/configuration/pnf_macro_settings.py @@ -2,6 +2,7 @@ from pathlib import Path from uuid import uuid4 from onaptests.utils.resources import get_resource_location + from .settings import * # noqa ONLY_INSTANTIATE = False diff --git a/src/onaptests/configuration/status_settings.py b/src/onaptests/configuration/status_settings.py index 13fb8cd..691c747 100644 --- a/src/onaptests/configuration/status_settings.py +++ b/src/onaptests/configuration/status_settings.py @@ -1,6 +1,5 @@ from .settings import * # noqa - SERVICE_NAME = "Status Check" SERVICE_DETAILS = "Checks status of all k8s resources in the selected namespace" STATUS_RESULTS_DIRECTORY = "/tmp" diff --git a/src/onaptests/scenario/basic_cnf_macro.py b/src/onaptests/scenario/basic_cnf_macro.py index 71b6863..95fafad 100644 --- a/src/onaptests/scenario/basic_cnf_macro.py +++ b/src/onaptests/scenario/basic_cnf_macro.py @@ -1,7 +1,7 @@ """Instantiate basic cnf using SO macro flow.""" +from onapsdk.configuration import settings from yaml import SafeLoader, load -from onapsdk.configuration import settings from onaptests.scenario.scenario_base import (BaseStep, ScenarioBase, YamlTemplateBaseScenarioStep) from onaptests.steps.instantiate.service_macro import \ diff --git a/src/onaptests/scenario/basic_cps.py b/src/onaptests/scenario/basic_cps.py index f6189da..a99cc78 100644 --- a/src/onaptests/scenario/basic_cps.py +++ b/src/onaptests/scenario/basic_cps.py @@ -1,7 +1,9 @@ #!/usr/bin/env python """Basic CPS test case.""" from onapsdk.configuration import settings -from onaptests.scenario.scenario_base import BaseStep, ScenarioBase, BaseScenarioStep + +from onaptests.scenario.scenario_base import (BaseScenarioStep, BaseStep, + ScenarioBase) from onaptests.steps.onboard.cps import (CheckPostgressDataBaseConnectionStep, QueryCpsAnchorNodeStep) diff --git a/src/onaptests/scenario/basic_vm_macro.py b/src/onaptests/scenario/basic_vm_macro.py index 0045761..8413258 100644 --- a/src/onaptests/scenario/basic_vm_macro.py +++ b/src/onaptests/scenario/basic_vm_macro.py @@ -1,7 +1,7 @@ """Instantiate basic vm using SO macro flow.""" +from onapsdk.configuration import settings from yaml import SafeLoader, load -from onapsdk.configuration import settings from onaptests.scenario.scenario_base import (BaseStep, ScenarioBase, YamlTemplateBaseScenarioStep) from onaptests.steps.instantiate.service_macro import \ diff --git a/src/onaptests/scenario/cds_resource_resolution.py b/src/onaptests/scenario/cds_resource_resolution.py index fcc3e93..03f8a86 100644 --- a/src/onaptests/scenario/cds_resource_resolution.py +++ b/src/onaptests/scenario/cds_resource_resolution.py @@ -1,6 +1,7 @@ #!/usr/bin/env python """CDS resource resolution test scenario.""" -from onaptests.scenario.scenario_base import BaseStep, ScenarioBase, BaseScenarioStep +from onaptests.scenario.scenario_base import (BaseScenarioStep, BaseStep, + ScenarioBase) from onaptests.steps.onboard.cds import CbaProcessStep from onaptests.steps.simulator.cds_mockserver import \ CdsMockserverCnfConfigureStep diff --git a/src/onaptests/scenario/multi_vnf_macro.py b/src/onaptests/scenario/multi_vnf_macro.py index 47b1830..f4dfc71 100644 --- a/src/onaptests/scenario/multi_vnf_macro.py +++ b/src/onaptests/scenario/multi_vnf_macro.py @@ -1,7 +1,7 @@ """Instantiate basic vm using SO macro flow.""" +from onapsdk.configuration import settings from yaml import SafeLoader, load -from onapsdk.configuration import settings from onaptests.scenario.scenario_base import (BaseStep, ScenarioBase, YamlTemplateBaseScenarioStep) from onaptests.steps.instantiate.service_macro import \ diff --git a/src/onaptests/scenario/pnf_macro.py b/src/onaptests/scenario/pnf_macro.py index 88d42d1..10f9866 100644 --- a/src/onaptests/scenario/pnf_macro.py +++ b/src/onaptests/scenario/pnf_macro.py @@ -1,7 +1,7 @@ """Instantiate service with PNF using SO macro flow.""" +from onapsdk.configuration import settings from yaml import SafeLoader, load -from onapsdk.configuration import settings from onaptests.scenario.scenario_base import (BaseStep, ScenarioBase, YamlTemplateBaseScenarioStep) from onaptests.steps.instantiate.pnf_register_ves import \ diff --git a/src/onaptests/scenario/scenario_base.py b/src/onaptests/scenario/scenario_base.py index 7069afb..f19352a 100644 --- a/src/onaptests/scenario/scenario_base.py +++ b/src/onaptests/scenario/scenario_base.py @@ -1,10 +1,10 @@ import logging import time -from xtesting.core import testcase - from onapsdk.configuration import settings from onapsdk.exceptions import SDKException, SettingsError +from xtesting.core import testcase + from onaptests.steps.base import BaseStep, YamlTemplateBaseStep from onaptests.utils.exceptions import (OnapTestException, TestConfigurationException) diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py index 918bc6d..197afac 100644 --- a/src/onaptests/steps/base.py +++ b/src/onaptests/steps/base.py @@ -10,6 +10,7 @@ from typing import Iterator, List, Optional from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.configuration import settings from onapsdk.exceptions import SDKException, SettingsError + from onaptests.steps.reports_collection import (Report, ReportsCollection, ReportStepStatus) from onaptests.utils.exceptions import (OnapTestException, @@ -19,7 +20,6 @@ from onaptests.utils.exceptions import (OnapTestException, SubstepExecutionExceptionGroup, TestConfigurationException) - # pylint: disable=protected-access IF_FORCE_CLEANUP = "PYTHON_SDK_TESTS_FORCE_CLEANUP" diff --git a/src/onaptests/steps/cloud/check_status.py b/src/onaptests/steps/cloud/check_status.py index b3fab03..ee54c2f 100644 --- a/src/onaptests/steps/cloud/check_status.py +++ b/src/onaptests/steps/cloud/check_status.py @@ -11,10 +11,10 @@ from jinja2 import Environment, PackageLoader, select_autoescape from kubernetes import client, config from kubernetes.stream import stream from natural.date import delta +from onapsdk.configuration import settings from urllib3.exceptions import MaxRetryError, NewConnectionError from xtesting.core import testcase -from onapsdk.configuration import settings from onaptests.utils.exceptions import StatusCheckException from ..base import BaseStep @@ -721,13 +721,25 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep): """Init CheckNamespaceStatusStep.""" super().__init__(namespace=settings.K8S_ONAP_NAMESPACE, resource_type="") self.__logger.debug("K8s namespaces status test init started") - if settings.IN_CLUSTER: - config.load_incluster_config() - else: - config.load_kube_config(config_file=settings.K8S_CONFIG) + + self.job_list_step = None + self.pod_list_step = None + self.service_list_step = None + self.deployment_list_step = None + self.replicaset_list_step = None + self.statefulset_list_step = None + self.daemonset_list_step = None + self.configmap_list_step = None + self.secret_list_step = None + self.ingress_list_step = None + self.pvc_list_step = None + if not settings.IF_VALIDATION: + if settings.IN_CLUSTER: + config.load_incluster_config() + else: + config.load_kube_config(config_file=settings.K8S_CONFIG) for namespace in ([self.namespace] + settings.EXTRA_NAMESPACE_LIST): self._init_namespace_steps(namespace) - self.pods = [] self.services = [] self.jobs = [] @@ -747,17 +759,18 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep): self.failing_pvcs = [] def _init_namespace_steps(self, namespace: str): - self.job_list_step = CheckK8sJobsStep(namespace) - self.pod_list_step = CheckK8sPodsStep(namespace, self.job_list_step) - self.service_list_step = CheckK8sServicesStep(namespace, self.pod_list_step) - self.deployment_list_step = CheckK8sDeploymentsStep(namespace, self.pod_list_step) - self.replicaset_list_step = CheckK8sReplicaSetsStep(namespace, self.pod_list_step) - self.statefulset_list_step = CheckK8sStatefulSetsStep(namespace, self.pod_list_step) - self.daemonset_list_step = CheckK8sDaemonSetsStep(namespace, self.pod_list_step) - self.configmap_list_step = CheckK8sConfigMapsStep(namespace) - self.secret_list_step = CheckK8sSecretsStep(namespace) - self.ingress_list_step = CheckK8sIngressesStep(namespace) - self.pvc_list_step = CheckK8sPvcsStep(namespace) + if namespace == settings.K8S_ONAP_NAMESPACE: + self.job_list_step = CheckK8sJobsStep(namespace) + self.pod_list_step = CheckK8sPodsStep(namespace, self.job_list_step) + self.service_list_step = CheckK8sServicesStep(namespace, self.pod_list_step) + self.deployment_list_step = CheckK8sDeploymentsStep(namespace, self.pod_list_step) + self.replicaset_list_step = CheckK8sReplicaSetsStep(namespace, self.pod_list_step) + self.statefulset_list_step = CheckK8sStatefulSetsStep(namespace, self.pod_list_step) + self.daemonset_list_step = CheckK8sDaemonSetsStep(namespace, self.pod_list_step) + self.configmap_list_step = CheckK8sConfigMapsStep(namespace) + self.secret_list_step = CheckK8sSecretsStep(namespace) + self.ingress_list_step = CheckK8sIngressesStep(namespace) + self.pvc_list_step = CheckK8sPvcsStep(namespace) self.add_step(self.job_list_step) self.add_step(self.pod_list_step) self.add_step(self.service_list_step) diff --git a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py index 8307b45..2bc206d 100644 --- a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py +++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py @@ -3,10 +3,11 @@ from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.configuration import settings from ..base import BaseStep -from .customer_service_subscription_create import CustomerServiceSubscriptionCreateStep +from .customer_service_subscription_create import \ + CustomerServiceSubscriptionCreateStep +from .k8s_connectivity_info_create import K8SConnectivityInfoStep from .link_cloud_to_complex import LinkCloudRegionToComplexStep from .register_cloud import RegisterCloudRegionStep -from .k8s_connectivity_info_create import K8SConnectivityInfoStep class ConnectServiceSubToCloudRegionStep(BaseStep): diff --git a/src/onaptests/steps/cloud/customer_service_subscription_create.py b/src/onaptests/steps/cloud/customer_service_subscription_create.py index 533b2b8..170f033 100644 --- a/src/onaptests/steps/cloud/customer_service_subscription_create.py +++ b/src/onaptests/steps/cloud/customer_service_subscription_create.py @@ -1,6 +1,6 @@ from onapsdk.aai.business import Customer -from onapsdk.sdc.service import Service from onapsdk.configuration import settings +from onapsdk.sdc.service import Service from ..base import BaseStep from .customer_create import CustomerCreateStep diff --git a/src/onaptests/steps/cloud/expose_service_node_port.py b/src/onaptests/steps/cloud/expose_service_node_port.py index 4f6eecc..763d0b9 100644 --- a/src/onaptests/steps/cloud/expose_service_node_port.py +++ b/src/onaptests/steps/cloud/expose_service_node_port.py @@ -22,7 +22,7 @@ class ExposeServiceNodePortStep(BaseStep): self.service_name = service_name self.port = port self.node_port = node_port - self.k8s_client: client.CoreV1Api = client.CoreV1Api() + self.k8s_client: client.CoreV1Api = None @property def component(self) -> str: @@ -68,6 +68,7 @@ class ExposeServiceNodePortStep(BaseStep): config.load_incluster_config() else: config.load_kube_config(config_file=settings.K8S_CONFIG) + self.k8s_client: client.CoreV1Api = client.CoreV1Api() if not self.is_service_node_port_type(): try: self.k8s_client.patch_namespaced_service( diff --git a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py index 410ac47..73a4c1b 100644 --- a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py +++ b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py @@ -1,9 +1,9 @@ """Connectivity info creation module.""" from jinja2 import Environment, PackageLoader, select_autoescape - from onapsdk.configuration import settings from onapsdk.exceptions import APIError from onapsdk.k8s import ConnectivityInfo + from onaptests.steps.base import BaseStep diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py index 5035f86..00af163 100644 --- a/src/onaptests/steps/cloud/register_cloud.py +++ b/src/onaptests/steps/cloud/register_cloud.py @@ -5,6 +5,7 @@ from uuid import uuid4 from onapsdk.aai.cloud_infrastructure import CloudRegion from onapsdk.configuration import settings from onapsdk.exceptions import ResourceNotFound + from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep from ..base import BaseStep diff --git a/src/onaptests/steps/instantiate/k8s_profile_create.py b/src/onaptests/steps/instantiate/k8s_profile_create.py index 4be5684..9630ec4 100644 --- a/src/onaptests/steps/instantiate/k8s_profile_create.py +++ b/src/onaptests/steps/instantiate/k8s_profile_create.py @@ -1,14 +1,15 @@ from typing import Iterable from uuid import uuid4 -from yaml import load, SafeLoader from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.configuration import settings from onapsdk.exceptions import APIError, ResourceNotFound from onapsdk.k8s import Definition from onapsdk.so.instantiation import InstantiationParameter +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions + from ..base import BaseStep from .vnf_ala_carte import YamlTemplateVnfAlaCarteInstantiateStep diff --git a/src/onaptests/steps/instantiate/sdnc_service.py b/src/onaptests/steps/instantiate/sdnc_service.py index 851902a..7b8c600 100644 --- a/src/onaptests/steps/instantiate/sdnc_service.py +++ b/src/onaptests/steps/instantiate/sdnc_service.py @@ -5,6 +5,7 @@ from onapsdk.exceptions import APIError from onapsdk.sdnc import VfModulePreload from onapsdk.sdnc.preload import PreloadInformation from onapsdk.sdnc.services import Service + from onaptests.scenario.scenario_base import BaseScenarioStep from onaptests.steps.base import BaseStep from onaptests.utils.exceptions import OnapTestException diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py index 4a0a4c1..84be750 100644 --- a/src/onaptests/steps/instantiate/service_ala_carte.py +++ b/src/onaptests/steps/instantiate/service_ala_carte.py @@ -1,17 +1,19 @@ import time from uuid import uuid4 -from yaml import load, SafeLoader -from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.aai.business.owning_entity import OwningEntity as AaiOwningEntity +from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.configuration import settings from onapsdk.exceptions import ResourceNotFound from onapsdk.sdc.service import Service from onapsdk.so.instantiation import ServiceInstantiation +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions + from ..base import YamlTemplateBaseStep -from ..cloud.connect_service_subscription_to_cloud_region import ConnectServiceSubToCloudRegionStep +from ..cloud.connect_service_subscription_to_cloud_region import \ + ConnectServiceSubToCloudRegionStep from ..onboard.service import YamlTemplateServiceOnboardStep diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py index a513d1e..37c5318 100644 --- a/src/onaptests/steps/instantiate/service_macro.py +++ b/src/onaptests/steps/instantiate/service_macro.py @@ -2,7 +2,6 @@ import time from typing import List from uuid import uuid4 -from yaml import load, SafeLoader from onapsdk.aai.business.owning_entity import OwningEntity from onapsdk.aai.cloud_infrastructure.cloud_region import CloudRegion @@ -10,23 +9,18 @@ from onapsdk.aai.cloud_infrastructure.tenant import Tenant from onapsdk.configuration import settings from onapsdk.exceptions import ResourceNotFound from onapsdk.sdc.service import Service -from onapsdk.so.instantiation import ( - InstantiationParameter, - ServiceInstantiation, - VfmoduleParameters, - VnfParameters, - SoService -) -from onaptests.steps.cloud.customer_service_subscription_create import ( - CustomerServiceSubscriptionCreateStep -) +from onapsdk.so.instantiation import (InstantiationParameter, + ServiceInstantiation, SoService, + VfmoduleParameters, VnfParameters) +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions from onaptests.steps.base import YamlTemplateBaseStep -from onaptests.steps.onboard.service import YamlTemplateServiceOnboardStep -from onaptests.steps.cloud.connect_service_subscription_to_cloud_region import ( +from onaptests.steps.cloud.connect_service_subscription_to_cloud_region import \ ConnectServiceSubToCloudRegionStep -) +from onaptests.steps.cloud.customer_service_subscription_create import \ + CustomerServiceSubscriptionCreateStep +from onaptests.steps.onboard.service import YamlTemplateServiceOnboardStep class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py index e148e4c..e6fc32b 100644 --- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py +++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py @@ -1,15 +1,16 @@ from typing import Iterable from uuid import uuid4 -from yaml import load, SafeLoader from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.configuration import settings from onapsdk.so.instantiation import InstantiationParameter +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions + from ..base import YamlTemplateBaseStep -from .vnf_ala_carte import YamlTemplateVnfAlaCarteInstantiateStep from .k8s_profile_create import K8SProfileStep +from .vnf_ala_carte import YamlTemplateVnfAlaCarteInstantiateStep class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep): diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py index 72dcb2f..2d974b4 100644 --- a/src/onaptests/steps/instantiate/vl_ala_carte.py +++ b/src/onaptests/steps/instantiate/vl_ala_carte.py @@ -1,13 +1,14 @@ import re from typing import Iterable from uuid import uuid4 -from yaml import load, SafeLoader from onapsdk.configuration import settings -from onapsdk.so.instantiation import Subnet from onapsdk.sdc.service import Service +from onapsdk.so.instantiation import Subnet +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions + from ..base import YamlTemplateBaseStep from .service_ala_carte import YamlTemplateServiceAlaCarteInstantiateStep diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py index e45f71e..8ead082 100644 --- a/src/onaptests/steps/instantiate/vnf_ala_carte.py +++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py @@ -1,11 +1,12 @@ from uuid import uuid4 -from yaml import load, SafeLoader from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.configuration import settings from onapsdk.sdc.service import Service +from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions + from ..base import YamlTemplateBaseStep from .service_ala_carte import YamlTemplateServiceAlaCarteInstantiateStep diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py index 68a2dde..1d71db2 100644 --- a/src/onaptests/steps/loop/clamp.py +++ b/src/onaptests/steps/loop/clamp.py @@ -10,12 +10,12 @@ import random import string import time -from yaml import SafeLoader, load - -import onaptests.utils.exceptions as onap_test_exceptions from onapsdk.clamp.clamp_element import Clamp from onapsdk.configuration import settings from onapsdk.sdc.service import Service +from yaml import SafeLoader, load + +import onaptests.utils.exceptions as onap_test_exceptions from onaptests.steps.base import YamlTemplateBaseStep from onaptests.steps.loop.instantiate_loop import InstantiateLoop from onaptests.steps.onboard.clamp import OnboardClampStep diff --git a/src/onaptests/steps/loop/instantiate_loop.py b/src/onaptests/steps/loop/instantiate_loop.py index 3d34731..9aeefca 100644 --- a/src/onaptests/steps/loop/instantiate_loop.py +++ b/src/onaptests/steps/loop/instantiate_loop.py @@ -6,6 +6,7 @@ import logging.config from onapsdk.clamp.loop_instance import LoopInstance from onapsdk.configuration import settings + import onaptests.utils.exceptions as onap_test_exceptions diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py index c2fe191..4d64ee4 100644 --- a/src/onaptests/steps/onboard/clamp.py +++ b/src/onaptests/steps/onboard/clamp.py @@ -1,11 +1,10 @@ #!/usr/bin/python # http://www.apache.org/licenses/LICENSE-2.0 """Clamp Onboard service class.""" -from yaml import load, SafeLoader +from onapsdk.configuration import settings from onapsdk.sdc.service import Service from onapsdk.sdc.vf import Vf - -from onapsdk.configuration import settings +from yaml import SafeLoader, load from ..base import BaseStep, YamlTemplateBaseStep from .service import YamlTemplateVfOnboardStep diff --git a/src/onaptests/steps/onboard/msb_k8s.py b/src/onaptests/steps/onboard/msb_k8s.py index db8d934..7727ea7 100644 --- a/src/onaptests/steps/onboard/msb_k8s.py +++ b/src/onaptests/steps/onboard/msb_k8s.py @@ -4,7 +4,8 @@ from onapsdk.k8s import Definition, Profile from onaptests.steps.base import BaseStep from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep -from onaptests.steps.cloud.k8s_connectivity_info_create import K8SConnectivityInfoStep +from onaptests.steps.cloud.k8s_connectivity_info_create import \ + K8SConnectivityInfoStep class CreateDefinitionStep(BaseStep): diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py index 8e0cd12..9b8119a 100644 --- a/src/onaptests/steps/onboard/pnf.py +++ b/src/onaptests/steps/onboard/pnf.py @@ -4,6 +4,7 @@ from onapsdk.configuration import settings from onapsdk.sdc.pnf import Pnf from onapsdk.sdc.vendor import Vendor from onapsdk.sdc.vsp import Vsp + from ..base import BaseStep, YamlTemplateBaseStep from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py index d2391b3..738454f 100644 --- a/src/onaptests/steps/onboard/service.py +++ b/src/onaptests/steps/onboard/service.py @@ -1,6 +1,5 @@ import time from typing import Any, Dict -from yaml import load, SafeLoader import onapsdk.constants as onapsdk_const from onapsdk.configuration import settings @@ -11,6 +10,7 @@ from onapsdk.sdc.properties import ComponentProperty from onapsdk.sdc.service import Service, ServiceInstantiationType from onapsdk.sdc.vf import Vf from onapsdk.sdc.vl import Vl +from yaml import SafeLoader, load from ..base import BaseStep, YamlTemplateBaseStep from .pnf import PnfOnboardStep, YamlTemplatePnfOnboardStep diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py index 0c68835..e3a4cf8 100644 --- a/src/onaptests/steps/onboard/vf.py +++ b/src/onaptests/steps/onboard/vf.py @@ -1,9 +1,10 @@ -from pathlib import Path import time +from pathlib import Path from onapsdk.configuration import settings from onapsdk.sdc.vf import Vf from onapsdk.sdc.vsp import Vsp + from onaptests.utils.resources import get_resource_location from ..base import BaseStep, YamlTemplateBaseStep diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py index 36e78df..24bae77 100644 --- a/src/onaptests/steps/onboard/vsp.py +++ b/src/onaptests/steps/onboard/vsp.py @@ -1,6 +1,7 @@ from onapsdk.configuration import settings from onapsdk.sdc.vendor import Vendor from onapsdk.sdc.vsp import Vsp + from onaptests.utils.resources import get_resource_location from ..base import BaseStep, YamlTemplateBaseStep diff --git a/src/onaptests/steps/reports_collection.py b/src/onaptests/steps/reports_collection.py index dfdc09a..2f92660 100644 --- a/src/onaptests/steps/reports_collection.py +++ b/src/onaptests/steps/reports_collection.py @@ -1,11 +1,13 @@ +import json from dataclasses import dataclass from enum import Enum -import json from pathlib import Path from typing import List + from jinja2 import Environment, FileSystemLoader, select_autoescape from onapsdk.configuration import settings from onapsdk.exceptions import SettingsError + from onaptests.utils.resources import get_resource_location diff --git a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py index 0ecc2ca..acfa990 100644 --- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py +++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py @@ -7,8 +7,8 @@ from typing import Tuple import requests import urllib3 from kubernetes import client, config, watch - from onapsdk.configuration import settings + from onaptests.steps.base import BaseStep from onaptests.steps.instantiate.msb_k8s import CreateInstanceStep from onaptests.utils.exceptions import (EnvironmentPreparationException, diff --git a/src/onaptests/steps/wrapper/helm_charts.py b/src/onaptests/steps/wrapper/helm_charts.py index 874e1ff..b15d52b 100644 --- a/src/onaptests/steps/wrapper/helm_charts.py +++ b/src/onaptests/steps/wrapper/helm_charts.py @@ -2,11 +2,11 @@ import yaml from avionix import ChartBuilder, ChartDependency, ChartInfo from avionix.errors import HelmError + from onaptests.steps.base import BaseStep +from onaptests.utils.exceptions import (EnvironmentCleanupException, + EnvironmentPreparationException) from onaptests.utils.resources import get_local_dir -from onaptests.utils.exceptions import ( - EnvironmentPreparationException, - EnvironmentCleanupException) class HelmChartStep(BaseStep): diff --git a/src/onaptests/steps/wrapper/start.py b/src/onaptests/steps/wrapper/start.py index e08f108..a5dadab 100644 --- a/src/onaptests/steps/wrapper/start.py +++ b/src/onaptests/steps/wrapper/start.py @@ -1,7 +1,9 @@ """Start simulators via simulators' API.""" -from typing import Union, Optional, Dict +from typing import Dict, Optional, Union + import requests from onapsdk.configuration import settings + from onaptests.steps.base import BaseStep from onaptests.utils.exceptions import TestConfigurationException diff --git a/src/onaptests/utils/resources.py b/src/onaptests/utils/resources.py index 71e56d6..82bc709 100644 --- a/src/onaptests/utils/resources.py +++ b/src/onaptests/utils/resources.py @@ -1,6 +1,7 @@ """Standard functions for the simulator wrapper.""" import os from importlib.resources import path + import onaptests diff --git a/tox.ini b/tox.ini index 2ce589d..da36574 100644 --- a/tox.ini +++ b/tox.ini @@ -57,6 +57,7 @@ commands = /bin/bash -c "coala --non-interactive --disable-caching --no-autoapply-warn md --files $(