diff options
author | Panagiotis Karalis <pkaralis@intracom-telecom.com> | 2018-05-18 16:29:39 +0300 |
---|---|---|
committer | Manuel Buil <mbuil@suse.com> | 2018-06-12 11:29:24 +0000 |
commit | 37d5bca7cc52709e89d434345560cfe1d90e2e52 (patch) | |
tree | d6c016789585451030c70cfc82c25384738d7394 /sfc/tests/functest/run_sfc_tests.py | |
parent | 77dfb2e6eb0f3c872ec25cc6196d13b5ddfe0a3b (diff) |
Rethink the clean up process
Using the '--nocleanup' parameter as part of command,
the cleanup mechanism could be disable.
Otherwise, the cleanup method is executed even if a exception has been raised.
Change-Id: I9638369900f599793393feb5184c30b74f1b7c7e
Signed-off-by: Panagiotis Karalis <pkaralis@intracom-telecom.com>
Diffstat (limited to 'sfc/tests/functest/run_sfc_tests.py')
-rw-r--r-- | sfc/tests/functest/run_sfc_tests.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sfc/tests/functest/run_sfc_tests.py b/sfc/tests/functest/run_sfc_tests.py index 7c0b9d15..1c1dc455 100644 --- a/sfc/tests/functest/run_sfc_tests.py +++ b/sfc/tests/functest/run_sfc_tests.py @@ -29,6 +29,13 @@ COMMON_CONFIG = sfc_config.CommonConfig() class SfcFunctest(testcase.TestCase): + def __init__(self): + super(SfcFunctest, self).__init__() + + self.cleanup_flag = True + if '--nocleanup' in sys.argv: + self.cleanup_flag = False + def __fetch_tackerc_file(self, controller_node): rc_file = os.path.join(COMMON_CONFIG.sfc_test_dir, 'tackerc') if not os.path.exists(rc_file): @@ -159,6 +166,7 @@ class SfcFunctest(testcase.TestCase): tc_class = getattr(module, test_cfg['class_name']) tc_instance = tc_class(testcase_config, supported_installers, vnf_names) + cleanup_run_flag = False start_time = time.time() try: result, creators = tc_instance.run() @@ -166,6 +174,11 @@ class SfcFunctest(testcase.TestCase): logger.error("Exception when executing: %s" % test_name) logger.error(e) result = {'status': 'FAILED'} + creators = tc_instance.get_creators() + if self.cleanup_flag is True: + sfc_cleanup.cleanup(creators, odl_ip=odl_ip, + odl_port=odl_port) + cleanup_run_flag = True end_time = time.time() duration = end_time - start_time logger.info("Results of test case '%s - %s':\n%s\n" % @@ -183,7 +196,10 @@ class SfcFunctest(testcase.TestCase): dic = {"duration": duration, "status": status} self.details.update({test_name: dic}) - sfc_cleanup.cleanup(creators, odl_ip=odl_ip, odl_port=odl_port) + + if cleanup_run_flag is not True and self.cleanup_flag is True: + sfc_cleanup.cleanup(creators, odl_ip=odl_ip, + odl_port=odl_port) self.stop_time = time.time() |