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 ##############################################################################
20 # ------------------------------------------------------
21 # parser for configuration files in each test case
22 # ------------------------------------------------------
23 parser = argparse.ArgumentParser()
24 parser.add_argument("-c", "--conf",
25 help="configuration files for the testcase,\
27 default="/home/opnfv/bottlenecks/testsuites/posca\
28 /testcase_cfg/posca_factor_system_bandwidth.yaml")
29 args = parser.parse_args()
30 headers = {"Content-Type": "application/json"}
31 INTERPRETER = "/usr/bin/python"
34 # --------------------------------------------------
35 # logging configuration
36 # --------------------------------------------------
37 logger = logging.getLogger(__name__)
40 def posca_env_check():
41 print("========== posca system bandwidth env check ===========")
42 filepath = r"/home/opnfv/bottlenecks/testsuites/posca/test_result/"
43 if os.path.exists(filepath):
46 os.mkdir(r'/home/opnfv/bottlenecks/testsuites/posca/test_result/')
49 def system_cpu_burden(test_id, data, file_config, con_dic):
51 print("test is is begin from %d" % test_id)
54 data_return["throughput"] = 1
55 for test_x in data["tx_pkt_sizes"]:
56 data_max["throughput"] = 1
57 for test_y in data["rx_pkt_sizes"]:
59 "tx_msg_size": float(test_x),
60 "rx_msg_size": float(test_y),
63 file_config["test_id"] = date_id
64 data_reply = common_script.posca_send_data(
65 con_dic, test_config, file_config)
66 if (data_max["remote_cpu_util"] > con_dic["cpu_load"]):
68 if (data_max["local_cpu_util"] > con_dic["cpu_load"]):
70 print("cpu_burden don't find\n")
74 def posca_run(con_dic):
75 print("========== run posca system bandwidth ===========")
79 rx_pkt_s_a = con_dic['rx_pkt_sizes'].split(',')
80 tx_pkt_s_a = con_dic['tx_pkt_sizes'].split(',')
81 time_new = time.strftime('%H_%M', time.localtime(time.time()))
82 file_config["file_path"] = "/home/opnfv/bottlenecks/testsuites/posca/\
83 test_result/factor_system_system_bandwidth_%s.json" % (time_new)
84 file_config["test_type"] = "system_bandwidth_biggest"
85 data["rx_pkt_sizes"] = rx_pkt_s_a
86 data["tx_pkt_sizes"] = tx_pkt_s_a
87 print("######test package begin######")
88 date_return, pkt_reply = system_cpu_burden(
89 test_con_id, data, file_config, con_dic)
96 logger.error("Configuration files do not exist for \
97 the specified testcases")
100 testcase_cfg = args.conf
103 'test_ip', 'tool', 'test_time', 'protocol',
104 'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load',
105 'latency', 'ES_ip', 'dashboard'
108 starttime = datetime.datetime.now()
109 config = ConfigParser.ConfigParser()
110 con_dic = common_script.posca_config_read(testcase_cfg, con_str, config)
111 common_script.posca_create_incluxdb(con_dic)
113 endtime = datetime.datetime.now()
114 if con_dic["dashboard"] == "y":
115 cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_dashboard/\
117 pargs = [INTERPRETER, cmd]
118 print("\nBegin to establish dashboard.")
119 sub_result = subprocess.Popen(pargs)
121 print("System Bandwidth testing time : %s" % (endtime - starttime))
124 if __name__ == '__main__':