diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-07-20 10:15:32 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-07-30 11:49:19 +0000 |
commit | c9b3ea89ea31773cdb6ee343dc6ea803d0371739 (patch) | |
tree | d6b73bdffaa65452b67a06a64e2e3ebaf136a877 /src/onaptests/scenario/cds_resource_resolution.py | |
parent | 7fbd9f67fa43997bc8b030ab24dcc4315493c1b1 (diff) |
CDS resource-resolution test
Issue-ID: TEST-291
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I441f2486b38481624eeefa18f47840d4c7a3db9d
Diffstat (limited to 'src/onaptests/scenario/cds_resource_resolution.py')
-rw-r--r-- | src/onaptests/scenario/cds_resource_resolution.py | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/onaptests/scenario/cds_resource_resolution.py b/src/onaptests/scenario/cds_resource_resolution.py new file mode 100644 index 0000000..11df77f --- /dev/null +++ b/src/onaptests/scenario/cds_resource_resolution.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python +"""CDS resource resolution test scenario.""" + +import logging +import time + +from onapsdk.configuration import settings +from onapsdk.exceptions import SDKException +from xtesting.core import testcase + +from onaptests.steps.base import BaseStep +from onaptests.steps.onboard.cds import CbaProcessStep +from onaptests.steps.simulator.cds_mockserver import CdsMockserverCnfConfigureStep +from onaptests.utils.exceptions import OnapTestException + + +class CDSResourceResolutionStep(BaseStep): + """Step created to run scenario and generate report.""" + + def __init__(self, cleanup=False): + """Initialize step. + + Substeps: + - CdsMockserverCnfConfigureStep, + - CbaProcessStep. + """ + super().__init__(cleanup=cleanup) + self.add_step(CdsMockserverCnfConfigureStep( + cleanup=settings.CLEANUP_FLAG + )) + self.add_step(CbaProcessStep( + cleanup=settings.CLEANUP_FLAG + )) + + @property + def description(self) -> str: + """Step description. + + Used for reports + + Returns: + str: Step description + + """ + return "CDS resource-resoulution base step" + + @property + def component(self) -> str: + """Component name. + + Name of the component this step relates to. + Usually the name of ONAP component. + + Returns: + str: Component name + + """ + return "PythonSDK-tests" + + +class CDSResourceResolution(testcase.TestCase): + """Enrich simple blueprint using CDS blueprintprocessor.""" + + __logger = logging.getLogger(__name__) + + def __init__(self, **kwargs): + """Init CDS resource resolution use case.""" + if "case_name" not in kwargs: + kwargs["case_name"] = 'basic_cds' + super().__init__(**kwargs) + self.__logger.debug("CDS resource resolution initialization") + self.test = CDSResourceResolutionStep( + cleanup=settings.CLEANUP_FLAG) + self.start_time = None + self.stop_time = None + self.result = 0 + + def run(self): + self.__logger.debug("CDS resource resolution run") + self.start_time = time.time() + try: + self.test.execute() + 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): + """Clean Additional resources if needed.""" + self.__logger.info("Generate Test report") + self.test.reports_collection.generate_report() |