From c31b7fb464fbb8bb0c7d8d2b3dc7b20f4a04cff5 Mon Sep 17 00:00:00 2001 From: Michal Jagiello Date: Tue, 20 Jul 2021 10:15:32 +0000 Subject: [TEST] CDS resource-resolution test Issue-ID: TEST-291 Signed-off-by: Michal Jagiello Change-Id: I5d9f55b67942c62f63e11282ef2383fe063d3137 --- src/onaptests/scenario/cds_resource_resolution.py | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/onaptests/scenario/cds_resource_resolution.py (limited to 'src/onaptests/scenario/cds_resource_resolution.py') diff --git a/src/onaptests/scenario/cds_resource_resolution.py b/src/onaptests/scenario/cds_resource_resolution.py new file mode 100644 index 0000000..7e9635f --- /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=cleanup + )) + self.add_step(CbaProcessStep( + cleanup=cleanup + )) + + @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() -- cgit 1.2.3-korg