diff options
Diffstat (limited to 'sdnvpn/test/functest')
-rw-r--r-- | sdnvpn/test/functest/config.yaml | 8 | ||||
-rw-r--r-- | sdnvpn/test/functest/run_sdnvpn_tests.py | 163 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_1.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_2.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_3.py | 14 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_4.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_7.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_8.py | 10 |
8 files changed, 85 insertions, 152 deletions
diff --git a/sdnvpn/test/functest/config.yaml b/sdnvpn/test/functest/config.yaml index 6f09cd5..ddaca9f 100644 --- a/sdnvpn/test/functest/config.yaml +++ b/sdnvpn/test/functest/config.yaml @@ -5,13 +5,10 @@ testcases: sdnvpn.test.functest.tempest: enabled: true description: Neutron BGPVPN tests in tempest - testname_db: functest_tempest # declared name in the test api - # http://testresults.opnfv.org/test/api/v1/projects/sdnvpn/cases sdnvpn.test.functest.testcase_1: enabled: true description: VPN provides connectivity between subnets - testname_db: functest_testcase_1 instance_1_name: sdnvpn-1-1 instance_2_name: sdnvpn-1-2 instance_3_name: sdnvpn-1-3 @@ -35,7 +32,6 @@ testcases: sdnvpn.test.functest.testcase_2: enabled: true description: Tenant separation - testname_db: functest_testcase_2 instance_1_name: sdnvpn-2-1 instance_2_name: sdnvpn-2-2 instance_3_name: sdnvpn-2-3 @@ -69,7 +65,6 @@ testcases: sdnvpn.test.functest.testcase_3: enabled: true description: Data center gateway integration - testname_db: functest_testcase_3 secgroup_name: sdnvpn-sg secgroup_descr: Security group for SDNVPN test cases image_name: sdnvpn-image @@ -93,7 +88,6 @@ testcases: sdnvpn.test.functest.testcase_4: enabled: true description: VPN provides connectivity between subnets using router association - testname_db: functest_testcase_4 instance_1_name: sdnvpn-4-1 instance_2_name: sdnvpn-4-2 instance_3_name: sdnvpn-4-3 @@ -117,7 +111,6 @@ testcases: sdnvpn.test.functest.testcase_7: enabled: false description: Network associate VPNs with routers attached (ODL Bug 6962) - testname_db: functest_testcase_7 image_name: sdnvpn-image instance_1_name: sdnvpn-7-1 instance_2_name: sdnvpn-7-2 @@ -137,7 +130,6 @@ testcases: sdnvpn.test.functest.testcase_8: enabled: true description: Test floating IP and router assoc coexistence - testname_db: functest_testcase_8 image_name: sdnvpn-image instance_1_name: sdnvpn-8-1 instance_2_name: sdnvpn-8-2 diff --git a/sdnvpn/test/functest/run_sdnvpn_tests.py b/sdnvpn/test/functest/run_sdnvpn_tests.py index e671264..6fe7558 100644 --- a/sdnvpn/test/functest/run_sdnvpn_tests.py +++ b/sdnvpn/test/functest/run_sdnvpn_tests.py @@ -8,7 +8,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import importlib import logging import os @@ -17,99 +16,91 @@ import time import traceback import yaml -import functest.utils.functest_utils as ft_utils +from functest.core import testcase from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib.gather_logs import gather_logs -logger = logging.getLogger('sdnvpn-run-tests') - COMMON_CONFIG = sdnvpn_config.CommonConfig() -TEST_DB_URL = COMMON_CONFIG.test_db - - -def push_results(testname, start_time, end_time, criteria, details): - logger.info("Push testcase '%s' results into the DB...\n" % testname) - ft_utils.push_results_to_db("sdnvpn", - testname, - start_time, - end_time, - criteria, - details) - - -def main(report=False): - # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-100 - # and SDNVPN-126 - cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1" - logger.info("Setting subnet/net quota to unlimited : %s" % cmd_line) - cmd = os.popen(cmd_line) - output = cmd.read() - logger.debug(output) - - # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115 - cmd_line = "nova quota-class-update --instances -1 default" - logger.info("Setting instances quota to unlimited : %s" % cmd_line) - cmd = os.popen(cmd_line) - output = cmd.read() - logger.debug(output) - - with open(COMMON_CONFIG.config_file) as f: - config_yaml = yaml.safe_load(f) - - testcases = config_yaml.get("testcases") - overall_status = "PASS" - for testcase in testcases: - if testcases[testcase]['enabled']: - test_name = testcase - test_descr = testcases[testcase]['description'] - test_name_db = testcases[testcase]['testname_db'] - title = ("Running '%s - %s'" % - (test_name, test_descr)) - logger.info(title) - logger.info("%s\n" % ("=" * len(title))) - t = importlib.import_module(testcase, package=None) - start_time = time.time() - try: - result = t.main() - except Exception as ex: - result = -1 - logger.info("Caught Exception in %s: %s Trace: %s" % - (test_name, ex, traceback.format_exc())) - end_time = time.time() - if result < 0: - status = "FAIL" - overall_status = "FAIL" - logger.info("Testcase %s failed" % test_name) - else: - status = result.get("status") - details = result.get("details") - logger.info("Results of test case '%s - %s':\n%s\n" % - (test_name, test_descr, result)) - - if status == "FAIL": + + +class SdnvpnFunctest(testcase.TestCase): + + __logger = logging.getLogger(__name__) + + def run(self): + self.start_time = time.time() + + cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1" + self.__logger.info("Setting subnet/net quota to unlimited : %s" + % cmd_line) + cmd = os.popen(cmd_line) + output = cmd.read() + self.__logger.debug(output) + + # Workaround for + # https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115 + cmd_line = "nova quota-class-update --instances -1 default" + self.__logger.info("Setting instances quota to unlimited : %s" + % cmd_line) + cmd = os.popen(cmd_line) + output = cmd.read() + self.__logger.debug(output) + + with open(COMMON_CONFIG.config_file) as f: + config_yaml = yaml.safe_load(f) + + testcases = config_yaml.get("testcases") + overall_status = "PASS" + for tc in testcases: + if testcases[tc]['enabled']: + test_name = tc + test_descr = testcases[tc]['description'] + title = ("Running '%s - %s'" % + (test_name, test_descr)) + self.__logger.info(title) + self.__logger.info("%s\n" % ("=" * len(title))) + module = 'sdnvpn.test.functest.' + test_name + t = importlib.import_module(module, package=None) + try: + result = t.main() + except Exception as ex: + result = -1 + self.__logger.info("Caught Exception in %s: %s Trace: %s" + % (test_name, ex, + traceback.format_exc())) + if result < 0: + status = "FAIL" overall_status = "FAIL" + self.__logger.info("Testcase %s failed" % test_name) + else: + status = result.get("status") + self.details.update( + {test_name: {'status': status, + 'details': result.get("details")}}) + self.__logger.info("Results of test case '%s - %s':\n%s\n" + % (test_name, test_descr, result)) + + if status == "FAIL": + overall_status = "FAIL" + + self.stop_time = time.time() - if report: - push_results( - test_name_db, start_time, end_time, status, details) + try: + gather_logs('overall') + except Exception as ex: + self.__logger.error(('Something went wrong in the Log gathering.' + 'Ex: %s, Trace: %s') + % ex, traceback.format_exc()) - try: - gather_logs('overall') - except Exception as ex: - logger.error(('Something went wrong in the Log gathering.' - 'Ex: %s, Trace: %s') - % ex, traceback.format_exc()) - if overall_status == "FAIL": - sys.exit(-1) + if overall_status == "PASS": + self.result = 100 + return testcase.TestCase.EX_OK - sys.exit(0) + return testcase.TestCase.EX_RUN_ERROR if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) - parser = argparse.ArgumentParser() - parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - args = parser.parse_args() - main(report=args.report) + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s' + '- %(levelname)s - %(message)s') + SDNVPN = SdnvpnFunctest() + sys.exit(SDNVPN.run()) diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index 540fe9a..fc45143 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -8,7 +8,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import logging import sys @@ -18,15 +17,7 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() - -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-1') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_1') diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py index cea93ce..c904cfb 100644 --- a/sdnvpn/test/functest/testcase_2.py +++ b/sdnvpn/test/functest/testcase_2.py @@ -8,7 +8,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import logging import sys @@ -18,15 +17,7 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() - -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-2') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_2') diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index 058a270..44e7366 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -12,7 +12,6 @@ # - Add the functest Quagga as a neighbor # - Verify that the OpenDaylight and gateway Quagga peer -import argparse import logging import os import sys @@ -24,18 +23,11 @@ from sdnvpn.lib import utils as test_utils from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib.results import Results -COMMON_CONFIG = sdnvpn_config.CommonConfig() -TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig("testcase_3") - -logger = logging.getLogger('sdnvpn-testcase-3') -parser = argparse.ArgumentParser() +logger = logging.getLogger(__name__) -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() +COMMON_CONFIG = sdnvpn_config.CommonConfig() +TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig("testcase_3") def main(): diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py index 0ca1563..7e6677b 100644 --- a/sdnvpn/test/functest/testcase_4.py +++ b/sdnvpn/test/functest/testcase_4.py @@ -8,7 +8,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import logging import sys @@ -18,15 +17,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-4') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_4') diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index 607a299..15a8ebf 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -18,7 +18,6 @@ network associated: - Assign a floating IP to a VM - Ping it """ -import argparse import logging import sys @@ -27,15 +26,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-7') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_7') diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index 11f13bb..773f73c 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -18,7 +18,6 @@ Test whether router assoc can coexist with floating IP - Assign a floating IP to the VM in the router assoc network - Ping it the floating ip """ -import argparse import logging import sys @@ -27,15 +26,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-8') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_8') |