2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
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.'''
19 import utils.parser as conf_parser
20 import utils.logger as log
21 INTERPRETER = "/usr/bin/python"
23 LOG = log.Logger(__name__).getLogger()
24 # ------------------------------------------------------
26 # ------------------------------------------------------
29 def posca_testcase_run(testcase_script, test_config):
31 module_string = "testsuites.posca.testcase_script.%s" % (testcase_script)
32 module = importlib.import_module(module_string)
33 module.run(test_config)
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 print(config[testcase])
43 posca_testcase_run(testcase, config[testcase])
44 if con_dic["dashboard"] == "y":
45 cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_dashboard/\
47 pargs = [INTERPRETER, cmd]
48 LOG.info("\nBegin to establish dashboard.")
49 sub_result = subprocess.Popen(pargs)
54 test_level = "testcase"
55 test_name = "posca_factor_system_bandwidth"
56 posca_run(test_level, test_name)
59 if __name__ == '__main__':