diff options
Diffstat (limited to 'testsuites/posca/testcase_script')
7 files changed, 70 insertions, 74 deletions
diff --git a/testsuites/posca/testcase_script/common_script.py b/testsuites/posca/testcase_script/common_script.py index 2ca9f68b..a0114644 100644 --- a/testsuites/posca/testcase_script/common_script.py +++ b/testsuites/posca/testcase_script/common_script.py @@ -19,38 +19,38 @@ headers = {"Content-Type": "application/json"} def posca_tran_data(ES_ip, file_name): - p = sub.Popen(['curl', '-s', '-XPOST', "%s/_bulk" % ES_ip, - '--data-binary', "@" + file_name], stdout=sub.PIPE) - for line in iter(p.stdout.readline, b''): - ret_dict = json.loads(line) - if not ret_dict['errors']: - print("INFO: %6s lines no errors, total cost %d ms." - % (len(ret_dict['items']), ret_dict['took'])) - return len(ret_dict['items']) - else: - print("ERROR: %6s lines have errors, total cost %d ms." - % (len(ret_dict['items']), ret_dict['took'])) + p = sub.Popen(['curl', '-s', '-XPOST', "%s/_bulk" % ES_ip, + '--data-binary', "@" + file_name], stdout=sub.PIPE) + for line in iter(p.stdout.readline, b''): + ret_dict = json.loads(line) + if not ret_dict['errors']: + print("INFO: %6s lines no errors, total cost %d ms." + % (len(ret_dict['items']), ret_dict['took'])) + return len(ret_dict['items']) + else: + print("ERROR: %6s lines have errors, total cost %d ms." + % (len(ret_dict['items']), ret_dict['took'])) def posca_config_read(config_str, con_str, config): print("========== posca system bandwidth config read ===========") con_dic = {} - print("Configuration file is %s" %(config_str)) + print("Configuration file is %s" % (config_str)) idx = 0 with open(config_str, "rd") as cfgfile: config.readfp(cfgfile) while idx < len(con_str): con_dic[str(con_str[idx])] = \ - config.get("config", str(con_str[idx])) + config.get("config", str(con_str[idx])) idx += 1 with IPDB() as ip: GATEWAY_IP = ip.routes['default'].gateway if str(con_dic["test_ip"]) is "": - con_dic["test_ip"] = GATEWAY_IP+":8888" - print("test_ip is null get local ip is %s" %(con_dic["test_ip"])) + con_dic["test_ip"] = GATEWAY_IP + ":8888" + print("test_ip is null get local ip is %s" % (con_dic["test_ip"])) if con_dic["ES_ip"] is "": - con_dic["ES_ip"] = GATEWAY_IP+":9200" - print("ES_ip is null get local ip is %s" %(con_dic["ES_ip"])) + con_dic["ES_ip"] = GATEWAY_IP + ":9200" + print("ES_ip is null get local ip is %s" % (con_dic["ES_ip"])) return con_dic @@ -81,44 +81,46 @@ def posca_get_reply(con_dic, task_id, time_test=1): time.sleep(float(con_dic["test_time"])) reply_response = requests.get(reply_url) reply_data = json.loads(reply_response.text) - print("return data is %s" %(reply_data)) + print("return data is %s" % (reply_data)) if reply_data["status"] == 1: return(reply_data["result"][0]) if reply_data["status"] == 0: if time_test == 10: print("yardstick time out") sys.exit() - reply_result_data = posca_get_reply(con_dic, task_id, time_test=time_test+1) + reply_result_data = posca_get_reply( + con_dic, task_id, time_test=time_test + 1) return(reply_result_data) - posca_get_reply(con_dic, task_id, time_test=time_test+1) + posca_get_reply(con_dic, task_id, time_test=time_test + 1) if reply_data["status"] == 2: print("yardstick error exit") sys.exit() def posca_send_data(con_dic, test_config, file_config): - base_url = "http://%s/yardstick/testcases/samples/action" % (con_dic['test_ip']) - print("test ip addr is %s" %(base_url)) + base_url = "http://%s/yardstick/testcases/samples/action" % (con_dic[ + 'test_ip']) + print("test ip addr is %s" % (base_url)) test_dict = { - "action":"runTestCase", - "args":{ - "opts": { - "task-args": { - 'tx_msg_size': '%s' % str(test_config["tx_msg_size"]), - 'rx_msg_size': '%s' % str(test_config["rx_msg_size"]), - 'test_time': '%s' % str(int(con_dic["test_time"]) - 20), - 'host': 'node3.LF', - 'target': 'node4.LF' - } - }, - "testcase":"netperf_bottlenecks" - } + "action": "runTestCase", + "args": { + "opts": { + "task-args": { + 'tx_msg_size': '%s' % str(test_config["tx_msg_size"]), + 'rx_msg_size': '%s' % str(test_config["rx_msg_size"]), + 'test_time': '%s' % str(int(con_dic["test_time"]) - 20), + 'host': 'node3.LF', + 'target': 'node4.LF' + } + }, + "testcase": "netperf_bottlenecks" + } } reponse = requests.post( - base_url, data=json.dumps(test_dict), headers=headers) + base_url, data=json.dumps(test_dict), headers=headers) ask_data = json.loads(reponse.text) task_id = ask_data["result"] - print("yardstick task id is: %s" %(task_id)) + print("yardstick task id is: %s" % (task_id)) data_reply = posca_get_reply(con_dic, task_id) data_reply.update(test_config) posca_output_result(file_config, data_reply) @@ -128,11 +130,10 @@ def posca_send_data(con_dic, test_config, file_config): def posca_create_incluxdb(con_dic): base_url = "http://%s/yardstick/env/action" % (con_dic['test_ip']) test_dict = { - "action":"createInfluxDBContainer", + "action": "createInfluxDBContainer", } - reponse = requests.post( - base_url, data=json.dumps(test_dict), headers=headers) + requests.post( + base_url, data=json.dumps(test_dict), headers=headers) print("waiting for creating InfluxDB") time.sleep(30) print("Done, creating InflxDB Container") - diff --git a/testsuites/posca/testcase_script/posca_factor_cpu_burden.py b/testsuites/posca/testcase_script/posca_factor_cpu_burden.py index 273a24f9..58da8ca7 100644 --- a/testsuites/posca/testcase_script/posca_factor_cpu_burden.py +++ b/testsuites/posca/testcase_script/posca_factor_cpu_burden.py @@ -49,9 +49,6 @@ def posca_env_check(): def system_cpu_burden(test_id, data, file_config, con_dic): date_id = test_id print("test is is begin from %d" % test_id) - cur_role_result = 1 - pre_role_result = 1 - pre_reply = {} data_return = {} data_max = {} data_return["throughput"] = 1 @@ -59,14 +56,13 @@ def system_cpu_burden(test_id, data, file_config, con_dic): data_max["throughput"] = 1 for test_y in data["rx_pkt_sizes"]: test_config = { - "tx_msg_size": float(test_x), - "rx_msg_size": float(test_y), - } + "tx_msg_size": float(test_x), + "rx_msg_size": float(test_y), + } date_id = date_id + 1 file_config["test_id"] = date_id data_reply = common_script.posca_send_data( - con_dic, test_config, file_config) - bandwidth = data_reply["throughput"] + con_dic, test_config, file_config) if (data_max["remote_cpu_util"] > con_dic["cpu_load"]): return 1, data_reply if (data_max["local_cpu_util"] > con_dic["cpu_load"]): @@ -90,7 +86,7 @@ test_result/factor_system_system_bandwidth_%s.json" % (time_new) data["tx_pkt_sizes"] = tx_pkt_s_a print("######test package begin######") date_return, pkt_reply = system_cpu_burden( - test_con_id, data, file_config, con_dic) + test_con_id, data, file_config, con_dic) return True @@ -104,9 +100,9 @@ def main(): testcase_cfg = args.conf con_str = [ - 'test_ip', 'tool', 'test_time', 'protocol', - 'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load', - 'latency', 'ES_ip', 'dashboard' + 'test_ip', 'tool', 'test_time', 'protocol', + 'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load', + 'latency', 'ES_ip', 'dashboard' ] posca_env_check() starttime = datetime.datetime.now() @@ -122,8 +118,8 @@ system_bandwidth.py' print("\nBegin to establish dashboard.") sub_result = subprocess.Popen(pargs) sub_result.wait() - print("System Bandwidth testing time : %s" %(endtime - starttime)) + print("System Bandwidth testing time : %s" % (endtime - starttime)) time.sleep(5) if __name__ == '__main__': - main()
\ No newline at end of file + main() diff --git a/testsuites/posca/testcase_script/posca_factor_rx_cache_size.py b/testsuites/posca/testcase_script/posca_factor_rx_cache_size.py index cfbd278e..97045a1d 100644 --- a/testsuites/posca/testcase_script/posca_factor_rx_cache_size.py +++ b/testsuites/posca/testcase_script/posca_factor_rx_cache_size.py @@ -110,7 +110,7 @@ def posca_run(con_dic): bandwidth, latency, cpu_load) if (cpu_load < con_dic['test_cpu_load\ ']) and (latency < con_dic['test_latency']): - if (abs(bandwidth_tmp-bandwidth)/bandwidth < 0.05): + if (abs(bandwidth_tmp - bandwidth) / bandwidth < 0.05): return True else: print("%s,%s") % (bandwidth, test_tx_cache_s_e) diff --git a/testsuites/posca/testcase_script/posca_factor_rx_pkt_size.py b/testsuites/posca/testcase_script/posca_factor_rx_pkt_size.py index 5de25949..2a119413 100644 --- a/testsuites/posca/testcase_script/posca_factor_rx_pkt_size.py +++ b/testsuites/posca/testcase_script/posca_factor_rx_pkt_size.py @@ -115,7 +115,7 @@ def posca_run(con_dic): bandwidth, latency, cpu_load) if (cpu_load < con_dic['test_cpu_load\ ']) and (latency < con_dic['test_latency']): - if (abs(bandwidth_tmp-bandwidth)/bandwidth < 0.05): + if (abs(bandwidth_tmp - bandwidth) / bandwidth < 0.05): print("%s,%s,%s,%s,%s,%s") % (test_rx_pkt_s_e, test_rx_cache_s_e, test_tx_cache_s_e, diff --git a/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py b/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py index 0b77b6b6..7a0fd27b 100644 --- a/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py +++ b/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py @@ -60,24 +60,24 @@ def system_pkt_bandwidth(test_id, data, file_config, con_dic): bandwidth_tmp = 1 for test_y in data["rx_pkt_sizes"]: test_config = { - "tx_msg_size": float(test_x), - "rx_msg_size": float(test_y), - } + "tx_msg_size": float(test_x), + "rx_msg_size": float(test_y), + } date_id = date_id + 1 file_config["test_id"] = date_id data_reply = common_script.posca_send_data( - con_dic, test_config, file_config) + con_dic, test_config, file_config) bandwidth = data_reply["throughput"] if (data_max["throughput"] < bandwidth): data_max = data_reply - if (abs(bandwidth_tmp - bandwidth)/bandwidth_tmp < 0.025): + if (abs(bandwidth_tmp - bandwidth) / bandwidth_tmp < 0.025): print(pre_reply) break else: pre_reply = data_reply bandwidth_tmp = bandwidth cur_role_result = pre_reply["throughput"] - if (abs(pre_role_result - cur_role_result)/pre_role_result < 0.025): + if (abs(pre_role_result - cur_role_result) / pre_role_result < 0.025): print("date_id is %d,package return at line 111\n" % date_id) # return data_return if data_return["throughput"] < data_max["throughput"]: @@ -107,8 +107,8 @@ test_result/factor_system_system_bandwidth_%s.json" % (time_new) print("######find system bandwidth######") print("rx_msg_size:%d tx_msg_size:%d\n" % (pkt_reply["rx_msg_size"], pkt_reply["tx_msg_size"])) - date_tran = common_script.posca_tran_data( - con_dic['ES_ip'], file_config["file_path"]) + common_script.posca_tran_data( + con_dic['ES_ip'], file_config["file_path"]) return True @@ -121,9 +121,9 @@ def main(): testcase_cfg = args.conf con_str = [ - 'test_ip', 'tool', 'test_time', 'protocol', - 'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load', - 'latency', 'ES_ip', 'dashboard' + 'test_ip', 'tool', 'test_time', 'protocol', + 'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load', + 'latency', 'ES_ip', 'dashboard' ] posca_env_check() starttime = datetime.datetime.now() @@ -139,9 +139,8 @@ system_bandwidth.py' print("\nBegin to establish dashboard.") sub_result = subprocess.Popen(pargs) sub_result.wait() - print("System Bandwidth testing time : %s" %(endtime - starttime)) + print("System Bandwidth testing time : %s" % (endtime - starttime)) time.sleep(5) if __name__ == '__main__': main() - diff --git a/testsuites/posca/testcase_script/posca_factor_tx_cache_size.py b/testsuites/posca/testcase_script/posca_factor_tx_cache_size.py index a8d1a485..b7d45065 100644 --- a/testsuites/posca/testcase_script/posca_factor_tx_cache_size.py +++ b/testsuites/posca/testcase_script/posca_factor_tx_cache_size.py @@ -106,10 +106,10 @@ def posca_run(con_dic): latency = test_result.find("latency") posca_output_result(time_new, test_pkt_s_e, test_rx_cache_s_e, bandwidth, latency, cpu_load) - if (abs(bandwidth-con_dic['test_throughput'])/con_dic['test_\ + if (abs(bandwidth - con_dic['test_throughput']) / con_dic['test_\ throughput'] > 0.05) and (latency < con_dic['test_\ latency']) and (cpu_load < con_dic['test_cpu_load']): - if (abs(bandwidth_tmp-bandwidth)/bandwidth < 0.05): + if (abs(bandwidth_tmp - bandwidth) / bandwidth < 0.05): return True else: print("%s,%s") % (bandwidth, test_rx_cache_s_e) diff --git a/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py b/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py index 47cc5e75..39dba135 100644 --- a/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py +++ b/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py @@ -112,10 +112,10 @@ def posca_run(con_dic): posca_output_result(time_new, test_rx_pkt_s_e, test_rx_cache_s_e, test_tx_cache_s_e, bandwidth, latency, cpu_load) - if (abs(bandwidth-con_dic['test_throughput'])/con_dic['test_\ + if (abs(bandwidth - con_dic['test_throughput']) / con_dic['test_\ throughput'] > 0.05) and (latency < con_dic['test_\ latency']) and (cpu_load < con_dic['test_cpu_load']): - if (abs(bandwidth_tmp-bandwidth)/bandwidth < 0.05): + if (abs(bandwidth_tmp - bandwidth) / bandwidth < 0.05): print("%s,%s,%s,%s,%s,%s") % (test_rx_pkt_s_e, test_rx_cache_s_e, test_tx_cache_s_e, |