2 ##############################################################################
3 # Copyright (c) 2017 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 is to do data-plane baseline test for
11 VM pair life-cycle events using netperf.
12 Testing steps are summarized below:
13 1. run_test load testcase configuration
14 2. Bottlenecks eliminates the environments limits/constraints
15 3. Bottlenecks tells Yardstick to prepare environment
16 4. Bottlenecks tells Yardstick to run test
18 3.2 to install netperf
19 3.3 to send/forward packets for t2 seconds
20 3.4 record results and detroy stack
21 3.4 after every t1 seconds goto 3.1 and repeat the workflow
22 5. Bottlenecks collects testing results from Yardstick
23 6. Bottlenecks tells Yardstick to stop when time ends
24 or system fails the test
25 7. Bottlenecks sends testing data to bottlenecks-elk'''
27 import utils.logger as log
36 # from utils.parser import Parser as conf_parser
37 import utils.env_prepare.quota_prepare as quota_prepare
38 import utils.env_prepare.stack_prepare as stack_prepare
39 import utils.infra_setup.runner.yardstick as runner_yardstick
41 # import testsuites.posca.testcase_dashboard.posca_factor_throughputs as DashBoard # noqa
42 import utils.infra_setup.runner.docker_env as docker_env
44 # --------------------------------------------------
45 # logging configuration
46 # --------------------------------------------------
47 LOG = log.Logger(__name__).getLogger()
50 "action": "runTestCase",
55 "testcase": "netperf_bottlenecks"
58 testfile = os.path.basename(__file__)
59 testcase, file_format = os.path.splitext(testfile)
60 cidr = "/home/opnfv/repos/yardstick/samples/netperf_soak.yaml"
66 def env_pre(test_config):
67 test_yardstick = False
68 if "yardstick" in test_config["contexts"].keys():
70 stack_prepare._prepare_env_daemon(test_yardstick)
71 quota_prepare.quota_env_prepare()
72 LOG.info("yardstick environment prepare!")
73 if(test_config["contexts"]['yardstick_envpre']):
74 stdout = runner_yardstick.yardstick_image_prepare()
79 func_name = sys._getframe().f_code.co_name
80 out_file = ("/tmp/yardstick_" + str(uuid.uuid4()) + ".out")
81 parameter_info = dict(test_time=con_dic["scenarios"]["vim_pair_ttl"])
82 yardstick_container = docker_env.yardstick_info['container']
83 cmd = runner_yardstick.yardstick_command_parser(debug=runner_DEBUG,
86 parameter=parameter_info)
87 stdout = docker_env.docker_exec_cmd(yardstick_container, cmd)
91 while loop_value < 60:
93 loop_value = loop_value + 1
94 with open(out_file) as f:
96 if data["status"] == 1:
97 LOG.info("Success run yardstick netperf_soak test!")
100 elif data["status"] == 2:
101 LOG.error("Failed run yardstick netperf_soak test!")
104 q.put((out_value, func_name))
108 def config_to_result(num, out_num, during_date, result):
111 test_result["number_of_stacks"] = float(num)
112 test_result["success_times"] = out_num
113 test_result["success_rate"] = out_num / num
114 test_result["duration_time"] = during_date
115 test_result["result"] = result
116 testdata["data_body"] = test_result
117 testdata["testcase"] = testcase
121 def func_run(con_dic):
122 test_date = do_test(con_dic)
126 def run(test_config):
127 con_dic = test_config["load_manager"]
130 LOG.info("yardstick environment prepare done!")
132 return func_run(con_dic)