# 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")
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()
# ------------------------------------------------------
-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)
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 = []
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__':