From 069e3467772fa074a87d144a3a2fd9cc461175fb Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 4 Feb 2021 07:58:12 -0800 Subject: [PATCH] fix regression test errors --- py-json/realm.py | 23 +++++------------------ py-scripts/regression_test.sh | 15 ++++++--------- py-scripts/test_ipv4_variable_time.py | 22 ++++++++++------------ 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 974241fa..d6ff9f4b 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1191,12 +1191,8 @@ class L3CXProfile(LFCliBase): pass #Step 1, column names - fields=None - if col_names is not None and len(col_names) > 0: - fields = ",".join(col_names) - header_row=col_names - else: - header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) + fields = ",".join(col_names) + header_row=col_names # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) @@ -1208,10 +1204,7 @@ class L3CXProfile(LFCliBase): timestamps = [] # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: - if fields is None: - response = self.json_get("/endp/all") - else: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1263,10 +1256,7 @@ class L3CXProfile(LFCliBase): df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] #compare previous data to current data - try: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - except: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name @@ -1789,10 +1779,7 @@ class L4CXProfile(LFCliBase): df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] #compare previous data to current data - try: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - except: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 72411432..ed32fc61 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -8,6 +8,7 @@ SSID_USED="jedway-wpa2-x2048-5-3" PASSWD_USED="jedway-wpa2-x2048-5-3" RADIO_USED="wiphy1" SECURITY="wpa2" +COL_NAMES="'"'name'"','"'tx bytes'"','"'rx bytes'"','"'dropped'"'" START_NUM=0 CURR_TEST_NUM=0 @@ -29,10 +30,10 @@ testCommands=( "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" - "./test_ipv4_l4_wifi.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" - "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" - "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" - "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" + "./test_ipv4_l4_wifi.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s" + "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s" + "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format excel --col_names $COL_NAMES" + "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format csv --col_names $COL_NAMES" #"./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000"NAME #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" @@ -73,11 +74,7 @@ TEST_DIR="/home/lanforge/report-data/${NOW}" mkdir "$TEST_DIR" function run_test() { for i in "${testCommands[@]}"; do - chars=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - for i in {1..10} ; do - NAME+= - done - NAME=$(python3 -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))") + NAME=cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 CURR_TEST_NAME=${i%%.py*} CURR_TEST_NAME=${CURR_TEST_NAME#./*} CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 20e0bffd..2545d2b2 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -145,7 +145,7 @@ python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 --num_stations 32 - --security {open|wep|wpa|wpa2|wpa3} + --security {open|wep|wpa|wpa2|wpa3} --mode 1 {"auto" : "0", "a" : "1", @@ -177,12 +177,12 @@ python3 ./test_ipv4_variable_time.py Using the col_names flag: Currently the output function does not support inputting the columns in col_names the way they are displayed in the GUI. This quirk is under construction. To output - certain columns in the GUI in your final report, please match the according GUI column display to it's counterpart to have the columns correctly displayed in + certain columns in the GUI in your final report, please match the according GUI column display to it's counterpart to have the columns correctly displayed in your report. GUI Column Display Col_names argument to type in (to print in report) - Name | + Name | EID | 'eid' Run | 'run' Mng | 'mng' @@ -335,19 +335,17 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - if args.col_names is not None: - print(args.col_names) - if type(args.col_names) is not list: - col_names=list(args.col_names.split(",")) - #send col names here to file to reformat - else: - col_names = args.col_names - #send col names here to file to reformat + + if type(args.col_names) is not list: + col_names=list(args.col_names.split(",")) + #send col names here to file to reformat else: - col_names=None + col_names = args.col_names + #send col names here to file to reformat if args.debug: print("Column names are...") print(col_names) + ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, duration_sec=ip_var_test.parse_time(args.test_duration).total_seconds(),