X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Frun_testsuite.py;fp=testsuites%2Fposca%2Frun_posca.py;h=7ec67effedeebc2615220b2bcda033ee061ad944;hb=bde702f95563cf953c32f9bfd0587083a3fea26d;hp=b1dba1403d880a736e9b5813d7452a3aa32cdc43;hpb=c821b792db011dbbe1c70d256fadbe9c745570ff;p=bottlenecks.git diff --git a/testsuites/posca/run_posca.py b/testsuites/run_testsuite.py old mode 100755 new mode 100644 similarity index 71% rename from testsuites/posca/run_posca.py rename to testsuites/run_testsuite.py index b1dba140..7ec67eff --- a/testsuites/posca/run_posca.py +++ b/testsuites/run_testsuite.py @@ -7,7 +7,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -'''This file realize the function of how to run posca. +'''This file realize the function of how to run testsuite. In this file, The first thing is to read testcase config for example: you could run this by use posca_run('testcase', "Which testcase you will run") @@ -21,11 +21,13 @@ import os from oslo_serialization import jsonutils import json +import time import requests import datetime import utils.parser as conf_parser import utils.logger as log +import utils.infra_setup.runner.docker_env as docker_env INTERPRETER = "/usr/bin/python" LOG = log.Logger(__name__).getLogger() @@ -34,9 +36,10 @@ LOG = log.Logger(__name__).getLogger() # ------------------------------------------------------ -def posca_testcase_run(testcase_script, test_config): +def posca_testcase_run(testsuite, testcase_script, test_config): - module_string = "testsuites.posca.testcase_script.%s" % (testcase_script) + module_string = "testsuites.%s.testcase_script.%s" % (testsuite, + testcase_script) module = importlib.import_module(module_string) module.run(test_config) @@ -73,20 +76,37 @@ def report(testcase, start_date, stop_date, criteria, details_doc): LOG.exception('Failed to record result data: %s', err) -def posca_run(test_level, test_name, REPORT="False"): +def docker_env_prepare(config): + if 'contexts' in config.keys() and config["contexts"] is not None: + context_config = config["contexts"] + if 'yardstick' in context_config.keys() and \ + context_config["yardstick"] is not None: + docker_env.env_yardstick(context_config['yardstick']) + conf_parser.Parser.convert_docker_env(config, "yardstick") + if 'dashboard' in context_config.keys() and \ + context_config["dashboard"] is not None: + docker_env.env_elk(context_config['dashboard']) + conf_parser.Parser.convert_docker_env(config, "dashboard") + LOG.debug('Waiting for ELK init') + time.sleep(15) + return + + +def testsuite_run(test_level, test_name, REPORT="False"): + tester_parser = test_name.split("_") if test_level == "testcase": - config = conf_parser.Parser.testcase_read("posca", test_name) + config = conf_parser.Parser.testcase_read(tester_parser[0], test_name) elif test_level == "teststory": - config = conf_parser.Parser.story_read("posca", test_name) + config = conf_parser.Parser.story_read(tester_parser[0], test_name) for testcase in config: LOG.info("Begin to run %s testcase in POSCA testsuite", testcase) config[testcase]['out_file'] =\ conf_parser.Parser.testcase_out_dir(testcase) start_date = datetime.datetime.now() - posca_testcase_run(testcase, config[testcase]) + docker_env_prepare(config[testcase]) + posca_testcase_run(tester_parser[0], testcase, config[testcase]) stop_date = datetime.datetime.now() LOG.info("End of %s testcase in POSCA testsuite", testcase) - criteria = "FAIL" if REPORT == "True": details_doc = [] @@ -102,7 +122,7 @@ def main(): test_level = sys.argv[1] test_name = sys.argv[2] REPORT = sys.argv[3] - posca_run(test_level, test_name, REPORT) + testsuite_run(test_level, test_name, REPORT) if __name__ == '__main__':