Catch onaptests and onapsdk exceptions in scenario to generate test report if test fails
Issue-ID: INT-1852
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: Id9772fea10dc5aa323437e72c6fe5ddb4c6caabb
from xtesting.core import testcase
from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
-import onaptests.utils.exceptions as onap_test_exceptions
from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
+from onaptests.utils.exceptions import OnapTestException
class BasicCnf(testcase.TestCase):
"""Onboard then instantiate a simple CNF with ONAP."""
else:
self.__logger.info("No cleanup requested. Test completed.")
self.result = 100
- except onap_test_exceptions.OnapTestException as exc:
+ except (OnapTestException, SDKException) as exc:
self.result = 0
self.__logger.error(exc.error_message)
finally:
from onapsdk.configuration import settings
from onapsdk.exceptions import SDKException
-import onaptests.utils.exceptions as onap_test_exceptions
from onaptests.steps.instantiate.vl_ala_carte import YamlTemplateVlAlaCarteInstantiateStep
+from onaptests.utils.exceptions import OnapTestException
class BasicNetwork(testcase.TestCase):
"""Onboard then instantiate a simple Network with ONAP."""
else:
self.__logger.info("No cleanup requested. Test completed.")
self.result = 100
- except onap_test_exceptions.OnapTestException as exc:
+ except (OnapTestException, SDKException) as exc:
self.result = 0
self.__logger.error(exc.error_message)
finally:
import time
from xtesting.core import testcase
from onapsdk.configuration import settings
-import onaptests.utils.exceptions as onap_test_exceptions
+from onapsdk.exceptions import SDKException
from onaptests.steps.onboard.service import YamlTemplateServiceOnboardStep
+from onaptests.utils.exceptions import OnapTestException
class BasicOnboard(testcase.TestCase):
"""Onboard a simple VM with ONAP."""
self.test.execute()
self.__logger.info("VNF basic_vm successfully onboarded")
self.result = 100
- except onap_test_exceptions.OnapTestException as exc:
+ except (OnapTestException, SDKException) as exc:
self.result = 0
self.__logger.error(exc.error_message)
finally:
from onapsdk.configuration import settings
from onapsdk.exceptions import SDKException
-import onaptests.utils.exceptions as onap_test_exceptions
from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
+from onaptests.utils.exceptions import OnapTestException
class BasicVm(testcase.TestCase):
"""Onboard then instantiate a simple VM with ONAP."""
else:
self.__logger.info("No cleanup requested. Test completed.")
self.result = 100
- except onap_test_exceptions.OnapTestException as exc:
+ except (OnapTestException, SDKException) as exc:
self.result = 0
self.__logger.error(exc.error_message)
- except SDKException as error:
- self.__logger.info("service error {0}".format(error))
finally:
self.stop_time = time.time()
import time
from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
from xtesting.core import testcase
from onaptests.steps.onboard.cds import CbaEnrichStep
+from onaptests.utils.exceptions import OnapTestException
class CDSBlueprintEnrichment(testcase.TestCase):
def run(self):
self.__logger.debug("CDS blueprint enrichment run")
self.start_time = time.time()
- self.test.execute()
- self.result = 100
+ try:
+ self.test.execute()
+ self.result = 100
+ except (OnapTestException, SDKException) as exc:
+ self.result = 0
+ self.__logger.error(exc.error_message)
self.stop_time = time.time()
def clean(self):
from xtesting.core import testcase
from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
-import onaptests.utils.exceptions as onap_test_exceptions
from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
+from onaptests.utils.exceptions import OnapTestException
class ClearwaterIms(testcase.TestCase):
"""Onboard then instantiate a clearwater vIMS with ONAP."""
self.__logger.info("No cleanup requested. Test completed.")
self.result = 100
self.stop_time = time.time()
- except onap_test_exceptions.OnapTestException as exc:
+ except (OnapTestException, SDKException) as exc:
self.result = 0
self.__logger.error(exc.error_message)
finally:
"""Instantiate service with PNF using SO macro flow."""
+import time
from yaml import load
from xtesting.core import testcase
from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
from onaptests.steps.base import YamlTemplateBaseStep
from onaptests.steps.onboard.cds import CbaEnrichStep
from onaptests.steps.simulator.pnf_simulator_cnf.pnf_register import PnfSimulatorCnfRegisterStep
from onaptests.steps.instantiate.service_macro import YamlTemplateServiceMacroInstantiateStep
+from onaptests.utils.exceptions import OnapTestException
class PnfMacroScenarioStep(YamlTemplateBaseStep):
def run(self):
"""Run PNF macro test."""
- self.test.execute()
- self.test.cleanup()
+ self.start_time = time.time()
+ try:
+ self.test.execute()
+ self.test.cleanup()
+ self.result = 100
+ except (OnapTestException, SDKException) as exc:
+ self.result = 0
+ self.__logger.error(exc.error_message)
+ finally:
+ self.stop_time = time.time()
def clean(self):
"""Generate report."""