aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-12-23 13:40:11 +0100
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2022-01-12 22:09:13 +0000
commit22664610f99038223f996ef1c1661872a92e4ee4 (patch)
tree081ea2904008e25718f4bf5cf4ed17f73d3a4782 /src/onaptests/steps
parent2bd16f8898e6fd74e64b1500eb5fbc4448517d1a (diff)
[TEST] Basic CNF macro
Basic CNF macro added with refactoring that enables debugging under IDE Also SDK upgraded to 9.2 what required adaptation in existing tests Issue-ID: TEST-376 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I697857bc0c13e86b88b71c3b46e0c4b59751939c Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/base.py20
-rw-r--r--src/onaptests/steps/cloud/customer_service_subscription_create.py2
-rw-r--r--src/onaptests/steps/instantiate/k8s_profile_create.py12
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py6
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py16
-rw-r--r--src/onaptests/steps/instantiate/vf_module_ala_carte.py4
-rw-r--r--src/onaptests/steps/instantiate/vl_ala_carte.py4
-rw-r--r--src/onaptests/steps/instantiate/vnf_ala_carte.py4
-rw-r--r--src/onaptests/steps/loop/clamp.py4
-rw-r--r--src/onaptests/steps/onboard/cds.py4
-rw-r--r--src/onaptests/steps/onboard/clamp.py4
-rw-r--r--src/onaptests/steps/onboard/service.py4
-rw-r--r--src/onaptests/steps/onboard/vf.py4
-rw-r--r--src/onaptests/steps/onboard/vsp.py8
-rw-r--r--src/onaptests/steps/reports_collection.py8
-rw-r--r--src/onaptests/steps/wrapper/helm_charts.py2
16 files changed, 63 insertions, 43 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 97c9159..b7651bb 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -168,6 +168,13 @@ class BaseStep(ABC):
try:
if cleanup:
self._start_cleanup_time = time.time()
+ self._logger.info("*****************************************************")
+ self._logger.info(f"START [{self.component}] {self.name} cleanup: {self.description}")
+ self._logger.info("*****************************************************")
+ else:
+ self._logger.info("*****************************************************")
+ self._logger.info(f"START [{self.component}] {self.name}: {self.description}")
+ self._logger.info("*****************************************************")
execution_status: Optional[ReportStepStatus] = None
ret = fun(self, *args, **kwargs)
execution_status = ReportStepStatus.PASS
@@ -180,12 +187,18 @@ class BaseStep(ABC):
raise
finally:
if cleanup:
+ self._logger.info("*****************************************************")
+ self._logger.info(f"STOP [{self.component}] {self.name} cleanup: {self.description}")
+ self._logger.info("*****************************************************")
self._cleanup_report = Report(
step_description=f"[{self.component}] {self.name} cleanup: {self.description}",
step_execution_status=execution_status,
step_execution_duration=time.time() - self._start_cleanup_time
)
else:
+ self._logger.info("*****************************************************")
+ self._logger.info(f"STOP [{self.component}] {self.name}: {self.description}")
+ self._logger.info("*****************************************************")
if not self._start_execution_time:
if execution_status != ReportStepStatus.NOT_EXECUTED:
self._logger.error("No execution start time saved for %s step. Fix it by call `super.execute()` "
@@ -210,6 +223,10 @@ class BaseStep(ABC):
step.execute()
except (OnapTestException, SDKException) as substep_err:
raise SubstepExecutionException from substep_err
+ if self._steps:
+ self._logger.info("*****************************************************")
+ self._logger.info(f"CONTINUE [{self.component}] {self.name}: {self.description}")
+ self._logger.info("*****************************************************")
self._start_execution_time = time.time()
def cleanup(self) -> None:
@@ -218,6 +235,9 @@ class BaseStep(ABC):
Not all steps has to have cleanup method
"""
+ self._logger.info("*****************************")
+ self._logger.info("Start Cleanup step: " + self.name)
+ self._logger.info("*****************************")
if self._cleanup:
for step in self._steps:
try:
diff --git a/src/onaptests/steps/cloud/customer_service_subscription_create.py b/src/onaptests/steps/cloud/customer_service_subscription_create.py
index b318dc7..67de141 100644
--- a/src/onaptests/steps/cloud/customer_service_subscription_create.py
+++ b/src/onaptests/steps/cloud/customer_service_subscription_create.py
@@ -39,4 +39,4 @@ class CustomerServiceSubscriptionCreateStep(BaseStep):
super().execute()
service = Service(name=settings.SERVICE_NAME)
customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- customer.subscribe_service(service)
+ customer.subscribe_service(service.name)
diff --git a/src/onaptests/steps/instantiate/k8s_profile_create.py b/src/onaptests/steps/instantiate/k8s_profile_create.py
index d09d924..a5c8552 100644
--- a/src/onaptests/steps/instantiate/k8s_profile_create.py
+++ b/src/onaptests/steps/instantiate/k8s_profile_create.py
@@ -1,6 +1,6 @@
from typing import Iterable
from uuid import uuid4
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
@@ -48,7 +48,7 @@ class K8SProfileStep(BaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
@@ -124,8 +124,8 @@ class K8SProfileStep(BaseStep):
for vf_module in vnf_instance.vnf.vf_modules:
# Define profile (rb_profile) for resource bundle definition
# Retrieve resource bundle definition (rbdef) corresponding to vf module
- rbdef_name = vf_module.metadata["vfModuleModelInvariantUUID"]
- rbdef_version = vf_module.metadata["vfModuleModelCustomizationUUID"]
+ rbdef_name = vf_module.model_invariant_uuid
+ rbdef_version = vf_module.model_customization_id
rbdef = Definition.get_definition_by_name_version(rbdef_name, rbdef_version)
# Get k8s profile name from yaml service template
vnf_parameters = self.get_vnf_parameters(vnf_instance.vnf.name)
@@ -160,8 +160,8 @@ class K8SProfileStep(BaseStep):
# possible to have several modules for 1 VNF
for vf_module in vnf_instance.vnf.vf_modules:
# Retrieve resource bundle definition (rbdef) corresponding to vf module
- rbdef_name = vf_module.metadata["vfModuleModelInvariantUUID"]
- rbdef_version = vf_module.metadata["vfModuleModelCustomizationUUID"]
+ rbdef_name = vf_module.model_invariant_uuid
+ rbdef_version = vf_module.model_customization_id
rbdef = Definition.get_definition_by_name_version(rbdef_name, rbdef_version)
# Get k8s profile name from yaml service template
vnf_parameters = self.get_vnf_parameters(vnf_instance.vnf.name)
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index 3407e8e..a2e1812 100644
--- a/src/onaptests/steps/instantiate/service_ala_carte.py
+++ b/src/onaptests/steps/instantiate/service_ala_carte.py
@@ -1,6 +1,6 @@
import time
from uuid import uuid4
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
@@ -130,7 +130,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
@@ -188,6 +188,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
super().execute()
service = Service(self.service_name)
customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
+ service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(service.name)
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -230,6 +231,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
customer,
owning_entity,
settings.PROJECT,
+ service_subscription,
service_instance_name=self.service_instance_name
)
try:
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index b169049..dc2ce89 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -3,7 +3,7 @@ import time
from typing import List
from uuid import uuid4
from onapsdk.aai.business.service import ServiceInstance
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.business.customer import Customer, ServiceSubscription
from onapsdk.aai.business.owning_entity import OwningEntity
@@ -13,7 +13,6 @@ 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 onapsdk.vid import LineOfBusiness, Platform, Project
from onaptests.steps.cloud.customer_service_subscription_create import CustomerServiceSubscriptionCreateStep
import onaptests.utils.exceptions as onap_test_exceptions
@@ -73,7 +72,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
@@ -144,6 +143,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
super().execute()
service = Service(self.service_name)
customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
+ service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(service.name)
if any(
filter(lambda x: x in self.yaml_template[self.service_name].keys(),
["vnfs", "networks"])):
@@ -161,9 +161,6 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
except ResourceNotFound:
self._logger.info("Owning entity not found, create it")
owning_entity = OwningEntity.create(settings.OWNING_ENTITY)
- vid_project: Project = Project(settings.PROJECT)
- line_of_business: LineOfBusiness = LineOfBusiness(settings.LINE_OF_BUSINESS)
- platform: Platform = Platform(settings.PLATFORM)
# Before instantiating, be sure that the service has been distributed
self._logger.info("******** Check Service Distribution *******")
@@ -210,11 +207,12 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
sdc_service=service,
customer=customer,
owning_entity=owning_entity,
- project=vid_project,
- line_of_business=line_of_business,
- platform=platform,
+ project=settings.PROJECT,
+ line_of_business=settings.LINE_OF_BUSINESS,
+ platform=settings.PLATFORM,
cloud_region=cloud_region,
tenant=tenant,
+ service_subscription=service_subscription,
service_instance_name=self.service_instance_name,
vnf_parameters=vnf_params_list,
enable_multicloud=settings.USE_MULTICLOUD,
diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
index af569fe..38bdee9 100644
--- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
@@ -1,6 +1,6 @@
from typing import Iterable
from uuid import uuid4
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
@@ -56,7 +56,7 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py
index 3f81228..7186c24 100644
--- a/src/onaptests/steps/instantiate/vl_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vl_ala_carte.py
@@ -1,7 +1,7 @@
import re
from typing import Iterable
from uuid import uuid4
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
@@ -51,7 +51,7 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py
index 8dbec78..eb9896f 100644
--- a/src/onaptests/steps/instantiate/vnf_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py
@@ -1,5 +1,5 @@
from uuid import uuid4
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
@@ -49,7 +49,7 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py
index 9a705f2..c614857 100644
--- a/src/onaptests/steps/loop/clamp.py
+++ b/src/onaptests/steps/loop/clamp.py
@@ -6,7 +6,7 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
"""Clamp Scenario class."""
-from yaml import load
+from yaml import load, SafeLoader
import random
import string
import time
@@ -57,7 +57,7 @@ class ClampStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 7f91d56..d6645ef 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -214,7 +214,9 @@ class CbaPublishStep(CDSBaseStep):
def __init__(self, cleanup=False) -> None:
"""Initialize CBA publish step."""
super().__init__(cleanup=cleanup)
- self.add_step(CbaEnrichStep(cleanup=cleanup))
+ """Let's skip enrichment if enriched CBA is already present"""
+ if Path.is_file(settings.CDS_CBA_UNENRICHED):
+ self.add_step(CbaEnrichStep(cleanup=cleanup))
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
index 9d73a8e..72daba2 100644
--- a/src/onaptests/steps/onboard/clamp.py
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# http://www.apache.org/licenses/LICENSE-2.0
"""Clamp Onboard service class."""
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.sdc.service import Service
from onapsdk.sdc.vf import Vf
@@ -49,7 +49,7 @@ class OnboardClampStep(YamlTemplateBaseStep):
if self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index db1b330..6f1e69f 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -1,6 +1,6 @@
import time
from typing import Any, Dict
-from yaml import load
+from yaml import load, SafeLoader
from onapsdk.configuration import settings
from onapsdk.exceptions import APIError, ResourceNotFound
@@ -117,7 +117,7 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
elif self.is_root:
if not self._yaml_template:
with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
- self._yaml_template: dict = load(yaml_template)
+ self._yaml_template: dict = load(yaml_template, SafeLoader)
return self._yaml_template
return self.parent.yaml_template
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index 44c3749..852cb82 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -1,10 +1,10 @@
from pathlib import Path
-import sys
import time
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
from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
@@ -113,7 +113,7 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
vf.create()
artifact_file_path: Path = Path(vnf["vnf_artifact_file_path"])
if not artifact_file_path.exists():
- artifact_file_path = Path(sys.path[-1], artifact_file_path)
+ artifact_file_path = Path(get_resource_location(artifact_file_path))
vf.add_deployment_artifact(
artifact_type=vnf["vnf_artifact_type"],
artifact_name=vnf["vnf_artifact_name"],
diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py
index 5462c55..f898268 100644
--- a/src/onaptests/steps/onboard/vsp.py
+++ b/src/onaptests/steps/onboard/vsp.py
@@ -1,7 +1,7 @@
-import sys
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
from .vendor import VendorOnboardStep
@@ -105,8 +105,7 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
if "vnfs" in self.yaml_template:
for vnf in self.yaml_template["vnfs"]:
- with open(
- sys.path[-1] + "/" + vnf["heat_files_to_upload"], "rb") as package:
+ with open(get_resource_location(vnf["heat_files_to_upload"]), "rb") as package:
vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP",
vendor=vendor,
package=package)
@@ -114,8 +113,7 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
elif "pnfs" in self.yaml_template:
for pnf in self.yaml_template["pnfs"]:
if "heat_files_to_upload" in pnf:
- with open(
- sys.path[-1] + "/" + pnf["heat_files_to_upload"], "rb") as package:
+ with open(get_resource_location(pnf["heat_files_to_upload"]), "rb") as package:
vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP",
vendor=vendor,
package=package)
diff --git a/src/onaptests/steps/reports_collection.py b/src/onaptests/steps/reports_collection.py
index 52a0fec..4b7f79b 100644
--- a/src/onaptests/steps/reports_collection.py
+++ b/src/onaptests/steps/reports_collection.py
@@ -1,10 +1,10 @@
-import sys
from dataclasses import dataclass
from enum import Enum
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
class ReportStepStatus(Enum):
@@ -58,8 +58,8 @@ class ReportsCollection:
int: How many steps failed
"""
- return sum((1 for step_report in self.report if \
- step_report.step_execution_status == ReportStepStatus.FAIL))
+ return sum((1 for step_report in self.report if
+ step_report.step_execution_status == ReportStepStatus.FAIL))
def generate_report(self) -> None:
usecase = settings.SERVICE_NAME
@@ -75,7 +75,7 @@ class ReportsCollection:
jinja_env = Environment(
autoescape=select_autoescape(['html']),
- loader=FileSystemLoader(sys.path[-1] + '/onaptests/templates/reporting'))
+ loader=FileSystemLoader(get_resource_location('templates/reporting')))
jinja_env.get_template('reporting.html.j2').stream(
report=self,
diff --git a/src/onaptests/steps/wrapper/helm_charts.py b/src/onaptests/steps/wrapper/helm_charts.py
index 4482683..b8a6b21 100644
--- a/src/onaptests/steps/wrapper/helm_charts.py
+++ b/src/onaptests/steps/wrapper/helm_charts.py
@@ -3,7 +3,7 @@ import yaml
from avionix import ChartBuilder, ChartDependency, ChartInfo
from avionix.errors import HelmError
from onaptests.steps.base import BaseStep
-from onaptests.utils.simulators import get_local_dir
+from onaptests.utils.resources import get_local_dir
from onaptests.utils.exceptions import (
EnvironmentPreparationException,
EnvironmentCleanupException)