Dashboard and output file code reconstruction
[bottlenecks.git] / testsuites / posca / run_posca.py
1 #!/usr/bin/env python
2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 '''This file realize the function of how to run posca.
11 In this file, The first thing is to read testcase config
12 for example: you could run this by use
13 posca_run('testcase', "Which testcase you will run")
14 posca_run('teststory', "Which story you will run")
15 and if you run "python run_posca", this will run testcase,
16 posca_factor_system_bandwidth by default.'''
17
18 import importlib
19 import utils.parser as conf_parser
20 import utils.logger as log
21 INTERPRETER = "/usr/bin/python"
22
23 LOG = log.Logger(__name__).getLogger()
24 # ------------------------------------------------------
25 # run testcase in posca
26 # ------------------------------------------------------
27
28
29 def posca_testcase_run(testcase_script, test_config):
30
31     module_string = "testsuites.posca.testcase_script.%s" % (testcase_script)
32     module = importlib.import_module(module_string)
33     module.run(test_config)
34
35
36 def posca_run(test_level, test_name):
37     if test_level == "testcase":
38         config = conf_parser.Parser.testcase_read("posca", test_name)
39     elif test_level == "teststory":
40         config = conf_parser.Parser.story_read("posca", test_name)
41     for testcase in config:
42         LOG.info("Begin to run %s testcase in POSCA testsuite", testcase)
43         config[testcase]['out_file'] =\
44             conf_parser.Parser.testcase_out_dir(testcase)
45         posca_testcase_run(testcase, config[testcase])
46         LOG.info("End of %s testcase in POSCA testsuite", testcase)
47
48
49 def main():
50     test_level = "testcase"
51     test_name = "posca_factor_system_bandwidth"
52     posca_run(test_level, test_name)
53
54
55 if __name__ == '__main__':
56     main()