aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
authorJulien Fontaine <julien.fontaine@bell.ca>2021-08-04 15:52:02 -0400
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-11-08 17:20:12 +0000
commit17fd4b701a3ba21b656719a5991190d02eb51dc2 (patch)
tree5d6ce5b4896e4b0b0844dfccb0ebd59f2c72f244 /src/onaptests/steps
parent3eb2f52a40c0f420ada67c03fc58307237d764fa (diff)
[TEST] Added support for multi-vnf macro instantiation
Decoupled service YAML template into a model YAML template and a (SO) service YAML template. Model YAML template will be used during the onboarding steps and service YAML template will be used to generate payload when sending instantiation request to SO. Service YAML template reference model name to use for its VNF/VF-Modules using "model_name" field. This provide more flexibility to design the testcase and enables to setup more complex testcases like instantiating several VNF/VF-MOdules using the same SDC model infos. This patch aims to provide backward compatibility for existing testcases based on YAML template. Issue-ID: TEST-358 Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca> Change-Id: I69d370eff4d383d5af135206476c65e4a56e4ee5 (cherry picked from commit c3ef82f489b915095b7464fb119daf43b84f67f8)
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/base.py12
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py4
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py65
-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/clamp.py4
-rw-r--r--src/onaptests/steps/onboard/pnf.py4
-rw-r--r--src/onaptests/steps/onboard/service.py22
-rw-r--r--src/onaptests/steps/onboard/vf.py17
-rw-r--r--src/onaptests/steps/onboard/vsp.py17
12 files changed, 141 insertions, 20 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 744fc7b..4d6858d 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -247,3 +247,15 @@ class YamlTemplateBaseStep(BaseStep, ABC):
dict: YAML template
"""
+
+ @property
+ @abstractmethod
+ def model_yaml_template(self) -> dict:
+ """Model YAML template abstract property.
+
+ Every YAML template step need to implement that property.
+
+ Returns:
+ dict: YAML template
+
+ """
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index dd62f52..3407e8e 100644
--- a/src/onaptests/steps/instantiate/service_ala_carte.py
+++ b/src/onaptests/steps/instantiate/service_ala_carte.py
@@ -135,6 +135,10 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index d83d2fe..b169049 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -12,7 +12,8 @@ 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
+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
@@ -34,6 +35,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
"""
super().__init__(cleanup=cleanup)
self._yaml_template: dict = None
+ self._model_yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: str = None
if not settings.ONLY_INSTANTIATE:
@@ -76,6 +78,23 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ """Step Model YAML template.
+
+ Load from file if it's a root step, get from parent otherwise.
+
+ Returns:
+ dict: Step YAML template
+
+ """
+ if self.is_root:
+ if not self._model_yaml_template:
+ with open(settings.MODEL_YAML_TEMPLATE, "r") as model_yaml_template:
+ self._model_yaml_template: dict = load(model_yaml_template)
+ return self._model_yaml_template
+ return self.parent.model_yaml_template
+
+ @property
def service_name(self) -> str:
"""Service name.
@@ -142,6 +161,9 @@ 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 *******")
@@ -163,31 +185,40 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
if distribution_completed is False:
self._logger.error(
- "Service Distribution for %s failed !!",service.name)
+ "Service Distribution for %s failed !!", service.name)
raise onap_test_exceptions.ServiceDistributionException
+ so_service = None
vnf_params_list: List[VnfParameters] = []
- for vnf_data in self.yaml_template[self.service_name].get("vnfs", []):
- vnf_params_list.append(VnfParameters(
- vnf_data["vnf_name"],
- [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in vnf_data.get("vnf_parameters", [])],
- [VfmoduleParameters(vf_module_data["vf_module_name"],
- [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in vf_module_data.get("parameters", [])]) \
+ if settings.MODEL_YAML_TEMPLATE:
+ so_data = self.yaml_template[self.service_name]
+ so_service = SoService(vnfs=so_data.get("vnfs", []),
+ subscription_service_type=so_data.get('subscription_service_type'))
+ else:
+ for vnf_data in self.yaml_template[self.service_name].get("vnfs", []):
+ vnf_params_list.append(VnfParameters(
+ vnf_data["vnf_name"],
+ [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in
+ vnf_data.get("vnf_parameters", [])],
+ [VfmoduleParameters(vf_module_data["vf_module_name"],
+ [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for
+ parameter in vf_module_data.get("parameters", [])]) \
for vf_module_data in vnf_data.get("vf_module_parameters", [])]
- ))
+ ))
service_instantiation = ServiceInstantiation.instantiate_macro(
- service,
+ sdc_service=service,
customer=customer,
owning_entity=owning_entity,
- project=settings.PROJECT,
- line_of_business=settings.LINE_OF_BUSINESS,
- platform=settings.PLATFORM,
+ project=vid_project,
+ line_of_business=line_of_business,
+ platform=platform,
cloud_region=cloud_region,
tenant=tenant,
service_instance_name=self.service_instance_name,
vnf_parameters=vnf_params_list,
- enable_multicloud=settings.USE_MULTICLOUD
+ enable_multicloud=settings.USE_MULTICLOUD,
+ so_service=so_service
)
try:
service_instantiation.wait_for_finish(timeout=settings.ORCHESTRATION_REQUEST_TIMEOUT)
@@ -197,9 +228,9 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
if service_instantiation.failed:
self._logger.error("Service instantiation %s failed", self.service_instance_name)
raise onap_test_exceptions.ServiceInstantiateException
- else:
- service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(self.service_name)
- self._service_instance: ServiceInstance = service_subscription.get_service_instance_by_name(self.service_instance_name)
+
+ service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(self.service_name)
+ self._service_instance: ServiceInstance = service_subscription.get_service_instance_by_name(self.service_instance_name)
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
index aacecc3..af569fe 100644
--- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
@@ -61,6 +61,10 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py
index 3bb293a..158e437 100644
--- a/src/onaptests/steps/instantiate/vl_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vl_ala_carte.py
@@ -56,6 +56,10 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py
index b02c7ea..8dbec78 100644
--- a/src/onaptests/steps/instantiate/vnf_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py
@@ -54,6 +54,10 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py
index 86bcbb0..9a705f2 100644
--- a/src/onaptests/steps/loop/clamp.py
+++ b/src/onaptests/steps/loop/clamp.py
@@ -62,6 +62,10 @@ class ClampStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
index afbd7cb..9d73a8e 100644
--- a/src/onaptests/steps/onboard/clamp.py
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -54,6 +54,10 @@ class OnboardClampStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py
index 2ec44e2..4e3303e 100644
--- a/src/onaptests/steps/onboard/pnf.py
+++ b/src/onaptests/steps/onboard/pnf.py
@@ -99,6 +99,10 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""
return self.parent.yaml_template[self.parent.service_name]
+ @property
+ def model_yaml_template(self) -> dict:
+ return {}
+
@YamlTemplateBaseStep.store_state
def execute(self):
"""Onboard PNFs from YAML template."""
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index ee2d3ab..db1b330 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -86,6 +86,7 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""
super().__init__(cleanup=cleanup)
self._yaml_template: dict = None
+ self._model_yaml_template: dict = None
if "vnfs" in self.yaml_template[self.service_name]:
self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
if "pnfs" in self.yaml_template[self.service_name]:
@@ -111,7 +112,9 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
dict: Step YAML template
"""
- if self.is_root:
+ if settings.MODEL_YAML_TEMPLATE:
+ return self.model_yaml_template
+ 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)
@@ -119,6 +122,23 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
return self.parent.yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ """Step Model YAML template.
+
+ Load from file if it's a root step, get from parent otherwise.
+
+ Returns:
+ dict: Step YAML template
+
+ """
+ if self.is_root:
+ if not self._model_yaml_template:
+ with open(settings.MODEL_YAML_TEMPLATE, "r") as model_yaml_template:
+ self._model_yaml_template: dict = load(model_yaml_template)
+ return self._model_yaml_template
+ return self.parent.model_yaml_template
+
+ @property
def service_name(self) -> str:
"""Service name.
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index 76aaf2e..44c3749 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -80,7 +80,22 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
dict: YAML template
"""
- return self.parent.yaml_template[self.parent.service_name]
+ if settings.MODEL_YAML_TEMPLATE:
+ return self.model_yaml_template
+ else:
+ return self.parent.yaml_template[self.parent.service_name]
+
+ @property
+ def model_yaml_template(self) -> dict:
+ """Step Model YAML template.
+
+ Load from file if it's a root step, get from parent otherwise.
+
+ Returns:
+ dict: Step YAML template
+
+ """
+ return self.parent.model_yaml_template[self.parent.service_name]
@YamlTemplateBaseStep.store_state
def execute(self):
diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py
index 6f8fbf6..5462c55 100644
--- a/src/onaptests/steps/onboard/vsp.py
+++ b/src/onaptests/steps/onboard/vsp.py
@@ -77,7 +77,22 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
dict: YAML template
"""
- return self.parent.yaml_template
+ if settings.MODEL_YAML_TEMPLATE:
+ return self.model_yaml_template
+ else:
+ return self.parent.yaml_template
+
+ @property
+ def model_yaml_template(self) -> dict:
+ """Model YAML template.
+
+ Get model YAML template from parent.
+
+ Returns:
+ dict: YAML template
+
+ """
+ return self.parent.model_yaml_template
@YamlTemplateBaseStep.store_state
def execute(self):