diff options
Diffstat (limited to 'functest/ci')
-rwxr-xr-x | functest/ci/check_os.sh | 2 | ||||
-rwxr-xr-x | functest/ci/config_functest.yaml | 1 | ||||
-rwxr-xr-x | functest/ci/prepare_env.py | 66 | ||||
-rwxr-xr-x | functest/ci/run_tests.py | 68 | ||||
-rwxr-xr-x | functest/ci/testcases.yaml | 14 |
5 files changed, 90 insertions, 61 deletions
diff --git a/functest/ci/check_os.sh b/functest/ci/check_os.sh index 053796d9..e2471026 100755 --- a/functest/ci/check_os.sh +++ b/functest/ci/check_os.sh @@ -24,7 +24,7 @@ fi echo "Checking OpenStack endpoints:" -publicURL=$OS_AUTH_URL +publicURL=$(openstack catalog show identity |awk '/public/ {print $4}') publicIP=$(echo $publicURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//') publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/\/.*$//') echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..." diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index aa66b0dd..25be1724 100755 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -88,6 +88,7 @@ onos_sfc: image_file_name: firewall_block_image.img tempest: + deployment_name: opnfv-tempest identity: tenant_name: tempest tenant_description: Tenant for Tempest test suite diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 3df3a0e0..74c751af 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -29,12 +29,6 @@ import functest.utils.openstack_utils as os_utils from functest.utils.constants import CONST actions = ['start', 'check'] -parser = argparse.ArgumentParser() -parser.add_argument("action", help="Possible actions are: " - "'{d[0]}|{d[1]}' ".format(d=actions)) -parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") -args = parser.parse_args() - """ logging configuration """ logger = ft_logger.Logger("prepare_env").getLogger() @@ -48,6 +42,19 @@ with open(CONFIG_PATCH_PATH) as f: functest_patch_yaml = yaml.safe_load(f) +class PrepareEnvParser(): + + def __init__(self): + self.parser = argparse.ArgumentParser() + self.parser.add_argument("action", help="Possible actions are: " + "'{d[0]}|{d[1]}' ".format(d=actions)) + self.parser.add_argument("-d", "--debug", help="Debug mode", + action="store_true") + + def parse_args(self, argv=[]): + return vars(self.parser.parse_args(argv)) + + def print_separator(): logger.info("==============================================") @@ -227,32 +234,36 @@ def install_rally(): rally_conf = os_utils.get_credentials_for_rally() with open('rally_conf.json', 'w') as fp: json.dump(rally_conf, fp) - cmd = "rally deployment create --file=rally_conf.json --name=" - cmd += CONST.rally_deployment_name - ft_utils.execute_command(cmd, - error_msg="Problem creating Rally deployment") - - logger.info("Installing tempest from existing repo...") - cmd = ("rally verify install --source " + - CONST.dir_repo_tempest + - " --system-wide") + cmd = ("rally deployment create " + "--file=rally_conf.json --name={}" + .format(CONST.rally_deployment_name)) ft_utils.execute_command(cmd, - error_msg="Problem installing Tempest.") + error_msg=("Problem while creating " + "Rally deployment")) cmd = "rally deployment check" ft_utils.execute_command(cmd, error_msg=("OpenStack not responding or " "faulty Rally deployment.")) - cmd = "rally show images" + cmd = "rally deployment list" ft_utils.execute_command(cmd, error_msg=("Problem while listing " - "OpenStack images.")) + "Rally deployment.")) - cmd = "rally show flavors" + cmd = "rally plugin list | head -5" ft_utils.execute_command(cmd, error_msg=("Problem while showing " - "OpenStack flavors.")) + "Rally plugins.")) + + +def install_tempest(): + logger.info("Installing tempest from existing repo...") + cmd = ("rally verify create-verifier --source {0} " + "--name {1} --type tempest" + .format(CONST.dir_repo_tempest, CONST.tempest_deployment_name)) + ft_utils.execute_command(cmd, + error_msg="Problem while installing Tempest.") def check_environment(): @@ -267,15 +278,15 @@ def check_environment(): logger.error(msg_not_active) sys.exit(1) - logger.info("Functest environment installed.") + logger.info("Functest environment is installed.") -def main(): - if not (args.action in actions): +def main(**kwargs): + if not (kwargs['action'] in actions): logger.error('Argument not valid.') sys.exit() - if args.action == "start": + if kwargs['action'] == "start": logger.info("######### Preparing Functest environment #########\n") check_env_variables() create_directories() @@ -283,17 +294,20 @@ def main(): patch_config_file() verify_deployment() install_rally() + install_tempest() with open(CONST.env_active, "w") as env_file: env_file.write("1") check_environment() - if args.action == "check": + if kwargs['action'] == "check": check_environment() exit(0) if __name__ == '__main__': - main() + parser = PrepareEnvParser() + args = parser.parse_args(sys.argv[1:]) + main(**args) diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index 7aac9d2c..10f1ac9a 100755 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -26,17 +26,6 @@ import functest.utils.openstack_snapshot as os_snapshot import functest.utils.openstack_utils as os_utils from functest.utils.constants import CONST -parser = argparse.ArgumentParser() -parser.add_argument("-t", "--test", dest="test", action='store', - help="Test case or tier (group of tests) to be executed. " - "It will run all the test if not specified.") -parser.add_argument("-n", "--noclean", help="Do not clean OpenStack resources" - " after running each test (default=false).", - action="store_true") -parser.add_argument("-r", "--report", help="Push results to database " - "(default=false).", action="store_true") -args = parser.parse_args() - """ logging configuration """ logger = ft_logger.Logger("run_tests").getLogger() @@ -49,6 +38,26 @@ EXEC_SCRIPT = ("%s/functest/ci/exec_test.sh" % CONST.dir_repo_functest) # this variable will change to -1 +class RunTestsParser(): + + def __init__(self): + self.parser = argparse.ArgumentParser() + self.parser.add_argument("-t", "--test", dest="test", action='store', + help="Test case or tier (group of tests) " + "to be executed. It will run all the test " + "if not specified.") + self.parser.add_argument("-n", "--noclean", help="Do not clean " + "OpenStack resources after running each " + "test (default=false).", + action="store_true") + self.parser.add_argument("-r", "--report", help="Push results to " + "database (default=false).", + action="store_true") + + def parse_args(self, argv=[]): + return vars(self.parser.parse_args(argv)) + + class GlobalVariables: EXECUTED_TEST_CASES = [] OVERALL_RESULT = 0 @@ -118,7 +127,7 @@ def get_run_dict_if_defined(testname): return None -def run_test(test, tier_name): +def run_test(test, tier_name, testcases=None): result_str = "PASS" start = datetime.datetime.now() test_name = test.get_name() @@ -170,18 +179,19 @@ def run_test(test, tier_name): if result != 0: logger.error("The test case '%s' failed. " % test_name) - OVERALL_RESULT = -1 + GlobalVariables.OVERALL_RESULT = -1 result_str = "FAIL" if test.is_blocking(): - if not args.test or args.test == "all": + if not testcases or testcases == "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(GlobalVariables.EXECUTED_TEST_CASES) - logger.info("Execution exit value: %s" % OVERALL_RESULT) - sys.exit(OVERALL_RESULT) + logger.info("Execution exit value: %s" % + GlobalVariables.OVERALL_RESULT) + sys.exit(GlobalVariables.OVERALL_RESULT) update_test_info(test_name, result_str, duration_str) @@ -222,7 +232,7 @@ def run_all(tiers): generate_report.main(GlobalVariables.EXECUTED_TEST_CASES) -def main(): +def main(**kwargs): CI_INSTALLER_TYPE = CONST.INSTALLER_TYPE CI_SCENARIO = CONST.DEPLOY_SCENARIO @@ -230,27 +240,29 @@ def main(): file = CONST.functest_testcases_yaml _tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, file) - if args.noclean: + if kwargs['noclean']: GlobalVariables.CLEAN_FLAG = False - if args.report: + if kwargs['report']: GlobalVariables.REPORT_FLAG = True - if args.test: + if kwargs['test']: source_rc_file() - if _tiers.get_tier(args.test): - run_tier(_tiers.get_tier(args.test)) + if _tiers.get_tier(kwargs['test']): + run_tier(_tiers.get_tier(kwargs['test'])) - elif _tiers.get_test(args.test): - run_test(_tiers.get_test(args.test), _tiers.get_tier(args.test)) + elif _tiers.get_test(kwargs['test']): + run_test(_tiers.get_test(kwargs['test']), + _tiers.get_tier(kwargs['test']), + kwargs['test']) - elif args.test == "all": + elif kwargs['test'] == "all": run_all(_tiers) else: logger.error("Unknown test case or tier '%s', or not supported by " "the given scenario '%s'." - % (args.test, CI_SCENARIO)) + % (kwargs['test'], CI_SCENARIO)) logger.debug("Available tiers are:\n\n%s" % _tiers) else: @@ -261,4 +273,6 @@ def main(): if __name__ == '__main__': - main() + parser = RunTestsParser() + args = parser.parse_args(sys.argv[1:]) + main(**args) diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index 4096bb79..ede08285 100755 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -65,7 +65,7 @@ tiers: Tempest automatically and depends on the parameters of the OpenStack deplopyment. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' run: module: 'functest.opnfv_tests.openstack.tempest.tempest' @@ -121,7 +121,7 @@ tiers: the cloud's private network. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' run: module: 'functest.opnfv_tests.openstack.snaps.connection_check' @@ -139,7 +139,7 @@ tiers: the cloud's private network. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' run: module: 'functest.opnfv_tests.openstack.snaps.api_check' @@ -159,7 +159,7 @@ tiers: the cloud's private network. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' run: module: 'functest.opnfv_tests.openstack.snaps.smoke' @@ -200,7 +200,7 @@ tiers: description: >- Test suite from SDNVPN project. dependencies: - installer: '(fuel)|(apex)' + installer: '(fuel)|(apex)|(netvirt)' scenario: 'bgpvpn' run: module: 'functest.opnfv_tests.features.sdnvpn' @@ -309,7 +309,7 @@ tiers: Tempest automatically and depends on the parameters of the OpenStack deplopyment. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' run: module: 'functest.opnfv_tests.openstack.tempest.tempest' @@ -323,7 +323,7 @@ tiers: This test case runs the full suite of scenarios of the OpenStack Rally suite using several threads and iterations. dependencies: - installer: '' + installer: '^((?!netvirt).)*$' scenario: '' - |