X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Fposca%2Frun_posca.py;h=fcf35d5b3cc3e1a6a3d5ccde5ea854f38ae3f203;hb=c6755e612b322facefc4edc32e948ab2b00bb3b0;hp=48376b540f2604cf4d8e6d8adbd2b399f47d5119;hpb=b60b5daa668899d528c70c1d4858421eb71e73a6;p=bottlenecks.git diff --git a/testsuites/posca/run_posca.py b/testsuites/posca/run_posca.py index 48376b54..fcf35d5b 100755 --- a/testsuites/posca/run_posca.py +++ b/testsuites/posca/run_posca.py @@ -1,43 +1,61 @@ -#!/usr/bin/env python -############################################################################## -# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import sys -import subprocess - -INTERPRETER = "/usr/bin/python" -# ------------------------------------------------------ -# run posca testcase -# ------------------------------------------------------ - - -def posca_run(arg): - print("========== run posca ==========") - if(arg == "factor_system_bandwidth"): - print("========== run posca_system_bandwidth ===========") - cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_script/\ - posca_factor_system_bandwidth.py' - pargs = [INTERPRETER, cmd] - sub_result = subprocess.Popen(pargs) - sub_result.wait() - - -def posca_env_check(): - print("========== posca env check ===========") - - -def main(): - # para_testname = sys.argv[0] - para_test_arg = sys.argv[1] - posca_env_check() - posca_run(para_test_arg) - sys.exit(0) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# 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. +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") +posca_run('teststory', "Which story you will run") +and if you run "python run_posca", this will run testcase, +posca_factor_system_bandwidth by default.''' + +import importlib +import utils.parser as conf_parser +import utils.logger as log +INTERPRETER = "/usr/bin/python" + +LOG = log.Logger(__name__).getLogger() +# ------------------------------------------------------ +# run posca testcase +# ------------------------------------------------------ + + +def posca_testcase_run(testcase_script, test_config): + + module_string = "testsuites.posca.testcase_script.%s" % (testcase_script) + module = importlib.import_module(module_string) + module.run(test_config) + + +def posca_run(test_level, test_name): + if test_level == "testcase": + config = conf_parser.Parser.testcase_read("posca", test_name) + elif test_level == "teststory": + config = conf_parser.Parser.story_read("posca", test_name) + for testcase in config: + print(config[testcase]) + posca_testcase_run(testcase, config[testcase]) + if con_dic["dashboard"] == "y": + cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_dashboard/\ +system_bandwidth.py' + pargs = [INTERPRETER, cmd] + LOG.info("\nBegin to establish dashboard.") + sub_result = subprocess.Popen(pargs) + sub_result.wait() + + +def main(): + test_level = "testcase" + test_name = "posca_factor_system_bandwidth" + posca_run(test_level, test_name) + + +if __name__ == '__main__': + main() +