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 realize the function of run systembandwidth script.
11 for example this contain two part first run_script,
12 second is algorithm, this part is about how to judge the bottlenecks.
13 This test is using yardstick as a tool to begin test.'''
17 import utils.logger as log
18 import utils.infra_setup.runner.yardstick as Runner
19 from utils.parser import Parser as conf_parser
20 # --------------------------------------------------
21 # logging configuration
22 # --------------------------------------------------
23 LOG = log.Logger(__name__).getLogger()
26 "action": "runTestCase",
31 "testcase": "netperf_bottlenecks"
37 Runner.Create_Incluxdb(con_dic['runner_config'])
40 def do_test(test_config, con_dic):
41 test_dict['args']['opts']['task-args'] = test_config
42 Task_id = Runner.Send_Data(test_dict, con_dic['runner_config'])
43 time.sleep(con_dic['test_config']['test_time'])
44 Data_Reply = Runner.Get_Reply(con_dic['runner_config'], Task_id)
45 test_date = Data_Reply[con_dic['runner_config']['yardstick_testcase']][0]
51 rx_pkt_a = con_dic['test_config']['rx_pkt_sizes'].split(',')
52 tx_pkt_a = con_dic['test_config']['tx_pkt_sizes'].split(',')
53 data["rx_pkt_sizes"] = rx_pkt_a
54 data["tx_pkt_sizes"] = tx_pkt_a
55 con_dic["result_file"] = os.path.dirname(
56 os.path.abspath(__file__)) + "/test_case/result"
63 data_return["throughput"] = 1
64 if con_dic["runner_config"]["yardstick_test_ip"] is None:
65 con_dic["runner_config"]["yardstick_test_ip"] =\
66 conf_parser.ip_parser("yardstick_test_ip")
68 for test_x in data["tx_pkt_sizes"]:
69 data_max["throughput"] = 1
71 for test_y in data["rx_pkt_sizes"]:
73 "tx_msg_size": float(test_x),
74 "rx_msg_size": float(test_y),
75 "test_time": con_dic['test_config']['test_time']
78 data_reply = do_test(test_config, con_dic)
79 bandwidth = float(data_reply["throughput"])
80 if (data_max["throughput"] < bandwidth):
82 if (abs(bandwidth_tmp - bandwidth) / bandwidth_tmp < 0.025):
86 pre_reply = data_reply
87 bandwidth_tmp = bandwidth
88 cur_role_result = float(pre_reply["throughput"])
89 if (abs(pre_role_result - cur_role_result) / pre_role_result < 0.025):
90 print("date_id is %d,package return at line 111\n" % date_id)
91 if data_return["throughput"] < data_max["throughput"]:
92 data_return = data_max
93 pre_role_result = cur_role_result
94 print("date_id is %d,id return success\n" % date_id)