X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Frun_tests.py;h=af8f51dd0460d13b80d118c85c40ecf0034fd1cb;hb=55961f67b74c39a9ab8ec2e5e7b9d9d170fc496f;hp=a024dd7202689f9161a78ae0e5b079f2b7bf8d93;hpb=1c3a04fd4779c828ac6f6b5806bdf68cb4fff04f;p=functest.git diff --git a/ci/run_tests.py b/ci/run_tests.py index a024dd720..af8f51dd0 100755 --- a/ci/run_tests.py +++ b/ci/run_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python -u # # Author: Jose Lausuch (jose.lausuch@ericsson.com) # @@ -8,11 +8,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import datetime import os import re import sys + +import argparse + import functest.ci.generate_report as generate_report import functest.ci.tier_builder as tb import functest.utils.functest_logger as ft_logger @@ -20,7 +22,7 @@ import functest.utils.functest_utils as ft_utils import functest.utils.openstack_clean as os_clean import functest.utils.openstack_snapshot as os_snapshot import functest.utils.openstack_utils as os_utils - +from functest.testcases.Controllers.ODL.OpenDaylightTesting import ODLTestCases parser = argparse.ArgumentParser() parser.add_argument("-t", "--test", dest="test", action='store', @@ -39,9 +41,7 @@ logger = ft_logger.Logger("run_tests").getLogger() """ global variables """ -REPOS_DIR = os.getenv('repos_dir') -FUNCTEST_REPO = ("%s/functest/" % REPOS_DIR) -EXEC_SCRIPT = ("%sci/exec_test.sh" % FUNCTEST_REPO) +EXEC_SCRIPT = ("%s/ci/exec_test.sh" % ft_utils.FUNCTEST_REPO) CLEAN_FLAG = True REPORT_FLAG = False EXECUTED_TEST_CASES = [] @@ -75,6 +75,13 @@ def cleanup(): os_clean.main() +def update_test_info(test_name, result, duration): + for test in EXECUTED_TEST_CASES: + if test['test_name'] == test_name: + test.update({"result": result, + "duration": duration}) + + def run_test(test, tier_name): global OVERALL_RESULT, EXECUTED_TEST_CASES result_str = "PASS" @@ -93,9 +100,15 @@ def run_test(test, tier_name): if REPORT_FLAG: flags += " -r" - cmd = ("%s%s" % (EXEC_SCRIPT, flags)) - logger.debug("Executing command '%s'" % cmd) - result = ft_utils.execute_command(cmd, logger, exit_on_error=False) + if test_name == 'odl': + result = ODLTestCases.functest_run() + if result and REPORT_FLAG: + result = ODLTestCases.push_to_db() + result = not result + else: + cmd = ("%s%s" % (EXEC_SCRIPT, flags)) + logger.debug("Executing command '%s'" % cmd) + result = ft_utils.execute_command(cmd, exit_on_error=False) if CLEAN_FLAG: cleanup() @@ -109,16 +122,17 @@ def run_test(test, tier_name): OVERALL_RESULT = -1 result_str = "FAIL" - if test.get_blocking(): - logger.info("This test case is blocking. Exiting...") + if test.is_blocking(): + if not args.test or args.test == "all": + logger.info("This test case is blocking. Aborting overall " + "execution.") + # if it is a single test we don't print the whole results table + update_test_info(test_name, result_str, duration_str) + generate_report.main(EXECUTED_TEST_CASES) + logger.info("Execution exit value: %s" % OVERALL_RESULT) sys.exit(OVERALL_RESULT) - for test in EXECUTED_TEST_CASES: - if test['test_name'] == test_name: - test.update({"result": result_str, - "duration": duration_str}) - - return result + update_test_info(test_name, result_str, duration_str) def run_tier(tier): @@ -134,11 +148,7 @@ def run_tier(tier): print_separator("#") logger.debug("\n%s" % tier) for test in tests: - res = run_test(test, tier_name) - if res != 0: - return res - - return 0 + run_test(test, tier_name) def run_all(tiers): @@ -163,12 +173,9 @@ def run_all(tiers): logger.info("Tests to be executed:%s" % summary) EXECUTED_TEST_CASES = generate_report.init(tiers_to_run) for tier in tiers_to_run: - res = run_tier(tier) - if res != 0: - return res - generate_report.main(EXECUTED_TEST_CASES) + run_tier(tier) - return 0 + generate_report.main(EXECUTED_TEST_CASES) def main(): @@ -178,7 +185,7 @@ def main(): CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE') CI_SCENARIO = os.getenv('DEPLOY_SCENARIO') - file = FUNCTEST_REPO + "/ci/testcases.yaml" + file = ft_utils.get_testcases_file() _tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, file) if args.noclean: @@ -207,6 +214,7 @@ def main(): else: run_all(_tiers) + logger.info("Execution exit value: %s" % OVERALL_RESULT) sys.exit(OVERALL_RESULT) if __name__ == '__main__':