From b7b9796d16a2e53e0e58ae9888dade1e89a0cc19 Mon Sep 17 00:00:00 2001 From: mrichomme Date: Tue, 13 Oct 2020 12:52:24 +0200 Subject: Improve xtesting integration All the exceptions shall be caught by the use case Issue-ID: TEST-257 Signed-off-by: mrichomme Change-Id: Ie2762ad869d8984ce2125db4a8ef4990ee50f82a Signed-off-by: mrichomme --- src/onaptests/scenario/basic_vm.py | 48 ++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'src/onaptests/scenario/basic_vm.py') diff --git a/src/onaptests/scenario/basic_vm.py b/src/onaptests/scenario/basic_vm.py index 48fd169..35cedbc 100644 --- a/src/onaptests/scenario/basic_vm.py +++ b/src/onaptests/scenario/basic_vm.py @@ -5,6 +5,7 @@ import time from xtesting.core import testcase from onapsdk.configuration import settings +import onaptests.utils.exceptions as onap_test_exceptions from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep class BasicVm(testcase.TestCase): @@ -29,18 +30,41 @@ class BasicVm(testcase.TestCase): """Run onap_tests with ubuntu16 VM.""" self.start_time = time.time() self.__logger.debug("start time") - self.test.execute() - self.__logger.info("VNF basic_vm successfully created") - self.stop_time = time.time() - # The cleanup is part of the test, not only a teardown action - if settings.CLEANUP_FLAG: - self.__logger.info("VNF basic_vm cleanup called") - time.sleep(settings.CLEANUP_ACTIVITY_TIMER) - self.test.cleanup() - self.result = 100 - else: - self.__logger.info("No cleanup requested. Test completed.") - self.result = 100 + try: + self.test.execute() + self.__logger.info("VNF basic_vm successfully created") + # The cleanup is part of the test, not only a teardown action + if settings.CLEANUP_FLAG: + self.__logger.info("VNF basic_vm cleanup called") + time.sleep(settings.CLEANUP_ACTIVITY_TIMER) + self.test.cleanup() + self.result = 100 + else: + self.__logger.info("No cleanup requested. Test completed.") + self.result = 100 + except onap_test_exceptions.TestConfigurationException: + self.result = 0 + self.__logger.error("Basic VM configuration error") + except onap_test_exceptions.ServiceInstantiateException: + self.result = 0 + self.__logger.error("Basic VM instantiation error") + except onap_test_exceptions.ServiceCleanupException: + self.result = 0 + self.__logger.error("Basic VM instance cleanup error") + except onap_test_exceptions.VnfInstantiateException: + self.result = 0 + self.__logger.error("Basic VM Vnf instantiation error") + except onap_test_exceptions.VnfCleanupException: + self.result = 0 + self.__logger.error("Basic VM Vnf instance cleanup error") + except onap_test_exceptions.VfModuleInstantiateException: + self.result = 0 + self.__logger.error("Basic VM Module instantiation error") + except onap_test_exceptions.VfModuleCleanupException: + self.__logger.error("Basic VM Module cleanup failed.") + self.result = 0 + finally: + self.stop_time = time.time() def clean(self): """Clean Additional resources if needed.""" -- cgit 1.2.3-korg