aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-05-18 16:29:39 +0300
committerManuel Buil <mbuil@suse.com>2018-06-12 11:29:24 +0000
commit37d5bca7cc52709e89d434345560cfe1d90e2e52 (patch)
treed6c016789585451030c70cfc82c25384738d7394
parent77dfb2e6eb0f3c872ec25cc6196d13b5ddfe0a3b (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>
-rw-r--r--sfc/tests/functest/run_sfc_tests.py18
-rw-r--r--sfc/tests/functest/sfc_chain_deletion.py8
-rw-r--r--sfc/tests/functest/sfc_one_chain_two_service_functions.py8
-rw-r--r--sfc/tests/functest/sfc_parent_function.py26
-rw-r--r--sfc/tests/functest/sfc_symmetric_chain.py8
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py8
6 files changed, 58 insertions, 18 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()
diff --git a/sfc/tests/functest/sfc_chain_deletion.py b/sfc/tests/functest/sfc_chain_deletion.py
index 849c2971..ffb7e2e2 100644
--- a/sfc/tests/functest/sfc_chain_deletion.py
+++ b/sfc/tests/functest/sfc_chain_deletion.py
@@ -93,6 +93,14 @@ class SfcChainDeletion(sfc_parent_function.SfcCommonTestCase):
if __name__ == 'sfc.tests.functest.sfc_chain_deletion':
return results.compile_summary(), self.creators
+ def get_creators(self):
+ """Return the creators info, specially in case the info is not
+ returned due to an exception.
+
+ :return: creators
+ """
+ return self.creators
+
if __name__ == '__main__':
diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
index eeb2ec8c..bd333377 100644
--- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py
+++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
@@ -76,6 +76,14 @@ class SfcOneChainTwoServiceTC(sfc_parent_function.SfcCommonTestCase):
'sfc.tests.functest.sfc_one_chain_two_service_functions':
return results.compile_summary(), self.creators
+ def get_creators(self):
+ """Return the creators info, specially in case the info is not
+ returned due to an exception.
+
+ :return: creators
+ """
+ return self.creators
+
if __name__ == '__main__':
diff --git a/sfc/tests/functest/sfc_parent_function.py b/sfc/tests/functest/sfc_parent_function.py
index a16fa6a7..0db00f03 100644
--- a/sfc/tests/functest/sfc_parent_function.py
+++ b/sfc/tests/functest/sfc_parent_function.py
@@ -1,5 +1,4 @@
import os
-import sys
import logging
import sfc.lib.test_utils as test_utils
import sfc.lib.openstack_utils as os_sfc_utils
@@ -22,7 +21,7 @@ results = Results(COMMON_CONFIG.line_length)
class SfcCommonTestCase(object):
- def __init__(self, testcase_config, supported_installers, vnfs):
+ def __init__(self, testcase_config, supported_installers, vnfs):
self.compute_nodes = None
self.controller_clients = None
@@ -75,17 +74,15 @@ class SfcCommonTestCase(object):
installer_type = os.environ.get("INSTALLER_TYPE")
if installer_type not in supported_installers:
- logger.error(
+ raise Exception(
'\033[91mYour installer is not supported yet\033[0m')
- sys.exit(1)
installer_ip = os.environ.get("INSTALLER_IP")
if not installer_ip:
logger.error(
'\033[91minstaller ip is not set\033[0m')
- logger.error(
+ raise Exception(
'\033[91mexport INSTALLER_IP=<ip>\033[0m')
- sys.exit(1)
cluster = COMMON_CONFIG.installer_cluster
openstack_nodes = (deployment_handler.get_nodes({'cluster': cluster})
@@ -108,8 +105,7 @@ class SfcCommonTestCase(object):
COMMON_CONFIG.disk_size_in_gb,
COMMON_CONFIG.vcpu_count)
if not custom_flv:
- logger.error("Failed to create custom flavor")
- sys.exit(1)
+ raise Exception("Failed to create custom flavor")
controller_nodes = [node for node in openstack_nodes
if node.is_controller()]
@@ -222,8 +218,7 @@ class SfcCommonTestCase(object):
self.vnf_id = os_sfc_utils.wait_for_vnf(self.tacker_client,
vnf_name=vnf_names)
if self.vnf_id is None:
- logger.error('ERROR while booting vnfs')
- sys.exit(1)
+ raise Exception('ERROR while booting vnfs')
def assign_floating_ip_client_server(self):
"""Assign floating IPs on the router about server and the client
@@ -266,15 +261,13 @@ class SfcCommonTestCase(object):
for ip in fips:
logger.info("Checking connectivity towards floating IP [%s]" % ip)
if not test_utils.ping(ip, retries=50, retry_timeout=3):
- logger.error("Cannot ping floating IP [%s]" % ip)
os_sfc_utils.get_tacker_items()
odl_utils.get_odl_items(self.odl_ip, self.odl_port)
- sys.exit(1)
+ raise Exception("Cannot ping floating IP [%s]" % ip)
logger.info("Successful ping to floating IP [%s]" % ip)
if not test_utils.check_ssh(self.fips_sfs):
- logger.error("Cannot establish SSH connection to the SFs")
- sys.exit(1)
+ raise Exception("Cannot establish SSH connection to the SFs")
def start_services_in_vm(self):
"""Start the HTTP server in the server VM as well as the vxlan tool for
@@ -285,9 +278,8 @@ class SfcCommonTestCase(object):
logger.info("Starting HTTP server on %s" % self.server_floating_ip)
if not test_utils.start_http_server(self.server_floating_ip):
- logger.error('\033[91mFailed to start HTTP server on %s\033[0m'
- % self.server_floating_ip)
- sys.exit(1)
+ raise Exception('\033[91mFailed to start HTTP server on %s\033[0m'
+ % self.server_floating_ip)
for sf_floating_ip in self.fips_sfs:
logger.info("Starting vxlan_tool on %s" % sf_floating_ip)
diff --git a/sfc/tests/functest/sfc_symmetric_chain.py b/sfc/tests/functest/sfc_symmetric_chain.py
index 067854db..b1400a71 100644
--- a/sfc/tests/functest/sfc_symmetric_chain.py
+++ b/sfc/tests/functest/sfc_symmetric_chain.py
@@ -138,6 +138,14 @@ class SfcSymmetricChain(sfc_parent_function.SfcCommonTestCase):
if __name__ == 'sfc.tests.functest.sfc_symmetric_chain':
return results.compile_summary(), self.creators
+ def get_creators(self):
+ """Return the creators info, specially in case the info is not
+ returned due to an exception.
+
+ :return: creators
+ """
+ return self.creators
+
def wait_for_classification_rules(ovs_logger, compute_nodes,
server_compute, server_port,
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
index 56a434f1..7a65f548 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -99,6 +99,14 @@ class SfcTwoChainsSSHandHTTP(sfc_parent_function.SfcCommonTestCase):
if __name__ == 'sfc.tests.functest.sfc_two_chains_SSH_and_HTTP':
return results.compile_summary(), self.creators
+ def get_creators(self):
+ """Return the creators info, specially in case the info is not
+ returned due to an exception.
+
+ :return: creators
+ """
+ return self.creators
+
if __name__ == '__main__':