aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/scenario
diff options
context:
space:
mode:
authormrichomme <morgan.richomme@orange.com>2020-10-13 12:52:24 +0200
committermrichomme <morgan.richomme@orange.com>2020-10-14 11:27:35 +0200
commitb7b9796d16a2e53e0e58ae9888dade1e89a0cc19 (patch)
tree379944906ed2c5a837dc1e09810235fd03a37e8b /src/onaptests/scenario
parent6276bed4df9b8458c4b6805edab81652fb15de76 (diff)
Improve xtesting integration
All the exceptions shall be caught by the use case Issue-ID: TEST-257 Signed-off-by: mrichomme <morgan.richomme@orange.com> Change-Id: Ie2762ad869d8984ce2125db4a8ef4990ee50f82a Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/scenario')
-rw-r--r--src/onaptests/scenario/basic_vm.py48
-rw-r--r--src/onaptests/scenario/clearwater_ims.py34
2 files changed, 57 insertions, 25 deletions
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."""
diff --git a/src/onaptests/scenario/clearwater_ims.py b/src/onaptests/scenario/clearwater_ims.py
index 83a654e..0177e02 100644
--- a/src/onaptests/scenario/clearwater_ims.py
+++ b/src/onaptests/scenario/clearwater_ims.py
@@ -29,19 +29,27 @@ class ClearwaterIms(testcase.TestCase):
"""Run vIMS test."""
self.start_time = time.time()
self.__logger.debug("start time")
- self.test.execute()
- self.__logger.info("VNF clearwater IMS 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 clearwater IMS 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 clearwater IMS successfully created")
+ # The cleanup is part of the test, not only a teardown action
+ if settings.CLEANUP_FLAG:
+ self.__logger.info("VNF clearwater IMS 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
+ self.stop_time = time.time()
+ except:
+ self.__logger.error("Clearwater IMS test case failed.")
+ self.result = 0
+ self.stop_time = time.time()
def clean(self):
"""Clean Additional resources if needed."""
- pass
+ try:
+ self.test.reports_collection.generate_report()
+ except:
+ self.__logger.error("Impossible to generate reporting")