aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/scenario
diff options
context:
space:
mode:
authorJulien Fontaine <julien.fontaine@bell.ca>2021-08-04 15:52:02 -0400
committerOleg Mitsura <oleg.mitsura@amdocs.com>2021-10-19 06:44:23 -0400
commitc3ef82f489b915095b7464fb119daf43b84f67f8 (patch)
tree5d6ce5b4896e4b0b0844dfccb0ebd59f2c72f244 /src/onaptests/scenario
parent062f7ed7f73ed61dc3990c3a23403fd544ae6261 (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
Diffstat (limited to 'src/onaptests/scenario')
-rw-r--r--src/onaptests/scenario/basic_vm_macro.py4
-rw-r--r--src/onaptests/scenario/multi_vnf_macro.py139
-rw-r--r--src/onaptests/scenario/pnf_macro.py4
3 files changed, 147 insertions, 0 deletions
diff --git a/src/onaptests/scenario/basic_vm_macro.py b/src/onaptests/scenario/basic_vm_macro.py
index f22ee12..67dded9 100644
--- a/src/onaptests/scenario/basic_vm_macro.py
+++ b/src/onaptests/scenario/basic_vm_macro.py
@@ -72,6 +72,10 @@ class BasicVmMacroStep(YamlTemplateBaseStep):
return self._yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> dict:
"""Service name.
diff --git a/src/onaptests/scenario/multi_vnf_macro.py b/src/onaptests/scenario/multi_vnf_macro.py
new file mode 100644
index 0000000..284baf0
--- /dev/null
+++ b/src/onaptests/scenario/multi_vnf_macro.py
@@ -0,0 +1,139 @@
+"""Instantiate basic vm using SO macro flow."""
+import logging
+import time
+
+from yaml import load
+
+from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
+from xtesting.core import testcase
+
+from onaptests.steps.base import YamlTemplateBaseStep
+from onaptests.steps.onboard.cds import CbaPublishStep
+from onaptests.utils.exceptions import OnapTestException
+from onaptests.steps.instantiate.service_macro import YamlTemplateServiceMacroInstantiateStep
+
+
+class MultiVnfUbuntuMacroStep(YamlTemplateBaseStep):
+
+ def __init__(self, cleanup=False):
+ """Initialize step.
+
+ Substeps:
+ - CbaPublishStep
+ - YamlTemplateServiceAlaCarteInstantiateStep.
+ """
+ super().__init__(cleanup=cleanup)
+ self._yaml_template: dict = None
+ self._model_yaml_template: dict = None
+ self.add_step(CbaPublishStep(
+ cleanup=settings.CLEANUP_FLAG
+ ))
+ self.add_step(YamlTemplateServiceMacroInstantiateStep(
+ cleanup=settings.CLEANUP_FLAG
+ ))
+
+ @property
+ def description(self) -> str:
+ """Step description.
+
+ Used for reports
+
+ Returns:
+ str: Step description
+
+ """
+ return "Multi VNF Ubuntu macro scenario step"
+
+ @property
+ def component(self) -> str:
+ """Component name.
+
+ Name of component which step is related with.
+ Most is the name of ONAP component.
+
+ Returns:
+ str: Component name
+
+ """
+ return "PythonSDK-tests"
+
+ @property
+ def yaml_template(self) -> dict:
+ """YAML template abstract property.
+
+ Every YAML template step need to implement that property.
+
+ Returns:
+ dict: YAML template
+
+ """
+ if not self._yaml_template:
+ with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ self._yaml_template: dict = load(yaml_template)
+ return self._yaml_template
+
+ @property
+ def model_yaml_template(self) -> dict:
+ 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
+
+ @property
+ def service_name(self) -> dict:
+ """Service name.
+
+ Get from YAML template.
+
+ Returns:
+ str: Service name
+
+ """
+ return next(iter(self.yaml_template.keys()))
+
+ @property
+ def service_instance_name(self) -> str:
+ """Service instance name.
+
+ Returns:
+ str: Service instance name
+
+ """
+ return settings.SERVICE_INSTANCE_NAME
+
+
+class MultiVnfUbuntuMacro(testcase.TestCase):
+ """Instantiate a basic vm macro."""
+
+ __logger = logging.getLogger(__name__)
+
+ def __init__(self, **kwargs):
+ """Init Basic Macro use case."""
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = 'nso_ubuntu_macro'
+ super().__init__(**kwargs)
+ self.__logger.debug("NSO Ubuntu macro init started")
+ self.test = MultiVnfUbuntuMacro(cleanup=settings.CLEANUP_FLAG)
+
+ def run(self):
+ """Run NSO Ubuntu macro test."""
+ self.start_time = time.time()
+ try:
+ self.test.execute()
+ self.__logger.info("Starting to clean up in {} seconds".format(settings.CLEANUP_ACTIVITY_TIMER))
+ time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
+ self.test.cleanup()
+ self.result = 100
+ except OnapTestException as exc:
+ self.result = 0
+ self.__logger.error(exc.error_message)
+ except SDKException:
+ self.result = 0
+ self.__logger.error("SDK Exception")
+ finally:
+ self.stop_time = time.time()
+
+ def clean(self):
+ """Generate report."""
+ self.test.reports_collection.generate_report()
diff --git a/src/onaptests/scenario/pnf_macro.py b/src/onaptests/scenario/pnf_macro.py
index e86557b..73a2adf 100644
--- a/src/onaptests/scenario/pnf_macro.py
+++ b/src/onaptests/scenario/pnf_macro.py
@@ -76,6 +76,10 @@ class PnfMacroScenarioStep(YamlTemplateBaseStep):
return self._yaml_template
@property
+ def model_yaml_template(self) -> dict:
+ return {}
+
+ @property
def service_name(self) -> dict:
"""Service name.