X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Fposca%2Frun_posca.py;h=72a0d4c24be41f291c89f5513cd9ced4f177b98b;hb=be6453bb485c720278c5f6a45a5194391e454ce4;hp=e5e11e9ff520b3304b3c447f4df3a74f9c67f72d;hpb=b533d7bbf4e36e50c1280f14da4bda903633280c;p=bottlenecks.git diff --git a/testsuites/posca/run_posca.py b/testsuites/posca/run_posca.py index e5e11e9f..72a0d4c2 100755 --- a/testsuites/posca/run_posca.py +++ b/testsuites/posca/run_posca.py @@ -1,44 +1,56 @@ -#!/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 ==========") - print(arg) - if(arg == "posca_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[2] - 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 testcase in posca +# ------------------------------------------------------ + + +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: + LOG.info("Begin to run %s testcase in POSCA testsuite", testcase) + config[testcase]['out_file'] =\ + conf_parser.Parser.testcase_out_dir(testcase) + posca_testcase_run(testcase, config[testcase]) + LOG.info("End of %s testcase in POSCA testsuite", testcase) + + +def main(): + test_level = "testcase" + test_name = "posca_factor_system_bandwidth" + posca_run(test_level, test_name) + + +if __name__ == '__main__': + main()