1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
##############################################################################
'''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()
|