diff options
author | liyin <liyin11@huawei.com> | 2017-01-24 17:26:21 +0800 |
---|---|---|
committer | Ace Lee <liyin11@huawei.com> | 2017-02-07 02:00:00 +0000 |
commit | c6755e612b322facefc4edc32e948ab2b00bb3b0 (patch) | |
tree | f3796ea159c10c9e9690c8b9072f37ebc0ea1f9c /testsuites/posca/run_posca.py | |
parent | ca641fcdaa919afb072a9625eb9ba3848b9e3805 (diff) |
Bottlenecks POSCA testing code reconstruction
JIRA:BOTTLENECK-103
This is the foundation of adding stack samples.
This code change a lot code.
but it's a basic.
Those code will be changed in the furture.
Change-Id: I8d5bbb9cc401b1aaac54ec4dffc4c005a42d17ac
Signed-off-by: liyin <liyin11@huawei.com>
Diffstat (limited to 'testsuites/posca/run_posca.py')
-rwxr-xr-x | testsuites/posca/run_posca.py | 105 |
1 files changed, 61 insertions, 44 deletions
diff --git a/testsuites/posca/run_posca.py b/testsuites/posca/run_posca.py index e5e11e9f..fcf35d5b 100755 --- a/testsuites/posca/run_posca.py +++ b/testsuites/posca/run_posca.py @@ -1,44 +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 ==========")
- 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 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() + |