From ca83116a9e1ed3dc056fe9ec9569b6de7aa7c327 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 24 Jul 2020 15:17:24 -0700 Subject: [PATCH 001/134] Changed debug variable usage --- py-scripts/test_ipv4_variable_time.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index ce45bbed..d07a0ace 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -34,6 +34,7 @@ class IPV4VariableTime(LFCliBase): self.security = security self.password = password self.number_template = number_template + self.debug = _debug_on self.resource = resource self.name_prefix = name_prefix self.test_duration = test_duration @@ -58,7 +59,7 @@ class IPV4VariableTime(LFCliBase): def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) + cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) #print("==============\n", cx_list, "\n==============") cx_rx_map = {} for cx_name in cx_list['endpoint']: @@ -143,7 +144,7 @@ class IPV4VariableTime(LFCliBase): temp_sta_list = [] for station in range(len(self.sta_list)): temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self.cx_profile.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) self._pass("PASS: Station build finished") @@ -151,14 +152,14 @@ class IPV4VariableTime(LFCliBase): def main(): lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) ip_var_test = IPV4VariableTime(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, name_prefix="var_time", ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4", resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256, side_b_min_rate=256) + side_a_min_rate=256, side_b_min_rate=256, _debug_on=True) ip_var_test.cleanup(station_list) ip_var_test.build() From 068653dd32b82f91c1300828cac20b53644a4567 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 24 Jul 2020 15:18:20 -0700 Subject: [PATCH 002/134] Turned off debug use in class init --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index d07a0ace..0caab16f 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -159,7 +159,7 @@ def main(): password="jedway-wpa2-x2048-4-4", resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256, side_b_min_rate=256, _debug_on=True) + side_a_min_rate=256, side_b_min_rate=256, _debug_on=False) ip_var_test.cleanup(station_list) ip_var_test.build() From a4f37c4b89aed96893974ef6b174ebc1bddf6457 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 24 Jul 2020 17:05:17 -0700 Subject: [PATCH 003/134] Added start_cx, stop_cx, and cleanup methods to GenCxProfile --- py-json/realm.py | 89 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 17088919..482e3a2e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -745,33 +745,102 @@ class GenCXProfile(LFCliBase): self.type = "lfping" self.dest = "127.0.0.1" self.interval = 1 - self.count = 2 self.cmd = "" self.local_realm = local_realm + self.created_cx = [] + self.created_endp = [] + + def parse_command(self, sta_name): + if self.type == "lfping": + if (self.dest is not None or self.dest != "") and (self.interval is not None or self.interval > 0): + self.cmd = "%s -i %.1f -l %s %s" % (self.type, self.interval, sta_name, self.dest) + #print(self.cmd) + else: + raise ValueError("Please ensure dest and interval have been set correctly") + else: + raise ValueError("Unknown command type") + + def start_cx(self): + print("Starting CXs...") + print(self.created_cx) + print(self.created_endp) + for cx_name in self.created_cx: + self.json_post("/cli-json/set_cx_state", { + "test_mgr": "default_tm", + "cx_name": cx_name, + "cx_state": "RUNNING" + }, debug_=self.debug) + print(".", end='') + print("") + + def stop_cx(self): + print("Stopping CXs...") + for cx_name in self.created_cx: + self.json_post("/cli-json/set_cx_state", { + "test_mgr": "default_tm", + "cx_name": cx_name, + "cx_state": "STOPPED" + }, debug_=self.debug) + print(".", end='') + print("") + + def cleanup(self): + print("Cleaning up cxs and endpoints") + for cx_name in self.created_cx: + req_url = "cli-json/rm_cx" + data = { + "test_mgr": "default_tm", + "cx_name": cx_name + } + self.json_post(req_url, data) + + for endp_name in self.created_endp: + req_url = "cli-json/rm_endp" + data = { + "endp_name": endp_name + } + self.json_post(req_url, data) + def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None): if self.debug: - debug_ = True; + debug_ = True post_data = [] for port_name in ports: - gen_name = self.local_realm.name_to_eid(port_name)[-1] + "_gen0" - gen_name2 = self.local_realm.name_to_eid(port_name)[-1] + "_gen1" + port_info = self.local_realm.name_to_eid(port_name) + if len(port_info) == 2: + resource = 1 + shelf = port_info[0] + name = port_info[-1] + elif len(port_info) == 3: + resource = port_info[0] + shelf = port_info[1] + name = port_info[-1] + else: + raise ValueError("Unexpected name for port_name %s" % port_name) + + gen_name = name + "_gen0" + gen_name1 = name + "_gen1" genl = GenericCx(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port) - genl.createGenEndp(gen_name, 1, 1, port_name, "gen_generic") - genl.createGenEndp(gen_name2, 1, 1, port_name, "gen_generic") + genl.createGenEndp(gen_name, shelf, resource, name, "gen_generic") + genl.createGenEndp(gen_name1, shelf, resource, name, "gen_generic") genl.setFlags(gen_name, "ClearPortOnStart", 1) - genl.setFlags(gen_name2, "ClearPortOnStart", 1) - genl.setFlags(gen_name2, "Unmanaged", 1) + genl.setFlags(gen_name1, "ClearPortOnStart", 1) + genl.setFlags(gen_name1, "Unmanaged", 1) + self.parse_command(name) genl.setCmd(gen_name, self.cmd) time.sleep(sleep_time) data = { - "alias": self.local_realm.name_to_eid(port_name)[-1] + "_gen_CX", + "alias": "CX_" + name + "_gen", "test_mgr": "default_tm", "tx_endp": gen_name, - "rx_endp": gen_name2 + "rx_endp": gen_name1 } post_data.append(data) + self.created_cx.append("CX_" + name + "_gen") + self.created_endp.append(gen_name) + self.created_endp.append(gen_name1) for data in post_data: url = "/cli-json/add_cx" From bed2f6e0d319b70e4d444603b079abfb24528519 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 24 Jul 2020 17:05:33 -0700 Subject: [PATCH 004/134] Added test for generic connections WIP --- py-scripts/test_generic.py | 122 +++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 py-scripts/test_generic.py diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py new file mode 100755 index 00000000..26c53651 --- /dev/null +++ b/py-scripts/test_generic.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 + +import sys +import os + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils +import realm +import time +import datetime + + +class GenTest(LFCliBase): + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, + number_template="00000", test_duration="5m", type="lfping", dest="127.0.0.1", + interval=1, + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.ssid = ssid + self.sta_list = sta_list + self.security = security + self.password = password + self.number_template = number_template + self.resource = resource + self.name_prefix = name_prefix + self.test_duration = test_duration + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + self.cx_profile = self.local_realm.new_generic_cx_profile() + + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.password, + self.station_profile.security = self.security + self.station_profile.number_template_ = self.number_template + self.station_profile.mode = 0 + + self.cx_profile.type = type + self.cx_profile.dest = dest + self.cx_profile.interval = interval + + def start(self, print_pass=False, print_fail=False): + self.station_profile.admin_up(self.resource) + temp_stas = self.sta_list.copy() + # temp_stas.append("eth1") + self.local_realm.wait_for_ip(self.resource, temp_stas) + # cur_time = datetime.datetime.now() + # old_cx_rx_values = self.__get_rx_values() + # end_time = self.local_realm.parse_time(self.test_duration) + cur_time + self.cx_profile.start_cx() + time.sleep(30) + + def stop(self): + self.cx_profile.stop_cx() + for sta_name in self.sta_list: + data = LFUtils.portDownRequest(1, sta_name) + url = "json-cli/set_port" + self.json_post(url, data) + + def build(self): + self.station_profile.use_security(self.security, self.ssid, self.password) + self.station_profile.set_number_template(self.number_template) + print("Creating stations") + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + temp_sta_list = [] + for station in range(len(self.sta_list)): + temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.cx_profile.create(ports=temp_sta_list, sleep_time=.5) + self._pass("PASS: Station build finished") + + def cleanup(self, sta_list): + self.cx_profile.cleanup() + self.station_profile.cleanup(self.resource, sta_list) + LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + debug=self.debug) + + +def main(): + lfjson_host = "localhost" + lfjson_port = 8080 + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) + generic_test = GenTest(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, + name_prefix="var_time", type="lfping", dest="10.40.0.1", interval=1, + ssid="jedway-wpa2-x2048-4-4", + password="jedway-wpa2-x2048-4-4", + resource=1, + security="wpa2", test_duration="5m", ) + + generic_test.cleanup(station_list) + generic_test.build() + if not generic_test.passes(): + print(generic_test.get_fail_message()) + exit(1) + generic_test.start(False, False) + generic_test.stop() + if not generic_test.passes(): + print(generic_test.get_fail_message()) + exit(1) + time.sleep(30) + exit(1) + generic_test.cleanup(station_list) + if generic_test.passes(): + print("Full test passed, all connections increased rx bytes") + + +if __name__ == "__main__": + main() From 6332a322b0d8fe44358f31119fef1fa7d8f690f9 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 24 Jul 2020 14:46:43 -0700 Subject: [PATCH 005/134] python: whitespace --- py-json/LANforge/lfcli_base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 9e382f7a..db1a78ff 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -12,8 +12,7 @@ class LFCliBase: # do not use `super(LFCLiBase,self).__init__(self, host, port, _debug) # that is py2 era syntax and will force self into the host variable, making you # very confused. - def __init__(self, _lfjson_host, _lfjson_port, _debug=False, _halt_on_error=False, _exit_on_error=False, - _exit_on_fail=False): + def __init__(self, _lfjson_host, _lfjson_port, _debug=False, _halt_on_error=False, _exit_on_error=False, _exit_on_fail=False): self.fail_pref = "FAILED: " self.pass_pref = "PASSED: " self.lfclient_host = _lfjson_host From 9e38eec42e5337ad6ce6ca2b61b7175753d52d2d Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 24 Jul 2020 14:47:24 -0700 Subject: [PATCH 006/134] python: copy of powersave script for Syama's changes --- py-scripts/tip_station_powersave.py | 185 ++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100755 py-scripts/tip_station_powersave.py diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py new file mode 100755 index 00000000..f352aa48 --- /dev/null +++ b/py-scripts/tip_station_powersave.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 +import sys +import pprint +import os + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'),'py-json')) + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +from LANforge import LFUtils +import realm +import time +import datetime + +#Currently, this test can only be applied to UDP connections +class TIPStationPowersave(LFCliBase): + def __init__(self, host, port, ssid, security, password, station_list, side_a_min_rate=56, side_b_min_rate=56, side_a_max_rate=0, + side_b_max_rate=0, pdu_size = 1000, prefix="00000", test_duration="5m", + _debug_on=False, _exit_on_error=False, _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.ssid = ssid + self.security = security + self.password = password + self.sta_list = station_list + self.prefix = prefix + self.debug = _debug_on + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=False, halt_on_error_=True) + #upload + self.cx_prof_upload = realm.L3CXProfile(self.host, self.port, self.local_realm, + side_a_min_bps=side_a_min_rate,side_b_min_bps=0, + side_a_max_bps=side_a_max_rate,side_b_max_bps=0, + side_a_min_pdu=pdu_size, side_a_max_pdu=pdu_size, + side_b_min_pdu=0, side_b_max_pdu=0, debug_=False) + + #download + self.cx_prof_download = realm.L3CXProfile(self.host, self.port, self.local_realm, + side_a_min_bps=0, side_b_min_bps=side_b_min_rate, + side_a_max_bps=0,side_b_max_bps=side_b_max_rate, + side_a_min_pdu=0, side_a_max_pdu=0, + side_b_min_pdu=pdu_size,side_b_max_pdu=pdu_size, debug_=False) + self.test_duration = test_duration + self.sta_powersave_enabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, ssid=self.ssid, ssid_pass=self.password, + security=self.security, number_template_=self.prefix, mode=0, up=True, + dhcp=True, + debug_=False) + self.sta_powersave_disabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, ssid=self.ssid, ssid_pass=self.password, + security=self.security, number_template_=self.prefix, mode=0, up=True, + dhcp=True, + debug_=False) + self.new_monitor = realm.WifiMonitor(self.lfclient_url, self.local_realm,debug_= _debug_on) + + + def build(self): + self.sta_powersave_disabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) + self.sta_powersave_disabled_profile.set_number_template(self.prefix) + self.sta_powersave_disabled_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.sta_powersave_disabled_profile.set_command_param("set_port", "report_timer", 5000) + self.sta_powersave_disabled_profile.set_command_flag("set_port", "rpt_timer", 1) + + self.sta_powersave_enabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) + self.sta_powersave_enabled_profile.set_number_template(self.prefix) + self.sta_powersave_enabled_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.sta_powersave_enabled_profile.set_command_param("set_port", "report_timer", 5000) + self.sta_powersave_enabled_profile.set_command_flag("set_port", "rpt_timer", 1) + self.sta_powersave_enabled_profile.set_command_flag("add_sta", "power_save_enable", 1) + + self.new_monitor.create(resource_=1, channel=157, radio_= "wiphy1", name_="moni0") + self.sta_powersave_disabled_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + # station_channel = self.json_get("/port/1/%s/%s") + # pprint.pprint(station_channel) + + + self._pass("PASS: Station builds finished") + temp_sta_list = [] + for name in list(self.local_realm.station_list()): + if "sta" in list(name)[0]: + temp_sta_list.append(list(name)[0]) + + #print("temp_sta_list", temp_sta_list) + self.cx_prof_upload.name_prefix = "UDP_up" + self.cx_prof_download.name_prefix = "UDP_down" + print("Creating upload cx profile ") + self.cx_prof_upload.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + print("Creating download cx profile") + self.cx_prof_download.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + + def __set_all_cx_state(self, state, sleep_time=5): + + print("Setting CX States to %s" % state) + cx_list = list(self.local_realm.cx_list()) + for cx_name in cx_list: + req_url = "cli-json/set_cx_state" + data = { + "test_mgr": "default_tm", + "cx_name": cx_name, + "cx_state": state + } + self.json_post(req_url, data) + time.sleep(sleep_time) + + + def __get_rx_values(self): + cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False) + #print("==============\n", cx_list, "\n==============") + cx_rx_map = {} + for cx_name in cx_list['endpoint']: + if cx_name != 'uri' and cx_name != 'handler': + for item, value in cx_name.items(): + for value_name, value_rx in value.items(): + if value_name == 'rx bytes': + cx_rx_map[item] = value_rx + return cx_rx_map + + + def start(self, print_pass=False, print_fail = False): + #start one test, measure + #start second test, measure + cur_time = datetime.datetime.now() + end_time = self.local_realm.parse_time(self.test_duration) + cur_time + #admin up on new monitor + self.new_monitor.admin_up() + now = datetime.datetime.now() + date_time = now.strftime("%Y-%m-%d-%H%M%S") + curr_mon_name = self.new_monitor.monitor_name + #("date and time: ",date_time) + self.new_monitor.start_sniff("/home/lanforge/Documents/"+curr_mon_name+"-"+date_time+".cap") + #admin up on station + + self.sta_powersave_disabled_profile.admin_up(resource=1) + #self.new_monitor.set_flag() + self.__set_all_cx_state("RUNNING") + + while cur_time < end_time: + #DOUBLE CHECK + interval_time = cur_time + datetime.timedelta(minutes=1) + while cur_time < interval_time: + cur_time = datetime.datetime.now() + time.sleep(1) + + + def stop(self): + #switch off new monitor + self.new_monitor.admin_down() + self.__set_all_cx_state("STOPPED") + for sta_name in self.sta_list: + data = LFUtils.portDownRequest(1, sta_name) + url = "json-cli/set_port" + self.json_post(url, data) + + + def cleanup(self): + self.new_monitor.cleanup() + self.cx_prof_download.cleanup() + self.cx_prof_upload.cleanup() + self.sta_powersave_disabled_profile.cleanup(resource=1, desired_stations=self.sta_list) + + +def main(): + + lfjson_host = "localhost" + lfjson_port = 8080 + #station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) + station_list = ["sta0000","sta0001"] + ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, ssid = "jedway-open" , security = "open", + password ="[BLANK]", station_list = station_list , side_a_min_rate=2000, side_b_min_rate=2000, side_a_max_rate=0, + side_b_max_rate=0, prefix="00000", test_duration="30s", + _debug_on=False, _exit_on_error=True, _exit_on_fail=True) + ip_powersave_test.cleanup() + ip_powersave_test.build() + ip_powersave_test.start() + ip_powersave_test.stop() + ip_powersave_test.cleanup() + +if __name__ == "__main__": + + main() + From 9c012cf5c4710134339ea415fefd426756d5e1ed Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 24 Jul 2020 18:10:03 -0700 Subject: [PATCH 007/134] python: linter corrections --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 482e3a2e..7b2b7651 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -987,9 +987,9 @@ class StationProfile: types = {"wep": "wep_enable", "wpa": "wpa_enable", "wpa2": "wpa2_enable", "wpa3": "use-wpa3", "open": "[BLANK]"} self.add_sta_data["ssid"] = ssid if security_type in types.keys(): - if (ssid is None) or ("" == ssid): + if (ssid is None) or (ssid == ""): raise ValueError("use_security: %s requires ssid" % security_type) - if (passwd is None) or ("" == passwd): + if (passwd is None) or (passwd == ""): raise ValueError("use_security: %s requires passphrase or [BLANK]" % security_type) for name in types.values(): if name in self.desired_add_sta_flags and name in self.desired_add_sta_flags_mask: From d4fca21bd8bd4fa999baf136ccf4662d5e5bf11d Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 24 Jul 2020 18:10:41 -0700 Subject: [PATCH 008/134] tip_station_powersave.py: WIP with Syama's requests in mind --- py-scripts/tip_station_powersave.py | 141 +++++++++++++++++++--------- 1 file changed, 96 insertions(+), 45 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index f352aa48..5419be52 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -20,39 +20,72 @@ import datetime #Currently, this test can only be applied to UDP connections class TIPStationPowersave(LFCliBase): - def __init__(self, host, port, ssid, security, password, station_list, side_a_min_rate=56, side_b_min_rate=56, side_a_max_rate=0, - side_b_max_rate=0, pdu_size = 1000, prefix="00000", test_duration="5m", - _debug_on=False, _exit_on_error=False, _exit_on_fail=False): + def __init__(self, host, port, ssid, security, password, + normal_station_list_=None, + powersave_station_list_=None, + side_a_min_rate=56000, + side_b_min_rate=56000, + side_a_max_rate=0, + side_b_max_rate=0, + pdu_size = 1000, + prefix="00000", + traffic_duration_="5m", + pause_duration_="2s", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.ssid = ssid self.security = security self.password = password - self.sta_list = station_list + self.normal_sta_list = normal_station_list_ + self.powersave_sta_list = powersave_station_list_ self.prefix = prefix self.debug = _debug_on self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=False, halt_on_error_=True) #upload self.cx_prof_upload = realm.L3CXProfile(self.host, self.port, self.local_realm, - side_a_min_bps=side_a_min_rate,side_b_min_bps=0, - side_a_max_bps=side_a_max_rate,side_b_max_bps=0, - side_a_min_pdu=pdu_size, side_a_max_pdu=pdu_size, - side_b_min_pdu=0, side_b_max_pdu=0, debug_=False) + side_a_min_bps=side_a_min_rate, + side_b_min_bps=0, + side_a_max_bps=side_a_max_rate, + side_b_max_bps=0, + side_a_min_pdu=pdu_size, + side_a_max_pdu=pdu_size, + side_b_min_pdu=pdu_size, + side_b_max_pdu=pdu_size, + debug_=False) #download - self.cx_prof_download = realm.L3CXProfile(self.host, self.port, self.local_realm, - side_a_min_bps=0, side_b_min_bps=side_b_min_rate, - side_a_max_bps=0,side_b_max_bps=side_b_max_rate, - side_a_min_pdu=0, side_a_max_pdu=0, - side_b_min_pdu=pdu_size,side_b_max_pdu=pdu_size, debug_=False) - self.test_duration = test_duration - self.sta_powersave_enabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, ssid=self.ssid, ssid_pass=self.password, - security=self.security, number_template_=self.prefix, mode=0, up=True, - dhcp=True, - debug_=False) - self.sta_powersave_disabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, ssid=self.ssid, ssid_pass=self.password, - security=self.security, number_template_=self.prefix, mode=0, up=True, + self.cx_prof_download = realm.L3CXProfile(self.host, self.port, self.local_realm, + side_a_min_bps=0, + side_b_min_bps=side_b_min_rate, + side_a_max_bps=0, + side_b_max_bps=side_b_max_rate, + side_a_min_pdu=pdu_size, + side_a_max_pdu=pdu_size, + side_b_min_pdu=pdu_size, + side_b_max_pdu=pdu_size, + debug_=False) + self.test_duration = traffic_duration_ + self.pause_duration = pause_duration_ + self.sta_powersave_enabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, + ssid=self.ssid, + ssid_pass=self.password, + security=self.security, + number_template_=self.prefix, + mode=0, + up=True, + dhcp=True, + debug_=False) + self.sta_powersave_disabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, + ssid=self.ssid, + ssid_pass=self.password, + security=self.security, + number_template_=self.prefix, + mode=0, + up=True, dhcp=True, debug_=False) self.new_monitor = realm.WifiMonitor(self.lfclient_url, self.local_realm,debug_= _debug_on) @@ -73,12 +106,11 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_enabled_profile.set_command_flag("add_sta", "power_save_enable", 1) self.new_monitor.create(resource_=1, channel=157, radio_= "wiphy1", name_="moni0") - self.sta_powersave_disabled_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.sta_powersave_disabled_profile.create(resource=1, radio="wiphy0", sta_names_=self.normal_sta_list, debug=False) # station_channel = self.json_get("/port/1/%s/%s") # pprint.pprint(station_channel) - - - self._pass("PASS: Station builds finished") + + self._pass("PASS: Stations created") temp_sta_list = [] for name in list(self.local_realm.station_list()): if "sta" in list(name)[0]: @@ -92,8 +124,8 @@ class TIPStationPowersave(LFCliBase): print("Creating download cx profile") self.cx_prof_download.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + def __set_all_cx_state(self, state, sleep_time=5): - print("Setting CX States to %s" % state) cx_list = list(self.local_realm.cx_list()) for cx_name in cx_list: @@ -121,8 +153,16 @@ class TIPStationPowersave(LFCliBase): def start(self, print_pass=False, print_fail = False): - #start one test, measure - #start second test, measure + """ + This method is intended to start the monitor, the normal station (without powersave), + and the remaining power save stations. The powersave stations will transmit for tx duration, + pause, then the AP will pass along upstream traffic. This upstream traffic (download) should + express a beacon before actually delivering a buffer full of traffic in order to alert the + station it should wake up for incomming traffic. + :param print_pass: + :param print_fail: + :return: + """ cur_time = datetime.datetime.now() end_time = self.local_realm.parse_time(self.test_duration) + cur_time #admin up on new monitor @@ -132,25 +172,25 @@ class TIPStationPowersave(LFCliBase): curr_mon_name = self.new_monitor.monitor_name #("date and time: ",date_time) self.new_monitor.start_sniff("/home/lanforge/Documents/"+curr_mon_name+"-"+date_time+".cap") - #admin up on station - + time.sleep(0.05) self.sta_powersave_disabled_profile.admin_up(resource=1) - #self.new_monitor.set_flag() - self.__set_all_cx_state("RUNNING") + self.sta_powersave_enabled_profile.admin_up(resource=1) - while cur_time < end_time: - #DOUBLE CHECK - interval_time = cur_time + datetime.timedelta(minutes=1) - while cur_time < interval_time: - cur_time = datetime.datetime.now() - time.sleep(1) + self.cx_prof_download. + # self.__set_all_cx_state("RUNNING") + # while cur_time < end_time: + # #DOUBLE CHECK + # interval_time = cur_time + datetime.timedelta(minutes=1) + # while cur_time < interval_time: + # cur_time = datetime.datetime.now() + # time.sleep(1) def stop(self): #switch off new monitor self.new_monitor.admin_down() self.__set_all_cx_state("STOPPED") - for sta_name in self.sta_list: + for sta_name in self.normal_sta_list: data = LFUtils.portDownRequest(1, sta_name) url = "json-cli/set_port" self.json_post(url, data) @@ -160,19 +200,30 @@ class TIPStationPowersave(LFCliBase): self.new_monitor.cleanup() self.cx_prof_download.cleanup() self.cx_prof_upload.cleanup() - self.sta_powersave_disabled_profile.cleanup(resource=1, desired_stations=self.sta_list) + self.sta_powersave_disabled_profile.cleanup(resource=1, desired_stations=self.normal_sta_list) def main(): - lfjson_host = "localhost" lfjson_port = 8080 #station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) - station_list = ["sta0000","sta0001"] - ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, ssid = "jedway-open" , security = "open", - password ="[BLANK]", station_list = station_list , side_a_min_rate=2000, side_b_min_rate=2000, side_a_max_rate=0, - side_b_max_rate=0, prefix="00000", test_duration="30s", - _debug_on=False, _exit_on_error=True, _exit_on_fail=True) + normal_station_list = ["sta0000" ] + powersave_station_list = ["sta0001","sta0002","sta0003","sta0004"] + ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, + ssid="jedway-open", + security="open", + password="[BLANK]", + normal_station_list_=normal_station_list, + powersave_station_list_=powersave_station_list, + side_a_min_rate=20000, + side_b_min_rate=20000, + side_a_max_rate=0, + side_b_max_rate=0, + prefix="00000", + traffic_duration_="5s", + _debug_on=False, + _exit_on_error=True, + _exit_on_fail=True) ip_powersave_test.cleanup() ip_powersave_test.build() ip_powersave_test.start() From 13e76e6930af454461d001a616787cb43bbad456 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 27 Jul 2020 15:08:55 -0700 Subject: [PATCH 009/134] Fixed incorrect command option for generic commands --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 7b2b7651..dca1f766 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -753,7 +753,7 @@ class GenCXProfile(LFCliBase): def parse_command(self, sta_name): if self.type == "lfping": if (self.dest is not None or self.dest != "") and (self.interval is not None or self.interval > 0): - self.cmd = "%s -i %.1f -l %s %s" % (self.type, self.interval, sta_name, self.dest) + self.cmd = "%s -i %.1f -I %s %s" % (self.type, self.interval, sta_name, self.dest) #print(self.cmd) else: raise ValueError("Please ensure dest and interval have been set correctly") From fc6fc88dc75e50f8e7af4811e3ec326d13a030d4 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 27 Jul 2020 15:50:33 -0700 Subject: [PATCH 010/134] Increased traffic rate --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 0caab16f..191d12fc 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -159,7 +159,7 @@ def main(): password="jedway-wpa2-x2048-4-4", resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256, side_b_min_rate=256, _debug_on=False) + side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=False) ip_var_test.cleanup(station_list) ip_var_test.build() From c269393b8b6a618cd3e97a6c3454489e5fbae1db Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 27 Jul 2020 16:16:22 -0700 Subject: [PATCH 011/134] Fixed interval bug --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index dca1f766..4f588a7e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -753,7 +753,7 @@ class GenCXProfile(LFCliBase): def parse_command(self, sta_name): if self.type == "lfping": if (self.dest is not None or self.dest != "") and (self.interval is not None or self.interval > 0): - self.cmd = "%s -i %.1f -I %s %s" % (self.type, self.interval, sta_name, self.dest) + self.cmd = "%s -i %s -I %s %s" % (self.type, self.interval, sta_name, self.dest) #print(self.cmd) else: raise ValueError("Please ensure dest and interval have been set correctly") From cbc65f02ba44b627e16cfa2a38a3a94a608b0385 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 27 Jul 2020 16:23:36 -0700 Subject: [PATCH 012/134] Commented out debug printing --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 4f588a7e..2fdcf415 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -762,8 +762,8 @@ class GenCXProfile(LFCliBase): def start_cx(self): print("Starting CXs...") - print(self.created_cx) - print(self.created_endp) + #print(self.created_cx) + #print(self.created_endp) for cx_name in self.created_cx: self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", From ecc89e46ed490d45e1099dec2768c899af690807 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 28 Jul 2020 10:19:34 -0600 Subject: [PATCH 013/134] fixed the indexing so number of stations is correct --- py-scripts/test_l3_longevity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 413bcfa7..bff8a56f 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -294,7 +294,7 @@ def main(): if number_of_stations > MAX_NUMBER_OF_STATIONS: print("number of stations per radio exceeded") quit(1) - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) station_lists.append(station_list) index += 1 ip_var_test = L3VariableTimeLongevity(lfjson_host, From a00d5a782f8c8a8551f61c7365c13874838c45ab Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 28 Jul 2020 10:37:06 -0600 Subject: [PATCH 014/134] added number of max stations per radio to error message --- py-scripts/test_l3_longevity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index bff8a56f..6ce9f131 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -292,7 +292,7 @@ def main(): for radio in radios: number_of_stations = int(number_of_stations_per_radio_list[index]) if number_of_stations > MAX_NUMBER_OF_STATIONS: - print("number of stations per radio exceeded") + print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) quit(1) station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) station_lists.append(station_list) From f8b482c348d847585aa6cd48e629e1e3c8705490 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 28 Jul 2020 11:56:09 -0700 Subject: [PATCH 015/134] Finished start method, cleaned up main() --- py-scripts/test_generic.py | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 26c53651..4d919493 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -54,13 +54,35 @@ class GenTest(LFCliBase): def start(self, print_pass=False, print_fail=False): self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() - # temp_stas.append("eth1") + temp_stas.append("eth1") self.local_realm.wait_for_ip(self.resource, temp_stas) - # cur_time = datetime.datetime.now() - # old_cx_rx_values = self.__get_rx_values() - # end_time = self.local_realm.parse_time(self.test_duration) + cur_time + cur_time = datetime.datetime.now() + passes = 0 + expected_passes = 0 self.cx_profile.start_cx() - time.sleep(30) + time.sleep(15) + end_time = self.local_realm.parse_time("30s") + cur_time + print("Starting Test...") + while cur_time < end_time: + cur_time = datetime.datetime.now() + gen_results = self.json_get("generic/list?fields=name,last+results", debug_=self.debug) + if gen_results['endpoints'] is not None: + for name in gen_results['endpoints']: + for k, v in name.items(): + if v['name'] in self.cx_profile.created_endp and not v['name'].endswith('1'): + expected_passes += 1 + if v['last results'] != "" and "Unreachable" not in v['last results']: + passes += 1 + else: + self._fail("%s Failed to ping %s " % (v['name'], self.cx_profile.dest), print_fail) + break + # print(cur_time) + # print(end_time) + time.sleep(1) + + if passes == expected_passes: + self._pass("PASS: All tests passed", print_pass) + def stop(self): self.cx_profile.stop_cx() @@ -106,17 +128,17 @@ def main(): if not generic_test.passes(): print(generic_test.get_fail_message()) exit(1) - generic_test.start(False, False) - generic_test.stop() + generic_test.start() if not generic_test.passes(): print(generic_test.get_fail_message()) exit(1) + generic_test.stop() time.sleep(30) - exit(1) generic_test.cleanup(station_list) if generic_test.passes(): print("Full test passed, all connections increased rx bytes") + if __name__ == "__main__": main() From 9e63e3e478acdd1af1246c5339b7b39d3c68e9cd Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 14:11:38 -0700 Subject: [PATCH 016/134] Python: adds methods: - Realm::new_wifi_monitor_profile factory - new StationDown::admin_down() - changes up=False --- py-json/realm.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 2fdcf415..dfcd677c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -336,12 +336,23 @@ class Realm(LFCliBase): info = () def new_station_profile(self): - station_prof = StationProfile(self.lfclient_url, local_realm=self, debug_=self.debug) + station_prof = StationProfile(self.lfclient_url, local_realm=self, debug_=self.debug, up=False) return station_prof + def new_wifi_monitor_profile(self, resource_=1, debug_=False, up_=False): + wifi_mon_prof = WifiMonitor(self.lfclient_url, + local_realm=self, + resource_=resource_, + up=up_, + debug_=(self.debug or debug_)) + return wifi_mon_prof + def new_l3_cx_profile(self): - cx_prof = L3CXProfile(self.lfclient_host, self.lfclient_port, \ - local_realm=self, debug_=self.debug, report_timer_=3000) + cx_prof = L3CXProfile(self.lfclient_host, + self.lfclient_port, + local_realm=self, + debug_=self.debug, + report_timer_=3000) return cx_prof def new_l4_cx_profile(self): @@ -886,6 +897,7 @@ class WifiMonitor: "flags": computed_flags, "flags_mask": self.flags_mask }) + def set_flag(self, param_name, value): if (param_name not in add_monitor.flags): raise ValueError("Flag '%s' does not exist for add_monitor, consult add_monitor.py" % param_name) @@ -964,7 +976,6 @@ class StationProfile: "mode": 0, "mac": "xx:xx:xx:xx:*:xx", "flags": 0, # (0x400 + 0x20000 + 0x1000000000) # create admin down - } self.desired_set_port_cmd_flags = [] self.desired_set_port_current_flags = ["if_down"] @@ -1099,8 +1110,18 @@ class StationProfile: def admin_up(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portUpRequest(resource, None, debug_on=False) for sta_name in self.station_names: - req_json = LFUtils.portUpRequest(resource, sta_name, debug_on=False) + req_json["port"] = sta_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) + + def admin_down(self, resource): + set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portDownRequest(resource, None, debug_on=False) + for sta_name in self.station_names: + req_json["port"] = sta_name set_port_r.addPostData(req_json) json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) From e573cbe15f71a3bf5f625632739048ef625f5f58 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 14:12:07 -0700 Subject: [PATCH 017/134] json: tip_station_powersave.py WIP, also uses new methods --- py-scripts/tip_station_powersave.py | 272 ++++++++++++++++------------ 1 file changed, 152 insertions(+), 120 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 5419be52..4233faf3 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -20,124 +20,152 @@ import datetime #Currently, this test can only be applied to UDP connections class TIPStationPowersave(LFCliBase): - def __init__(self, host, port, ssid, security, password, + def __init__(self, host, port, + ssid=None, + security="open", + password="[BLANK]", + resource_=1, + channel_=0, normal_station_list_=None, + normal_station_radio_=None, powersave_station_list_=None, - side_a_min_rate=56000, - side_b_min_rate=56000, - side_a_max_rate=0, - side_b_max_rate=0, - pdu_size = 1000, - prefix="00000", - traffic_duration_="5m", + powersave_station_radio_=None, + monitor_name_=None, + monitor_radio_=None, + side_a_min_rate_=56000, + side_b_min_rate_=56000, + side_a_max_rate_=0, + side_b_max_rate_=0, + pdu_size_=1000, + traffic_duration_="5s", pause_duration_="2s", - _debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + debug_on_=False, + exit_on_error_=False, + exit_on_fail_=False): + super().__init__(host, port, _debug=debug_on_, _halt_on_error=exit_on_error_, _exit_on_fail=exit_on_fail_) + self.resource = resource_ + if (channel_ == 0): + raise ValueError("Please set your radio channel") + self.channel = channel_ + self.monitor_name = monitor_name_ + self.monitor_radio = monitor_radio_ self.host = host self.port = port self.ssid = ssid self.security = security self.password = password self.normal_sta_list = normal_station_list_ + self.normal_sta_radio = normal_station_radio_ self.powersave_sta_list = powersave_station_list_ - self.prefix = prefix - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=False, halt_on_error_=True) + self.powersave_sta_radio = powersave_station_radio_ + self.debug = debug_on_ + self.local_realm = realm.Realm(lfclient_host=self.host, + lfclient_port=self.port, + debug_=self.debug, + halt_on_error_=self.debug, + exit_on_error_=self.debug) + + # background traffic + self.cx_background = self.local_realm.new_l3_cx_profile() + self.cx_background.side_a_min_bps = side_a_min_rate_ + self.cx_background.side_b_min_bps = side_a_min_rate_ + self.cx_background.side_a_max_bps = side_a_max_rate_ + self.cx_background.side_b_max_bps = side_a_min_rate_ + #upload - self.cx_prof_upload = realm.L3CXProfile(self.host, self.port, self.local_realm, - side_a_min_bps=side_a_min_rate, - side_b_min_bps=0, - side_a_max_bps=side_a_max_rate, - side_b_max_bps=0, - side_a_min_pdu=pdu_size, - side_a_max_pdu=pdu_size, - side_b_min_pdu=pdu_size, - side_b_max_pdu=pdu_size, - debug_=False) - + self.cx_prof_upload = self.local_realm.new_l3_cx_profile() + self.cx_prof_upload.side_a_min_bps = side_a_min_rate_ + self.cx_prof_upload.side_b_min_bps = 0 + self.cx_prof_upload.side_a_max_bps = side_a_max_rate_ + self.cx_prof_upload.side_b_max_bps = 0 + + self.cx_prof_upload.side_a_min_pdu = pdu_size_ + self.cx_prof_upload.side_a_max_pdu = 0 + self.cx_prof_upload.side_b_min_pdu = pdu_size_ + self.cx_prof_upload.side_b_max_pdu = 0, + #download - self.cx_prof_download = realm.L3CXProfile(self.host, self.port, self.local_realm, - side_a_min_bps=0, - side_b_min_bps=side_b_min_rate, - side_a_max_bps=0, - side_b_max_bps=side_b_max_rate, - side_a_min_pdu=pdu_size, - side_a_max_pdu=pdu_size, - side_b_min_pdu=pdu_size, - side_b_max_pdu=pdu_size, - debug_=False) + self.cx_prof_download = self.local_realm.new_l3_cx_profile() + self.cx_prof_download.side_a_min_bps = 0 + self.cx_prof_download.side_b_min_bps = side_b_min_rate_ + self.cx_prof_download.side_a_max_bps = 0 + self.cx_prof_download.side_b_max_bps = side_b_max_rate_ + + self.cx_prof_download.side_a_min_pdu = pdu_size_ + self.cx_prof_download.side_a_max_pdu = 0 + self.cx_prof_download.side_b_min_pdu = pdu_size_ + self.cx_prof_download.side_b_max_pdu = 0 + self.test_duration = traffic_duration_ self.pause_duration = pause_duration_ - self.sta_powersave_enabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, - ssid=self.ssid, - ssid_pass=self.password, - security=self.security, - number_template_=self.prefix, - mode=0, - up=True, - dhcp=True, - debug_=False) - self.sta_powersave_disabled_profile = realm.StationProfile(self.lfclient_url, self.local_realm, - ssid=self.ssid, - ssid_pass=self.password, - security=self.security, - number_template_=self.prefix, - mode=0, - up=True, - dhcp=True, - debug_=False) - self.new_monitor = realm.WifiMonitor(self.lfclient_url, self.local_realm,debug_= _debug_on) + self.sta_powersave_enabled_profile = self.local_realm.new_station_profile() + self.sta_powersave_disabled_profile = self.local_realm.new_station_profile() + self.wifi_monitor_profile = self.local_realm.new_wifi_monitor_profile() + def build(self): self.sta_powersave_disabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) - self.sta_powersave_disabled_profile.set_number_template(self.prefix) + self.sta_powersave_disabled_profile.set_number_template(self.powersave_disabled_prefix) self.sta_powersave_disabled_profile.set_command_flag("add_sta", "create_admin_down", 1) self.sta_powersave_disabled_profile.set_command_param("set_port", "report_timer", 5000) self.sta_powersave_disabled_profile.set_command_flag("set_port", "rpt_timer", 1) self.sta_powersave_enabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) - self.sta_powersave_enabled_profile.set_number_template(self.prefix) + self.sta_powersave_enabled_profile.set_number_template(self.powersave_enabled_prefix) self.sta_powersave_enabled_profile.set_command_flag("add_sta", "create_admin_down", 1) self.sta_powersave_enabled_profile.set_command_param("set_port", "report_timer", 5000) self.sta_powersave_enabled_profile.set_command_flag("set_port", "rpt_timer", 1) self.sta_powersave_enabled_profile.set_command_flag("add_sta", "power_save_enable", 1) - self.new_monitor.create(resource_=1, channel=157, radio_= "wiphy1", name_="moni0") - self.sta_powersave_disabled_profile.create(resource=1, radio="wiphy0", sta_names_=self.normal_sta_list, debug=False) - # station_channel = self.json_get("/port/1/%s/%s") - # pprint.pprint(station_channel) + self.wifi_monitor_profile.create(resource_=self.resource, + channel=self.channel, + radio_=self.monitor_radio, + name_=self.monitor_name) + time.sleep(0.2) + mon_j = self.json_get("/port/1/%s/%s"%(self.resource, self.monitor_name)) + if ("interface" not in mon_j): + raise ValueError("No monitor found") - self._pass("PASS: Stations created") - temp_sta_list = [] + self.sta_powersave_disabled_profile.create(resource=1, + radio=self.normal_sta_radio, + sta_names_=self.normal_sta_list, + debug=self.debug) + + self.sta_powersave_enabled_profile.create(resource=1, + radio=self.powersave_sta_radio, + sta_names_=self.powersave_sta_list, + debug=self.debug) + temp_sta_map = {} for name in list(self.local_realm.station_list()): - if "sta" in list(name)[0]: - temp_sta_list.append(list(name)[0]) + if (name in self.sta_powersave_disabled_profile.station_names) \ + or (name in self.sta_powersave_enabled_profile.station_names): + temp_sta_map[name]=1 + if len(temp_sta_map) == (len(self.sta_powersave_disabled_profile.station_names) + len(self.sta_powersave_enabled_profile.station_names)): + self._pass("Stations created") + else: + self._fail("Not all stations created") + + print("Creating background cx profile ") + self.cx_background.name_prefix="udp_bg" + self.cx_background.create(endp_type="lf_udp", + side_a=self.normal_sta_list, + side_b="1.eth1", + sleep_time=.05) - #print("temp_sta_list", temp_sta_list) - self.cx_prof_upload.name_prefix = "UDP_up" - self.cx_prof_download.name_prefix = "UDP_down" print("Creating upload cx profile ") - self.cx_prof_upload.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + self.cx_prof_upload.name_prefix = "udp_up" + self.cx_prof_upload.create(endp_type="lf_udp", + side_a=self.powersave_sta_list, + side_b="1.eth1", + sleep_time=.05) + print("Creating download cx profile") - self.cx_prof_download.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) - - - def __set_all_cx_state(self, state, sleep_time=5): - print("Setting CX States to %s" % state) - cx_list = list(self.local_realm.cx_list()) - for cx_name in cx_list: - req_url = "cli-json/set_cx_state" - data = { - "test_mgr": "default_tm", - "cx_name": cx_name, - "cx_state": state - } - self.json_post(req_url, data) - time.sleep(sleep_time) - + self.cx_prof_download.name_prefix = "udp_down" + self.cx_prof_download.create(endp_type="lf_udp", + side_a=self.powersave_sta_list, + side_b="1.eth1", + sleep_time=.05) def __get_rx_values(self): cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False) @@ -163,67 +191,71 @@ class TIPStationPowersave(LFCliBase): :param print_fail: :return: """ - cur_time = datetime.datetime.now() - end_time = self.local_realm.parse_time(self.test_duration) + cur_time + #admin up on new monitor - self.new_monitor.admin_up() + self.wifi_monitor_profile.admin_up() now = datetime.datetime.now() date_time = now.strftime("%Y-%m-%d-%H%M%S") - curr_mon_name = self.new_monitor.monitor_name - #("date and time: ",date_time) - self.new_monitor.start_sniff("/home/lanforge/Documents/"+curr_mon_name+"-"+date_time+".cap") + curr_mon_name = self.wifi_monitor_profile.monitor_name + pcap_file = "/home/lanforge/Documents/%s-%s.pcap"%(curr_mon_name, date_time) + self.wifi_monitor_profile.start_sniff(pcap_file) time.sleep(0.05) + self.sta_powersave_disabled_profile.admin_up(resource=1) self.sta_powersave_enabled_profile.admin_up(resource=1) - self.cx_prof_download. - # self.__set_all_cx_state("RUNNING") - # while cur_time < end_time: - # #DOUBLE CHECK - # interval_time = cur_time + datetime.timedelta(minutes=1) - # while cur_time < interval_time: - # cur_time = datetime.datetime.now() - # time.sleep(1) + LFUtils.waitUntilPortsAdminUp(resource_id=self.resource, + base_url=self.local_realm.lfclient_url, + port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + self.cx_prof_background.start_cx() + print("Upload starts at: %d"%time.time()) + self.cx_prof_upload.start_cx() + time.sleep(float(self.test_duration)) + self.cx_prof_upload.stop_cx() + print("Upload ends at: %d"%time.time()) + time.sleep(float(self.pause_duration)) + # here is where we should sleep long enough for station to go to sleep + print("Download begins at: %d"%time.time()) + self.cx_prof_download.start_cx() + time.sleep(float(self.test_duration)) + self.cx_prof_download.stop_cx() def stop(self): #switch off new monitor - self.new_monitor.admin_down() - self.__set_all_cx_state("STOPPED") - for sta_name in self.normal_sta_list: - data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" - self.json_post(url, data) + self.wifi_monitor_profile.admin_down() + self.cx_prof_download.stop_cx() + self.cx_prof_upload.stop_cx() + self.sta_powersave_enabled_profile.admin_down() + self.sta_powersave_disabled_profile.admin_down() - def cleanup(self): - self.new_monitor.cleanup() + self.wifi_monitor_profile.cleanup() self.cx_prof_download.cleanup() self.cx_prof_upload.cleanup() self.sta_powersave_disabled_profile.cleanup(resource=1, desired_stations=self.normal_sta_list) - def main(): lfjson_host = "localhost" lfjson_port = 8080 #station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) - normal_station_list = ["sta0000" ] - powersave_station_list = ["sta0001","sta0002","sta0003","sta0004"] + normal_station_list = ["sta1000" ] + powersave_station_list = ["sta0001"] #,"sta0002","sta0003","sta0004"] ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, ssid="jedway-open", - security="open", - password="[BLANK]", normal_station_list_=normal_station_list, + normal_station_radio_="wiphy0", powersave_station_list_=powersave_station_list, - side_a_min_rate=20000, - side_b_min_rate=20000, - side_a_max_rate=0, - side_b_max_rate=0, - prefix="00000", + powersave_station_radio_="wiphy0", + monitor_name_="moni0", + monitor_radio_="wiphy1", + side_a_min_rate_=56000, + side_b_min_rate_=56000, traffic_duration_="5s", - _debug_on=False, - _exit_on_error=True, - _exit_on_fail=True) + pause_duration_="2s", + debug_on_=True, + exit_on_error_=True, + exit_on_fail_=True) ip_powersave_test.cleanup() ip_powersave_test.build() ip_powersave_test.start() From 73d18a517e3107a08a24f46bdbbdacff3f226ca8 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 28 Jul 2020 15:01:49 -0700 Subject: [PATCH 018/134] Fixed variable names and missing import --- py-scripts/test_ipv6_connection.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/py-scripts/test_ipv6_connection.py b/py-scripts/test_ipv6_connection.py index 3b3ee89f..32581162 100755 --- a/py-scripts/test_ipv6_connection.py +++ b/py-scripts/test_ipv6_connection.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import sys - +import os if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) @@ -20,7 +20,8 @@ class IPv6Test(LFCliBase): def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, num_stations=0, prefix="00000", _debug_on=False, _exit_on_error=False, - _exit_on_fail=False): + _exit_on_fail=False, + number_template="00"): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port @@ -33,6 +34,7 @@ class IPv6Test(LFCliBase): self.resource = resource self.prefix = prefix self.debug = _debug_on + self.number_template = number_template self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) self.station_profile = self.local_realm.new_station_profile() @@ -45,16 +47,16 @@ class IPv6Test(LFCliBase): def build(self): self.station_profile.use_security(self.security, self.ssid, self.password) - self.profile.set_number_template(self.prefix) + self.station_profile.set_number_template(self.prefix) print("Creating stations") - self.profile.set_command_flag("add_sta", "create_admin_down", 1) - self.profile.set_command_param("set_port", "report_timer", 1500) - self.profile.set_command_flag("set_port", "rpt_timer", 1) - self.profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): - self.profile.admin_up(1) + self.station_profile.admin_up(1) associated_map = {} ip_map = {} print("Starting test...") @@ -100,7 +102,7 @@ class IPv6Test(LFCliBase): self.json_post(url, data) def cleanup(self, sta_list): - self.profile.cleanup(self.resource, sta_list) + self.station_profile.cleanup(self.resource, sta_list) LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) From 93e80df537bf3219597c4dfb4312a2ff215d3305 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 17:00:14 -0700 Subject: [PATCH 019/134] tip_station_powersave.py fixes --- py-scripts/tip_station_powersave.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 4233faf3..0da97284 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -62,8 +62,7 @@ class TIPStationPowersave(LFCliBase): self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=self.debug, - halt_on_error_=self.debug, - exit_on_error_=self.debug) + halt_on_error_=self.exit_on_error) # background traffic self.cx_background = self.local_realm.new_l3_cx_profile() @@ -106,13 +105,11 @@ class TIPStationPowersave(LFCliBase): def build(self): self.sta_powersave_disabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) - self.sta_powersave_disabled_profile.set_number_template(self.powersave_disabled_prefix) self.sta_powersave_disabled_profile.set_command_flag("add_sta", "create_admin_down", 1) self.sta_powersave_disabled_profile.set_command_param("set_port", "report_timer", 5000) self.sta_powersave_disabled_profile.set_command_flag("set_port", "rpt_timer", 1) self.sta_powersave_enabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) - self.sta_powersave_enabled_profile.set_number_template(self.powersave_enabled_prefix) self.sta_powersave_enabled_profile.set_command_flag("add_sta", "create_admin_down", 1) self.sta_powersave_enabled_profile.set_command_param("set_port", "report_timer", 5000) self.sta_powersave_enabled_profile.set_command_flag("set_port", "rpt_timer", 1) @@ -122,6 +119,9 @@ class TIPStationPowersave(LFCliBase): channel=self.channel, radio_=self.monitor_radio, name_=self.monitor_name) + LFUtils.wait_until_ports_appear(resource_id=1, + base_url=self.local_realm.lfclient_url, + port_list=[self.monitor_name]) time.sleep(0.2) mon_j = self.json_get("/port/1/%s/%s"%(self.resource, self.monitor_name)) if ("interface" not in mon_j): @@ -243,6 +243,7 @@ def main(): powersave_station_list = ["sta0001"] #,"sta0002","sta0003","sta0004"] ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, ssid="jedway-open", + channel_=157, normal_station_list_=normal_station_list, normal_station_radio_="wiphy0", powersave_station_list_=powersave_station_list, From b9bcba58b0481e43bf61e5f4506e34c61d0776da Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 23:39:58 -0700 Subject: [PATCH 020/134] JSON: simplifies die_on_error logic --- py-json/LANforge/LFRequest.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index de647726..c70cef29 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -47,6 +47,8 @@ class LFRequest: # request first url on stack def formPost(self, show_error=True, debug=False, die_on_error_=False): + if self.die_on_error: + die_on_error_ = True if (debug == False) and (self.debug == True): debug = True; responses = [] @@ -87,16 +89,15 @@ class LFRequest: LFUtils.debug_printer.pprint(responses[0].reason) print("------------------------------------------------------------------------") - if (die_on_error_ == True) or (self.die_on_error == True): + if die_on_error_: exit(1) except urllib.error.URLError as uerror: - if (show_error): + if show_error: print("----- LFRequest::formPost:94 URLError: ---------------------------------------------") print("Reason: %s; URL: %s"%(uerror.reason, request.get_full_url())) print("------------------------------------------------------------------------") if (die_on_error_ == True) or (self.die_on_error == True): exit(1) - return None def jsonPost(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None): @@ -167,10 +168,12 @@ class LFRequest: return None def get(self, debug=False, die_on_error_=False): - if (debug == False) and (self.debug == True): + if self.debug == True: debug = True - if (debug): - print("get: url: "+self.requested_url) + if self.die_on_error == True: + die_on_error_ = True + if debug: + print("LFUtils.get: url: "+self.requested_url) myrequest = urllib.request.Request(url=self.requested_url, headers=self.default_headers) myresponses = [] try: @@ -198,14 +201,15 @@ class LFRequest: print("----- Response: --------------------------------------------------------") LFUtils.debug_printer.pprint(myresponses[0].reason) print("------------------------------------------------------------------------") - if (die_on_error_ == True) or (self.die_on_error == True): + if die_on_error_ == True: + # print("--------------------------------------------- s.doe %s v doe %s ---------------------------" % (self.die_on_error, die_on_error_)) exit(1) except urllib.error.URLError as uerror: if debug: print("----- LFRequest::get:205 URLError: ---------------------------------------------") print("Reason: %s; URL: %s"%(uerror.reason, myrequest.get_full_url())) print("------------------------------------------------------------------------") - if (die_on_error_ == True) or (self.die_on_error == True): + if die_on_error_ == True: exit(1) return None From 4e052391e823bc60877723c2ebe04cf0804cfe17 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 23:40:41 -0700 Subject: [PATCH 021/134] JSON: stop dying on 404 response; formatting --- py-json/LANforge/lfcli_base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index db1a78ff..560f6f00 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -70,9 +70,9 @@ class LFCliBase: lf_r.addPostData(_data) if debug_ or self.debug: LANforge.LFUtils.debug_printer.pprint(_data) - json_response = lf_r.jsonPost(show_error=self.debug, \ - debug=(self.debug or debug_), \ - response_json_list_=response_json_list_, \ + json_response = lf_r.jsonPost(show_error=self.debug, + debug=(self.debug or debug_), + response_json_list_=response_json_list_, die_on_error_=self.exit_on_error) if debug_ and (response_json_list_ is not None): pprint.pprint(response_json_list_) @@ -93,10 +93,11 @@ class LFCliBase: json_response = None try: lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=(self.debug or debug_), die_on_error_=self.exit_on_error) - json_response = lf_r.getAsJson(self.debug) + json_response = lf_r.getAsJson(debug_=self.debug, die_on_error_=self.halt_on_error) #debug_printer.pprint(json_response) if (json_response is None) and (self.debug or debug_): - raise ValueError(json_response) + print("LFCliBase.json_get: no entity/response, probabily status 404") + return None except ValueError as ve: if self.debug or self.halt_on_error or self.exit_on_error: print("jsonGet asked for " + _req_url) @@ -138,7 +139,6 @@ class LFCliBase: return reverse_map - def error(self, exception): # print("lfcli_base error: %s" % exception) pprint.pprint(exception) From 9435d53545b386dd7982a0cbf2013c84a5490858 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 23:41:26 -0700 Subject: [PATCH 022/134] JSON: tip_powersave: fixes cleanup --- py-scripts/tip_station_powersave.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 0da97284..03acce5d 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -230,10 +230,11 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_disabled_profile.admin_down() def cleanup(self): - self.wifi_monitor_profile.cleanup() + self.wifi_monitor_profile.cleanup(resource_=self.resource, desired_ports=[self.monitor_name]) self.cx_prof_download.cleanup() self.cx_prof_upload.cleanup() - self.sta_powersave_disabled_profile.cleanup(resource=1, desired_stations=self.normal_sta_list) + self.sta_powersave_enabled_profile.cleanup(resource=self.resource, desired_stations=self.powersave_sta_list) + self.sta_powersave_disabled_profile.cleanup(resource=self.resource, desired_stations=self.normal_sta_list) def main(): lfjson_host = "localhost" @@ -255,9 +256,9 @@ def main(): traffic_duration_="5s", pause_duration_="2s", debug_on_=True, - exit_on_error_=True, + exit_on_error_=False, exit_on_fail_=True) - ip_powersave_test.cleanup() + ip_powersave_test.cleanup() ip_powersave_test.build() ip_powersave_test.start() ip_powersave_test.stop() From 90f68c52368ec0ba006dc608d17dbc9181ae3506 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 28 Jul 2020 23:42:32 -0700 Subject: [PATCH 023/134] JSON: improves monitor creation and cleanup; fixes station cleanup; adds freq-channel table --- py-json/realm.py | 224 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 199 insertions(+), 25 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index dfcd677c..b2efef9b 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -21,6 +21,108 @@ class Realm(LFCliBase): # self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.check_connect() + self.chan_to_freq = {} + self.freq_to_chan = {} + freq = 0 + chan = 1 + for freq in range( 2412, 2472, 5): + self.freq_to_chan[freq] = chan + self.chan_to_freq[chan] = freq + chan += 1 + + self.chan_to_freq[14] = 2484 + self.chan_to_freq[34] = 5170 + self.chan_to_freq[36] = 5180 + self.chan_to_freq[38] = 5190 + self.chan_to_freq[40] = 5200 + self.chan_to_freq[42] = 5210 + self.chan_to_freq[44] = 5220 + self.chan_to_freq[46] = 5230 + self.chan_to_freq[48] = 5240 + self.chan_to_freq[52] = 5260 + self.chan_to_freq[56] = 5280 + self.chan_to_freq[60] = 5300 + self.chan_to_freq[64] = 5320 + self.chan_to_freq[100] = 5500 + self.chan_to_freq[104] = 5520 + self.chan_to_freq[108] = 5540 + self.chan_to_freq[112] = 5560 + self.chan_to_freq[116] = 5580 + self.chan_to_freq[120] = 5600 + self.chan_to_freq[124] = 5620 + self.chan_to_freq[128] = 5640 + self.chan_to_freq[132] = 5660 + self.chan_to_freq[136] = 5680 + self.chan_to_freq[140] = 5700 + self.chan_to_freq[144] = 5720 + self.chan_to_freq[149] = 5745 + self.chan_to_freq[153] = 5765 + self.chan_to_freq[157] = 5785 + self.chan_to_freq[161] = 5805 + self.chan_to_freq[165] = 5825 + self.chan_to_freq[169] = 5845 + self.chan_to_freq[173] = 5865 + + self.freq_to_chan[2484] = 14 + self.freq_to_chan[5170] = 34 + self.freq_to_chan[5180] = 36 + self.freq_to_chan[5190] = 38 + self.freq_to_chan[5200] = 40 + self.freq_to_chan[5210] = 42 + self.freq_to_chan[5220] = 44 + self.freq_to_chan[5230] = 46 + self.freq_to_chan[5240] = 48 + self.freq_to_chan[5260] = 52 + self.freq_to_chan[5280] = 56 + self.freq_to_chan[5300] = 60 + self.freq_to_chan[5320] = 64 + self.freq_to_chan[5500] = 100 + self.freq_to_chan[5520] = 104 + self.freq_to_chan[5540] = 108 + self.freq_to_chan[5560] = 112 + self.freq_to_chan[5580] = 116 + self.freq_to_chan[5600] = 120 + self.freq_to_chan[5620] = 124 + self.freq_to_chan[5640] = 128 + self.freq_to_chan[5660] = 132 + self.freq_to_chan[5680] = 136 + self.freq_to_chan[5700] = 140 + self.freq_to_chan[5720] = 144 + self.freq_to_chan[5745] = 149 + self.freq_to_chan[5765] = 153 + self.freq_to_chan[5785] = 157 + self.freq_to_chan[5805] = 161 + self.freq_to_chan[5825] = 165 + self.freq_to_chan[5845] = 169 + self.freq_to_chan[5865] = 173 + + # 4.9Ghz police band + self.chan_to_freq[183] = 4915 + self.chan_to_freq[184] = 4920 + self.chan_to_freq[185] = 4925 + self.chan_to_freq[187] = 4935 + self.chan_to_freq[188] = 4940 + self.chan_to_freq[189] = 4945 + self.chan_to_freq[192] = 4960 + self.chan_to_freq[194] = 4970 + self.chan_to_freq[196] = 4980 + + self.freq_to_chan[4915] = 183 + self.freq_to_chan[4920] = 184 + self.freq_to_chan[4925] = 185 + self.freq_to_chan[4935] = 187 + self.freq_to_chan[4940] = 188 + self.freq_to_chan[4945] = 189 + self.freq_to_chan[4960] = 192 + self.freq_to_chan[4970] = 194 + self.freq_to_chan[4980] = 196 + + + def channel_freq(self, channel_=0): + return self.chan_to_freq[channel_] + + def freq_channel(self, freq_=0): + return self.freq_to_chan[freq_] # checks for OK or BUSY when querying cli-json/cv+is_built def wait_while_building(self, debug_=False): @@ -878,17 +980,31 @@ class WifiMonitor: computed_flags = 0 for flag_n in self.flag_names: computed_flags += add_monitor.flags[flag_n] - data ={ - "shelf": 1, - "resource": resource_, - "radio": radio_, - "freqency":5785, - "mode": "NA", #0 for AUTO or "NA" - "channel": channel - - } - self.local_realm.json_post("/cli-json/set_wifi_radio", _data= data) + # we want to query the existing country code of the radio + # there's no reason to change it but we get hollering from server + # if we don't provide a value for the parameter + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country"%(resource_, radio_), debug_=self.debug) + if jr is None: + raise ValueError("No radio %s.%s found"%(resource_, radio_)) + + eid = "1.%s.%s"%(resource_, radio_) + frequency = 0 + country = 0 + if eid in jr: + country = jr[eid]["country"] + + data = { + "shelf": 1, + "resource": resource_, + "radio": radio_, + "mode": 0, #"NA", #0 for AUTO or "NA" + "channel": channel, + "country": country, + "frequency": self.local_realm.channel_freq(channel_=channel) + } + self.local_realm.json_post("/cli-json/set_wifi_radio", _data=data) + time.sleep(1) self.local_realm.json_post("/cli-json/add_monitor", { "shelf": 1, "resource": resource_, @@ -907,10 +1023,36 @@ class WifiMonitor: del self.flag_names[param_name] self.flags_mask |= add_monitor.flags[param_name] - def cleanup(self): + def cleanup(self, resource_=1, desired_ports=None): print("Cleaning up monitors") - LFUtils.removePort(resource=self.resource, port_name = self.monitor_name, baseurl=self.lfclient_url, debug=self.debug) - + if (desired_ports is None) or (len(desired_ports) < 1): + if (self.monitor_name is None) or (self.monitor_name == ""): + print("No monitor name set to delete") + return + LFUtils.removePort(resource=resource_, + port_name=self.monitor_name, + baseurl=self.lfclient_url, + debug=self.debug) + else: + names = ",".join(desired_ports) + existing_ports = self.local_realm.json_get("/port/1/%d/%s?fields=alias"%(resource_, names), debug_=False) + if (existing_ports is None) or ("interfaces" not in existing_ports) or ("interface" not in existing_ports): + print("No monitor names found to delete") + return + if ("interfaces" in existing_ports): + for eid,info in existing_ports["interfaces"].items(): + LFUtils.removePort(resource=resource_, + port_name=info["alias"], + baseurl=self.lfclient_url, + debug=self.debug) + if ("interface" in existing_ports): + for eid,info in existing_ports["interface"].items(): + LFUtils.removePort(resource=resource_, + port_name=info["alias"], + baseurl=self.lfclient_url, + debug=self.debug) + + def admin_up(self): up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.monitor_name) @@ -1126,20 +1268,52 @@ class StationProfile: json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) - def cleanup(self, resource, desired_stations): - current_stations = self.local_realm.json_get("port/1/%s/%s?fields=alias" % (resource, ','.join(self.station_names))) - if current_stations is not None and current_stations['interfaces'] is not None: - print("Cleaning up stations") + def cleanup(self, resource, desired_stations=None, delay=0.03): + print("Cleaning up stations") + req_url = "/cli-json/rm_vlan" + data = { + "shelf": 1, + "resource": resource, + "port": None + } + if (desired_stations is not None): + if len(desired_stations) < 1: + print("No stations requested for cleanup, returning.") + return + names = ','.join(desired_stations) + current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) + if current_stations is None: + return + if "interfaces" in current_stations: + for station in current_stations['interfaces']: + for eid,info in station.items(): + data["port"] = info["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + time.sleep(delay) + + if "interface" in current_stations: + data["port"] = current_stations["interface"]["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + + return + + names = ','.join(self.station_names) + current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) + if current_stations is None or current_stations['interfaces'] is None: + print("No stations to clean up") + return + + if "interfaces" in current_stations: for station in current_stations['interfaces']: for eid,info in station.items(): - if info['alias'] in desired_stations: - req_url = "cli-json/rm_vlan" - data = { - "shelf": 1, - "resource": resource, - "port": info['alias'] - } - self.local_realm.json_post(req_url, data) + data["port"] = info["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + time.sleep(delay) + + if "interface" in current_stations: + data["port"] = current_stations["interface"]["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False): From 8e49bc10124fdecbe53fe434a20c78b9e0f1d0ce Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 29 Jul 2020 10:17:16 -0600 Subject: [PATCH 024/134] added upstream_port to help text --- py-scripts/test_l3_longevity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 6ce9f131..bc46e37d 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -211,7 +211,7 @@ def main(): Scripts are executed from: ./lanforge/py-scripts Generic command layout: - python3 .\\test_l3_longevity.py --test_duration --endp_type --radio + python3 .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio From 6a46dd326bf75c89f91a0fab3659ddd55e1631a4 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 29 Jul 2020 11:47:37 -0600 Subject: [PATCH 025/134] modified command line in help --- py-scripts/test_l3_longevity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index bc46e37d..b25b4b8d 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -211,7 +211,7 @@ def main(): Scripts are executed from: ./lanforge/py-scripts Generic command layout: - python3 .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio + python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio From 95b28740f484b95231e60403b26d3bdec91358b2 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 29 Jul 2020 13:16:41 -0700 Subject: [PATCH 026/134] Moved some functions in start around --- py-scripts/test_ipv4_l4_urls_per_ten.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index ee4cfdd0..0e4eb811 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -80,7 +80,6 @@ class IPV4L4(LFCliBase): def build(self): # Build stations self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) print("Creating stations") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) @@ -96,13 +95,13 @@ class IPV4L4(LFCliBase): def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() temp_stas.append("eth1") - self.local_realm.wait_for_ip(self.resource, temp_stas) - self.cx_profile.start_cx() cur_time = datetime.datetime.now() interval_time = cur_time + datetime.timedelta(minutes=10) passes = 0 expected_passes = 0 self.station_profile.admin_up(1) + self.local_realm.wait_for_ip(self.resource, temp_stas) + self.cx_profile.start_cx() print("Starting test") for test in range(self.num_tests): expected_passes += 1 From 37c9618f383d2cb062223ac9907866cb67f982f6 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 29 Jul 2020 13:21:54 -0700 Subject: [PATCH 027/134] Fixed hard-coded variable --- py-scripts/test_ipv4_l4_urls_per_ten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 0e4eb811..02663ef5 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -72,7 +72,7 @@ class IPV4L4(LFCliBase): for item in endp_list: expected_passes += 1 for name, info in item.items(): - if info['urls/s'] * 600 > 600 * .9: + if info['urls/s'] * self.target_requests_per_ten > self.target_requests_per_ten * .9: passes += 1 return passes == expected_passes From dcec9e535f044ab06dd85239404f7d104db307f4 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 29 Jul 2020 15:40:01 -0700 Subject: [PATCH 028/134] Removed unused method --- py-scripts/test_ipv4_l4_urls_per_ten.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 02663ef5..4c15aaed 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -51,18 +51,6 @@ class IPV4L4(LFCliBase): self.cx_profile.url = self.url self.cx_profile.requests_per_ten = self.requests_per_ten - def __set_all_cx_state(self, state, sleep_time=5): - print("Setting CX States to %s" % state) - for sta_name in self.sta_list: - req_url = "cli-json/set_cx_state" - data = { - "test_mgr": "default_tm", - "cx_name": "CX_" + sta_name + "_l4", - "cx_state": state - } - self.json_post(req_url, data) - time.sleep(sleep_time) - def __check_request_rate(self): endp_list = self.json_get("layer4/list?fields=urls/s") expected_passes = 0 From 1ed694a155dc1ba920053f68260e5430f7e5e193 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 29 Jul 2020 22:20:25 -0700 Subject: [PATCH 029/134] LFRequest.py: improves self.die_on_error logic to absolutely die on conditions that are !404 --- py-json/LANforge/LFRequest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index c70cef29..d82c147f 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -103,6 +103,8 @@ class LFRequest: def jsonPost(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None): if (debug == False) and (self.debug == True): debug = True + if self.die_on_error: + die_on_error_ = True responses = [] if ((self.post_data != None) and (self.post_data is not self.No_Data)): request = urllib.request.Request(url=self.requested_url, @@ -156,8 +158,8 @@ class LFRequest: print("----- Response: --------------------------------------------------------") LFUtils.debug_printer.pprint(responses[0].reason) print("------------------------------------------------------------------------") - if (die_on_error_ == True) or (self.die_on_error == True): - exit(1) + if die_on_error_ or (error.code != 404): + exit(1) except urllib.error.URLError as uerror: if show_error: print("----- LFRequest::jsonPost:162 URLError: ---------------------------------------------") From 28da5fe1906f211241c8e1e76f01f2f54c5c7b7e Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 10:05:26 -0700 Subject: [PATCH 030/134] Fixed typo with cli-json --- py-scripts/test_generic.py | 2 +- py-scripts/test_ipv4_l4.py | 2 +- py-scripts/test_ipv4_l4_urls_per_ten.py | 2 +- py-scripts/test_ipv4_variable_time.py | 2 +- py-scripts/test_ipv6_connection.py | 2 +- py-scripts/test_ipv6_variable_time.py | 2 +- py-scripts/test_wep_connection.py | 2 +- py-scripts/test_wpa2_connection.py | 2 +- py-scripts/test_wpa3_connection.py | 2 +- py-scripts/test_wpa_connection.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 4d919493..e7f914e8 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -88,7 +88,7 @@ class GenTest(LFCliBase): self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def build(self): diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index 7ea3d86e..35af1e9d 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -136,7 +136,7 @@ class IPV4L4(LFCliBase): self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 4c15aaed..eebd511f 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -114,7 +114,7 @@ class IPV4L4(LFCliBase): self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 191d12fc..dc11c61b 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -125,7 +125,7 @@ class IPV4VariableTime(LFCliBase): self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): diff --git a/py-scripts/test_ipv6_connection.py b/py-scripts/test_ipv6_connection.py index 32581162..9c1aeee4 100755 --- a/py-scripts/test_ipv6_connection.py +++ b/py-scripts/test_ipv6_connection.py @@ -97,7 +97,7 @@ class IPv6Test(LFCliBase): # Bring stations down for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" # print(sta_name) self.json_post(url, data) diff --git a/py-scripts/test_ipv6_variable_time.py b/py-scripts/test_ipv6_variable_time.py index c647ab95..6769bcfb 100755 --- a/py-scripts/test_ipv6_variable_time.py +++ b/py-scripts/test_ipv6_variable_time.py @@ -126,7 +126,7 @@ class IPV6VariableTime(LFCliBase): self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): diff --git a/py-scripts/test_wep_connection.py b/py-scripts/test_wep_connection.py index 8a825834..f0195ee0 100755 --- a/py-scripts/test_wep_connection.py +++ b/py-scripts/test_wep_connection.py @@ -92,7 +92,7 @@ class IPv4Test(LFCliBase): # Bring stations down for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" # print(sta_name) self.json_post(url, data) diff --git a/py-scripts/test_wpa2_connection.py b/py-scripts/test_wpa2_connection.py index 2b1e1acb..e4d45805 100755 --- a/py-scripts/test_wpa2_connection.py +++ b/py-scripts/test_wpa2_connection.py @@ -92,7 +92,7 @@ class IPv4Test(LFCliBase): # Bring stations down for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" # print(sta_name) self.json_post(url, data) diff --git a/py-scripts/test_wpa3_connection.py b/py-scripts/test_wpa3_connection.py index cd3660fb..a47ea720 100755 --- a/py-scripts/test_wpa3_connection.py +++ b/py-scripts/test_wpa3_connection.py @@ -92,7 +92,7 @@ class IPv4Test(LFCliBase): # Bring stations down for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" # print(sta_name) self.json_post(url, data) diff --git a/py-scripts/test_wpa_connection.py b/py-scripts/test_wpa_connection.py index 4a10be14..880d6872 100755 --- a/py-scripts/test_wpa_connection.py +++ b/py-scripts/test_wpa_connection.py @@ -92,7 +92,7 @@ class IPv4Test(LFCliBase): # Bring stations down for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, sta_name) - url = "json-cli/set_port" + url = "cli-json/set_port" # print(sta_name) self.json_post(url, data) From b1e34423b8aa906f1e2ab7f4cdd1fa5e4087942f Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 10:05:57 -0700 Subject: [PATCH 031/134] Added flags for add_vap --- py-json/LANforge/add_vap.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 py-json/LANforge/add_vap.py diff --git a/py-json/LANforge/add_vap.py b/py-json/LANforge/add_vap.py new file mode 100644 index 00000000..7a0beed3 --- /dev/null +++ b/py-json/LANforge/add_vap.py @@ -0,0 +1,30 @@ +add_vap_flags = { +"enable_wpa" : 0x10, # Enable WPA +"hostpad_config" : 0x20, # Use Custom hostapd config file. +"enable_80211d" : 0x40, # Enable 802.11D to broadcast country-code & channels in VAPs +"short_preamble" : 0x80, # Allow short-preamble +"pri_sec_ch_enable" : 0x100, # Enable Primary/Secondary channel switch. +"wep_enable" : 0x200, # Enable WEP Encryption +"wpa2_enable" : 0x400, # Enable WPA2 Encryption +"disable_ht40" : 0x800, # Disable HT-40 (will use HT-20 if available). +"verbose" : 0x10000, # Verbose-Debug: Increase debug info in wpa-supplicant and hostapd logs. +"80211u_enable" : 0x20000, # Enable 802.11u (Interworking) feature. +"80211u_auto" : 0x40000, # Enable 802.11u (Interworking) Auto-internetworking feature. Always enabled currently. +"80211u_gw" : 0x80000, # AP Provides access to internet (802.11u Interworking) +"80211u_additional" : 0x100000, # AP requires additional step for access (802.11u Interworking) +"80211u_e911" : 0x200000, # AP claims emergency services reachable (802.11u Interworking) +"80211u_e911_unauth" : 0x400000, # AP provides Unauthenticated emergency services (802.11u Interworking) +"hs20_enable" : 0x800000, # Enable Hotspot 2.0 (HS20) feature. Requires WPA-2. +"disable_dgaf" : 0x1000000, # AP Disable DGAF (used by HotSpot 2.0). +"8021x_radius" : 0x2000000, # Use 802.1x (RADIUS for AP). +"80211r_pmska_cache" : 0x4000000, # Enable oportunistic PMSKA caching for WPA2 (Related to 802.11r). +"disable_ht80" : 0x8000000, # Disable HT80 (for AC chipset NICs only) +"80211h_enable" : 0x10000000, # Enable 802.11h (needed for running on DFS channels) Requires 802.11d. +"osen_enable" : 0x40000000, # Enable OSEN protocol (OSU Server-only Authentication) +"ht160_enable" : 0x100000000, # Enable HT160 mode. +"create_admin_down" : 0x1000000000, # Station should be created admin-down. +"use-wpa3" : 0x10000000000, # Enable WPA-3 (SAE Personal) mode. +"use-bss-load" : 0x20000000000, # Enable BSS Load IE in Beacons and Probe Responses (.11e). +"use-rrm-report" : 0x40000000000, # Enable Radio measurements IE in beacon and probe responses. +"use-bss-transition" : 0x80000000000, # Enable BSS transition. +} From 4336ddb74eee23d98f8089c140f106cc259feccd Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 12:35:49 -0700 Subject: [PATCH 032/134] Fixed typo --- py-json/LANforge/LFUtils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index f6d57a31..f724a977 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -324,7 +324,7 @@ def waitUntilPortsAdminUp(resource_id=1, base_url="http://localhost:8080", port_ lf_r = LFRequest.LFRequest(base_url, uri) json_response = lf_r.getAsJson(debug_=False) if json_response == None: - print("port %s disappeared" % port_name) + print("port %s appeared" % port_name) continue if "interface" in json_response: json_response = json_response['interface'] From 7efbce8a46928c9399ed356ffa5c55c629e199a4 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 12:36:05 -0700 Subject: [PATCH 033/134] Fixed missing self.debug for create method --- py-scripts/test_generic.py | 2 +- py-scripts/test_ipv4_variable_time.py | 6 ++++-- py-scripts/test_ipv6_connection.py | 2 +- py-scripts/test_ipv6_variable_time.py | 2 +- py-scripts/test_wep_connection.py | 2 +- py-scripts/test_wpa2_connection.py | 2 +- py-scripts/test_wpa3_connection.py | 2 +- py-scripts/test_wpa_connection.py | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index e7f914e8..45d86c1f 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -101,7 +101,7 @@ class GenTest(LFCliBase): temp_sta_list = [] for station in range(len(self.sta_list)): temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self.cx_profile.create(ports=temp_sta_list, sleep_time=.5) self._pass("PASS: Station build finished") diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index dc11c61b..462739dd 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -60,13 +60,14 @@ class IPV4VariableTime(LFCliBase): def __get_rx_values(self): cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) + # print(self.cx_profile.created_cx.values()) #print("==============\n", cx_list, "\n==============") cx_rx_map = {} for cx_name in cx_list['endpoint']: if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'rx bytes': + if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): cx_rx_map[item] = value_rx return cx_rx_map @@ -88,6 +89,7 @@ class IPV4VariableTime(LFCliBase): return False def start(self, print_pass=False, print_fail=False): + LFUtils.wait_until_ports_disappear self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") @@ -159,7 +161,7 @@ def main(): password="jedway-wpa2-x2048-4-4", resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=False) + side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=True) ip_var_test.cleanup(station_list) ip_var_test.build() diff --git a/py-scripts/test_ipv6_connection.py b/py-scripts/test_ipv6_connection.py index 9c1aeee4..e9829548 100755 --- a/py-scripts/test_ipv6_connection.py +++ b/py-scripts/test_ipv6_connection.py @@ -52,7 +52,7 @@ class IPv6Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): diff --git a/py-scripts/test_ipv6_variable_time.py b/py-scripts/test_ipv6_variable_time.py index 6769bcfb..f7f29b79 100755 --- a/py-scripts/test_ipv6_variable_time.py +++ b/py-scripts/test_ipv6_variable_time.py @@ -145,7 +145,7 @@ class IPV6VariableTime(LFCliBase): temp_sta_list = [] for station in range(len(self.sta_list)): temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self.cx_profile.create(endp_type="lf_udp6", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) self._pass("PASS: Station build finished") diff --git a/py-scripts/test_wep_connection.py b/py-scripts/test_wep_connection.py index f0195ee0..1f001a56 100755 --- a/py-scripts/test_wep_connection.py +++ b/py-scripts/test_wep_connection.py @@ -49,7 +49,7 @@ class IPv4Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): diff --git a/py-scripts/test_wpa2_connection.py b/py-scripts/test_wpa2_connection.py index e4d45805..085107cc 100755 --- a/py-scripts/test_wpa2_connection.py +++ b/py-scripts/test_wpa2_connection.py @@ -49,7 +49,7 @@ class IPv4Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): diff --git a/py-scripts/test_wpa3_connection.py b/py-scripts/test_wpa3_connection.py index a47ea720..a19dcf98 100755 --- a/py-scripts/test_wpa3_connection.py +++ b/py-scripts/test_wpa3_connection.py @@ -49,7 +49,7 @@ class IPv4Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): diff --git a/py-scripts/test_wpa_connection.py b/py-scripts/test_wpa_connection.py index 880d6872..b07d7527 100755 --- a/py-scripts/test_wpa_connection.py +++ b/py-scripts/test_wpa_connection.py @@ -49,7 +49,7 @@ class IPv4Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): From 3a5a1db3a411e45595ada0946c6f47050a006347 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 13:50:38 -0700 Subject: [PATCH 034/134] Realm.py: StationProfile.create() gains suppress_related_commands_ parameter --- py-json/realm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index b2efef9b..701ee913 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1316,7 +1316,7 @@ class StationProfile: # Checks for errors in initialization values and creates specified number of stations using init parameters - def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False): + def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=False): # try: # resource = resource_radio[0: resource_radio.index(".")] # name = resource_radio[resource_radio.index(".") + 1:] @@ -1347,7 +1347,8 @@ class StationProfile: set_port.set_port_current_flags) self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags, set_port.set_port_interest_flags) - + # these are unactivated LFRequest objects that we can modify and + # re-use inside a loop, reducing the number of object creations add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") self.station_names = [] @@ -1356,7 +1357,7 @@ class StationProfile: else: self.station_names = sta_names_ - if len(self.station_names) >= 15: + if (len(self.station_names) >= 15) or (suppress_related_commands_ == True): self.add_sta_data["suppress_preexec_cli"] = "yes" self.add_sta_data["suppress_preexec_method"] = 1 self.set_port_data["suppress_preexec_cli"] = "yes" From c54d342a8e620348ee186f07fe01007969794d7d Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 13:51:05 -0700 Subject: [PATCH 035/134] LFUtils.py: whitespace --- py-json/LANforge/LFUtils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index f724a977..9ed349f5 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -375,7 +375,6 @@ def wait_until_ports_appear(resource_id=1, base_url="http://localhost:8080", por :param debug: :return: """ - print("Waiting until ports appear...") found_stations = [] sleep(2) From 29e831dbb2a3097b301216aa753199fa7bcaf233 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 13:51:39 -0700 Subject: [PATCH 036/134] sta_connect2.py: updated to use modern Realm methods --- py-scripts/sta_connect2.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/py-scripts/sta_connect2.py b/py-scripts/sta_connect2.py index 87cce840..13894295 100755 --- a/py-scripts/sta_connect2.py +++ b/py-scripts/sta_connect2.py @@ -62,7 +62,7 @@ class StaConnect2(LFCliBase): self.localrealm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6 self.resulting_stations = {} self.resulting_endpoints = {} - self.sta_profile = None + self.station_profile = None self.l3_udp_profile = None self.l3_tcp_profile = None @@ -147,14 +147,14 @@ class StaConnect2(LFCliBase): self.station_profile = self.localrealm.new_station_profile() if self.dut_security == WPA2: - self.station_profile.use_wpa2(on=True, ssid=self.dut_ssid, passwd=self.dut_passwd) + self.station_profile.use_security(security_type="wpa2", ssid=self.dut_ssid, passwd=self.dut_passwd) elif self.dut_security == OPEN: - self.station_profile.use_wpa2(on=False, ssid=self.dut_ssid) + self.station_profile.use_security(security_type="open", ssid=self.dut_ssid, passwd="[BLANK]") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) print("Adding new stations ", end="") - self.station_profile.create(resource=self.resource, radio=self.radio, sta_names_=self.station_names, up_=False, debug=False) - LFUtils.wait_until_ports_appear(self.resource, self.lfclient_url, self.station_names) + self.station_profile.create(resource=self.resource, radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True) + LFUtils.wait_until_ports_appear(self.resource, self.lfclient_url, self.station_names, debug=self.debug) # Create UDP endpoints self.l3_udp_profile = self.localrealm.new_l3_cx_profile() @@ -181,7 +181,12 @@ class StaConnect2(LFCliBase): suppress_related_commands=True) def start(self): - if not self.station_profile.up: + if self.station_profile is None: + self._fail("Incorrect setup") + pprint.pprint(self.station_profile) + if self.station_profile.up is None: + self._fail("Incorrect station profile, missing profile.up") + if self.station_profile.up == False: print("\nBringing ports up...") data = {"shelf": 1, "resource": self.resource, @@ -375,7 +380,10 @@ Example: if args.debug in on_flags: debug_v = True - staConnect = StaConnect2(lfjson_host, lfjson_port, debug_=debug_v) + staConnect = StaConnect2(lfjson_host, lfjson_port, + debug_=True, + _exit_on_fail=True, + _exit_on_error=False) staConnect.station_names = [ "sta0000" ] if args.user is not None: staConnect.user = args.user From a56748e501af252bb9b257ddb6ddb43ca4b59602 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 14:18:12 -0700 Subject: [PATCH 037/134] Set suppress_related_commands_ in StationProfile,create to default to True --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 701ee913..102f2d26 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1316,7 +1316,7 @@ class StationProfile: # Checks for errors in initialization values and creates specified number of stations using init parameters - def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=False): + def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=True): # try: # resource = resource_radio[0: resource_radio.index(".")] # name = resource_radio[resource_radio.index(".") + 1:] From b51f4aaecf30f97ef06a48ddc77cb191a03b2047 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 14:20:47 -0700 Subject: [PATCH 038/134] Turned off debugging --- py-scripts/test_ipv4_variable_time.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 462739dd..a193f66e 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -89,7 +89,6 @@ class IPV4VariableTime(LFCliBase): return False def start(self, print_pass=False, print_fail=False): - LFUtils.wait_until_ports_disappear self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") @@ -161,7 +160,7 @@ def main(): password="jedway-wpa2-x2048-4-4", resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=True) + side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=False) ip_var_test.cleanup(station_list) ip_var_test.build() From f8af6d597986b1473f53710a8f99b279d33c6abf Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 14:21:18 -0700 Subject: [PATCH 039/134] Added check for monitoring only created endpoints --- py-scripts/test_ipv6_variable_time.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_ipv6_variable_time.py b/py-scripts/test_ipv6_variable_time.py index f7f29b79..9e8540a7 100755 --- a/py-scripts/test_ipv6_variable_time.py +++ b/py-scripts/test_ipv6_variable_time.py @@ -59,14 +59,15 @@ class IPV6VariableTime(LFCliBase): def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) + cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) + # print(self.cx_profile.created_cx.values()) #print("==============\n", cx_list, "\n==============") cx_rx_map = {} for cx_name in cx_list['endpoint']: if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'rx bytes': + if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): cx_rx_map[item] = value_rx return cx_rx_map From 54657fc74ca5d91e39db1484b43d52b1beb16e15 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 15:27:29 -0700 Subject: [PATCH 040/134] Added check to prevent existing endps from interfering in test --- py-scripts/test_ipv4_l4_urls_per_ten.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index eebd511f..f80fbd45 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -20,7 +20,7 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, - target_requests_per_ten=600, number_template="00000", resource=1, num_tests=1, + target_requests_per_ten=60, number_template="00000", resource=1, num_tests=1, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): @@ -58,10 +58,12 @@ class IPV4L4(LFCliBase): if endp_list is not None and endp_list['endpoint'] is not None: endp_list = endp_list['endpoint'] for item in endp_list: - expected_passes += 1 for name, info in item.items(): - if info['urls/s'] * self.target_requests_per_ten > self.target_requests_per_ten * .9: - passes += 1 + if name in self.cx_profile.created_cx.keys(): + expected_passes += 1 + if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + passes += 1 return passes == expected_passes @@ -84,7 +86,7 @@ class IPV4L4(LFCliBase): temp_stas = self.sta_list.copy() temp_stas.append("eth1") cur_time = datetime.datetime.now() - interval_time = cur_time + datetime.timedelta(minutes=10) + interval_time = cur_time + datetime.timedelta(minutes=2) passes = 0 expected_passes = 0 self.station_profile.admin_up(1) @@ -106,7 +108,7 @@ class IPV4L4(LFCliBase): else: self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) break - interval_time = cur_time + datetime.timedelta(minutes=10) + interval_time = cur_time + datetime.timedelta(minutes=2) if passes == expected_passes: self._pass("PASS: All tests passes", print_pass) From 391261b46984094803f5c9feb1be6c8e09a41775 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 30 Jul 2020 15:36:32 -0700 Subject: [PATCH 041/134] Added check to prevent existing endps from interfering in test --- py-scripts/test_ipv4_l4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index 35af1e9d..aa43a114 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -78,7 +78,7 @@ class IPV4L4(LFCliBase): if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'bytes-rd': + if item in self.cx_profile.created_cx.keys() and value_name == 'bytes-rd': cx_map[item] = value_rx return cx_map From dd16ab307a55886028a366bf2c022c5d322f626a Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 16:34:07 -0700 Subject: [PATCH 042/134] realm.py: adds wait_until_ports_appear stateful facade method --- py-json/realm.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/py-json/realm.py b/py-json/realm.py index 102f2d26..f58110ef 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -117,6 +117,14 @@ class Realm(LFCliBase): self.freq_to_chan[4970] = 194 self.freq_to_chan[4980] = 196 + def wait_until_ports_appear(self, resource_=1, sta_list=None, debug_=False): + if (sta_list is None) or (len(sta_list) < 1): + print("realm.wait_until_ports_appear: no stations provided") + return + LFUtils.wait_until_ports_appear(resource_id=resource_, + base_url=self.lfclient_url, + port_list=sta_list, + debug=debug_) def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] @@ -579,6 +587,9 @@ class L3CXProfile(LFCliBase): side_b_name = "%s%s" % (self.name_prefix, side_b_info[2]) for port_name in side_a: + if port_name.find('.') < 0: + port_name = "%d.%s"(side_a_info[1], port_name) + side_a_info = self.local_realm.name_to_eid(port_name) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] From a1d57e30a789af1b82f6b3a84760555016f59eb7 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 30 Jul 2020 16:34:57 -0700 Subject: [PATCH 043/134] tip_station_powersave.py: WIP: can now create stations, monitor and connections without error Requires GUI fixes made 2020-07-30 --- py-scripts/tip_station_powersave.py | 85 +++++++++++++++++++---------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 03acce5d..97ed32a6 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -65,11 +65,11 @@ class TIPStationPowersave(LFCliBase): halt_on_error_=self.exit_on_error) # background traffic - self.cx_background = self.local_realm.new_l3_cx_profile() - self.cx_background.side_a_min_bps = side_a_min_rate_ - self.cx_background.side_b_min_bps = side_a_min_rate_ - self.cx_background.side_a_max_bps = side_a_max_rate_ - self.cx_background.side_b_max_bps = side_a_min_rate_ + self.cx_prof_bg = self.local_realm.new_l3_cx_profile() + self.cx_prof_bg.side_a_min_bps = side_a_min_rate_ + self.cx_prof_bg.side_b_min_bps = side_a_min_rate_ + self.cx_prof_bg.side_a_max_bps = side_a_max_rate_ + self.cx_prof_bg.side_b_max_bps = side_a_min_rate_ #upload self.cx_prof_upload = self.local_realm.new_l3_cx_profile() @@ -96,13 +96,22 @@ class TIPStationPowersave(LFCliBase): self.cx_prof_download.side_b_max_pdu = 0 self.test_duration = traffic_duration_ + if isinstance(self.test_duration, int): + self.test_duration = "%s"%traffic_duration_ + if isinstance(self.test_duration, str): + self.test_duration = self.local_realm.parse_time(self.test_duration) + self.pause_duration = pause_duration_ + if isinstance(self.pause_duration, int): + self.pause_duration = "%s"%pause_duration_ + if isinstance(self.pause_duration, str): + self.pause_duration = self.local_realm.parse_time(self.pause_duration) + self.sta_powersave_enabled_profile = self.local_realm.new_station_profile() self.sta_powersave_disabled_profile = self.local_realm.new_station_profile() self.wifi_monitor_profile = self.local_realm.new_wifi_monitor_profile() - def build(self): self.sta_powersave_disabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) self.sta_powersave_disabled_profile.set_command_flag("add_sta", "create_admin_down", 1) @@ -115,6 +124,7 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_enabled_profile.set_command_flag("set_port", "rpt_timer", 1) self.sta_powersave_enabled_profile.set_command_flag("add_sta", "power_save_enable", 1) + self.wifi_monitor_profile.create(resource_=self.resource, channel=self.channel, radio_=self.monitor_radio, @@ -130,42 +140,60 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_disabled_profile.create(resource=1, radio=self.normal_sta_radio, sta_names_=self.normal_sta_list, - debug=self.debug) + debug=self.debug, + suppress_related_commands_=True) self.sta_powersave_enabled_profile.create(resource=1, radio=self.powersave_sta_radio, sta_names_=self.powersave_sta_list, - debug=self.debug) + debug=self.debug, + suppress_related_commands_=True) + temp_sta_map = {} - for name in list(self.local_realm.station_list()): + for name in self.powersave_sta_list + self.normal_sta_list: if (name in self.sta_powersave_disabled_profile.station_names) \ or (name in self.sta_powersave_enabled_profile.station_names): temp_sta_map[name]=1 + print("Stations we want:") + pprint.pprint(temp_sta_map) + self.local_realm.wait_until_ports_appear(self.resource, temp_sta_map.keys()) + if len(temp_sta_map) == (len(self.sta_powersave_disabled_profile.station_names) + len(self.sta_powersave_enabled_profile.station_names)): - self._pass("Stations created") + self._pass("Stations created", print_=True) else: - self._fail("Not all stations created") + print("Stations we see created:") + pprint.pprint(temp_sta_map) + self._fail("Not all stations created", print_=True) + + bg_side_a_eids = [] + for port in self.normal_sta_list: + bg_side_a_eids.append( "%s.%s"%(self.resource, port)) + + ul_side_a_eids = [] + for port in self.normal_sta_list: + ul_side_a_eids.append( "%s.%s"%(self.resource, port)) + + dl_side_a_eids = [] + for port in self.normal_sta_list: + dl_side_a_eids.append( "%s.%s"%(self.resource, port)) print("Creating background cx profile ") - self.cx_background.name_prefix="udp_bg" - self.cx_background.create(endp_type="lf_udp", - side_a=self.normal_sta_list, - side_b="1.eth1", - sleep_time=.05) + self.cx_prof_bg.name_prefix= "udp_bg" + self.cx_prof_bg.create(endp_type="lf_udp", + side_a=bg_side_a_eids, + side_b="1.eth1") print("Creating upload cx profile ") self.cx_prof_upload.name_prefix = "udp_up" self.cx_prof_upload.create(endp_type="lf_udp", - side_a=self.powersave_sta_list, - side_b="1.eth1", - sleep_time=.05) + side_a=ul_side_a_eids, + side_b="1.eth1") print("Creating download cx profile") self.cx_prof_download.name_prefix = "udp_down" self.cx_prof_download.create(endp_type="lf_udp", - side_a=self.powersave_sta_list, - side_b="1.eth1", - sleep_time=.05) + side_a=ul_side_a_eids, + side_b="1.eth1") def __get_rx_values(self): cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False) @@ -207,17 +235,18 @@ class TIPStationPowersave(LFCliBase): LFUtils.waitUntilPortsAdminUp(resource_id=self.resource, base_url=self.local_realm.lfclient_url, port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) - self.cx_prof_background.start_cx() + self.cx_prof_bg.start_cx() print("Upload starts at: %d"%time.time()) self.cx_prof_upload.start_cx() - time.sleep(float(self.test_duration)) + + time.sleep(self.test_duration.total_seconds()) self.cx_prof_upload.stop_cx() print("Upload ends at: %d"%time.time()) - time.sleep(float(self.pause_duration)) + time.sleep(float(self.pause_duration.total_seconds())) # here is where we should sleep long enough for station to go to sleep print("Download begins at: %d"%time.time()) self.cx_prof_download.start_cx() - time.sleep(float(self.test_duration)) + time.sleep(float(self.test_duration.total_seconds())) self.cx_prof_download.stop_cx() @@ -226,8 +255,8 @@ class TIPStationPowersave(LFCliBase): self.wifi_monitor_profile.admin_down() self.cx_prof_download.stop_cx() self.cx_prof_upload.stop_cx() - self.sta_powersave_enabled_profile.admin_down() - self.sta_powersave_disabled_profile.admin_down() + self.sta_powersave_enabled_profile.admin_down(self.resource) + self.sta_powersave_disabled_profile.admin_down(self.resource) def cleanup(self): self.wifi_monitor_profile.cleanup(resource_=self.resource, desired_ports=[self.monitor_name]) From 860a6d5cfd739fc184bde75757eb70dac6e7236d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 27 Jul 2020 13:45:26 -0600 Subject: [PATCH 044/134] test_l3_longevity.py - adding multi cast --- py-json/realm.py | 225 +++++++++++++++++++++++++++++++- py-scripts/test_l3_longevity.py | 223 +++++++++++++++++++++++-------- 2 files changed, 396 insertions(+), 52 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f58110ef..f6a832da 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -448,6 +448,11 @@ class Realm(LFCliBase): def new_station_profile(self): station_prof = StationProfile(self.lfclient_url, local_realm=self, debug_=self.debug, up=False) return station_prof + # just here for now for initial coding, move later to correct spot + def new_multicast_profile(self): + multi_prof = MULTICASTProfile(self.lfclient_host, self.lfclient_port, \ + local_realm=self, debug_=self.debug, report_timer_=3000) + return multi_prof def new_wifi_monitor_profile(self, resource_=1, debug_=False, up_=False): wifi_mon_prof = WifiMonitor(self.lfclient_url, @@ -473,7 +478,225 @@ class Realm(LFCliBase): cx_prof = GenCXProfile(self.lfclient_host, self.lfclient_port,local_realm=self, debug_=self.debug) return cx_prof +class MULTICASTProfile(LFCliBase): + def __init__(self, lfclient_host, lfclient_port, local_realm, + side_a_min_bps=None, side_b_min_bps=None, + side_a_max_bps=0, side_b_max_bps=0, + side_a_min_pdu=-1, side_b_min_pdu=-1, + side_a_max_pdu=0, side_b_max_pdu=0, + report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): + """ + :param lfclient_host: + :param lfclient_port: + :param local_realm: + :param side_a_min_bps: + :param side_b_min_bps: + :param side_a_max_bps: + :param side_b_max_bps: + :param side_a_min_pdu: + :param side_b_min_pdu: + :param side_a_max_pdu: + :param side_b_max_pdu: + :param name_prefix: prefix string for connection + :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding + :param debug_: + """ + super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) + self.debug = debug_ + self.local_realm = local_realm + self.side_a_min_pdu = side_a_min_pdu + self.side_b_min_pdu = side_b_min_pdu + self.side_a_max_pdu = side_a_max_pdu + self.side_b_max_pdu = side_b_max_pdu + self.side_a_min_bps = side_a_min_bps + self.side_b_min_bps = side_b_min_bps + self.side_a_max_bps = side_a_max_bps + self.side_b_max_bps = side_b_max_bps + self.report_timer = report_timer_ + self.created_mc = {} + self.name_prefix = name_prefix_ + self.number_template = number_template_ + + def get_mc_names(self): + return self.created_mc.keys() + + def refresh_mc(self): + pass + + def start_mc_tx(self, side_b, suppress_related_commands=None, debug_ = False ): + if self.debug: + debut_=True + + print("starting mc_tx") + # hard code for now + endp_name = 'mcast-xmit-sta' + + #start the trasmitter probably should be in start + json_data = { + "endp_name":endp_name, + } + + url = "cli-json/start_endp" + self.local_realm.json_post(url, json_data) + + + def start_mc_rx(self,side_a, suppress_related_commands=None, debug_ = False): + if self.debug: + debug_=True + + for port_name in side_a: + side_a_info = self.local_realm.name_to_eid(port_name) + side_a_resource = side_a_info[2] + side_a_name = "%s%s"%(self.name_prefix, side_a_info[2]) + + json_data = { + "endp_name":side_a_resource + } + url = "cli-json/start_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + pass + + def stop_mc(self): + pass + + def cleanup(self): + pass + + def create_mc_tx(self, side_b, suppress_related_commands=None, debug_ = False ): + if self.debug: + debug_=True + + json_data = [] + + # need to eventually us this + #mc_tx_name = "%s%s" % (self.name_prefix, side_b) + + # hard code for now + endp_name = 'mcast-xmit-sta' + # add end point + #add_endp mcast-xmit-sta 1 1 eth1 mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 + json_data = { + 'alias':endp_name, + 'shelf':1, + 'resource':1, + 'port':side_b, + 'type':'mc_udp', + 'ip_port':-1, + 'is_rate_bursty': + 'NO','min_rate':4000000, + 'max_rate':0, + 'is_pkt_sz_random':'NO', + 'min_pkt':1472, + 'max_pkt':0, + 'payload_pattern':'INCREASING', + 'use_checksum':'NO', + 'ttl':32, + 'send_bad_crc_per_million':0, + 'multi_conn':0 + } + + + url = "/cli-json/add_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + + #set_endp_addr mcast-xmit-sta '0c c4 7a e1 ff b1 ' AUTO 0 0 + json_data = { + 'name':endp_name, + "mac":"xx:xx:xx:xx:*:xx", #'mac':'0c:c4:7a:e1:ff:b1' + 'ip':'AUTO', + 'min_port':0, + 'max_port':0 + } + + url = "cli-json/set_endp_addr" + #self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical + json_data = { + 'name':endp_name, + 'ttl':32,'mcast_group':'224.9.9.9', + 'mcast_dest_port':9999, + 'rcv_mcast':'No' + } + + url = "cli-json/set_mc_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + + + + def create_mc_rx(self,side_a, suppress_related_commands=None, debug_ = False): + if self.debug: + debug_=True + + for port_name in side_a: + side_a_info = self.local_realm.name_to_eid(port_name) + side_a_shelf = side_a_info[1] + side_a_resource = side_a_info[2] + side_a_name = "%s%s"%(self.name_prefix, side_a_info[2]) + # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 + json_data = { + 'alias':side_a_resource, + 'shelf':side_a_shelf, + 'resource':1, + 'port':side_a_resource, + 'type':'mc_udp', + 'ip_port':9999, + 'is_rate_bursty': + 'NO','min_rate':0, + 'max_rate':0, + 'is_pkt_sz_random':'NO', + 'min_pkt':1472, + 'max_pkt':0, + 'payload_pattern':'INCREASING', + 'use_checksum':'NO', + 'ttl':32, + 'send_bad_crc_per_million':0, + 'multi_conn':0 + } + + url = "cli-json/add_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + #set_endp_addr mcast-rcv-sta-001 '00 0e 8e 5b 9d 44 ' AUTO 9999 0 + #json_data = { + # 'name':side_a_resource, + # 'mac':'xx:xx:xx:xx:*:xx', + # 'ip':'AUTO', + # 'min_port':9999, + # 'max_port':0 + # } + # + #url = "cli-json/set_endp_addr" + #self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + # set_mc_endp mcast-rcv-sta-001 32 224.9.9.9 9999 Yes + json_data = { + 'name':side_a_resource, + 'ttl':32, + 'mcast_group':'224.9.9.9', + 'mcast_dest_port':9999, + 'rcv_mcast':'Yes' + } + url = "cli-json/set_mc_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + '''json_data = { + "endp_name":side_a_resource + } + url = "cli-json/start_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + ''' + + def to_string(self): + pprint.pprint(self) + + + class L3CXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, side_a_min_bps=None, side_b_min_bps=None, @@ -1397,7 +1620,7 @@ class StationProfile: time.sleep(2) set_port_r.addPostData(self.set_port_data) json_response = set_port_r.jsonPost(debug) - time.sleep(.03) + time.sleep(0.03) LFUtils.waitUntilPortsAppear(resource, self.lfclient_url, self.station_names) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index b25b4b8d..fea2c218 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -17,19 +17,38 @@ import realm import time import datetime +#The valid ways to have multiple TX would be if they were on different ports. +# I don't think that we need to add that complexity for now. + +#In fact, it occurs to me that a multicast TX profile might actually already +# know the right amount of information from which to generate it's RX endpoints + +#So if we create a TX endpoint, it has a multicast ip and port. +# Those two pieces of information are also useful for creating RXes. +# I suggest one profile class. + + +#multicast_profile.createTx(port) and multicast_profile.createRX(port_list) + +#the ports have no knowledge of the protocols they will interact with, +#the ports are layer-1 devices with some layer2 and layer3 features (mac addresses, IP addresses) +#so anything you can legally assign an IP to can take a Layer3 connection or better + + class L3VariableTimeLongevity(LFCliBase): - def __init__(self, host, port, endp_type, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + def __init__(self, host, port, endp_type, is_multicast, side_b, radios, radio_name_list, number_of_stations_per_radio_list, ssid_list, ssid_password_list, security, station_lists, name_prefix, resource=1, - side_a_min_rate=56, side_a_max_rate=0, - side_b_min_rate=56, side_b_max_rate=0, + side_a_min_rate=56000, side_a_max_rate=0, + side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", - _debug_on=False, + _debug_on=True, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.endp_type = endp_type + self.is_multicast = is_multicast self.side_b = side_b self.ssid_list = ssid_list self.ssid_password_list = ssid_password_list @@ -45,8 +64,9 @@ class L3VariableTimeLongevity(LFCliBase): self.number_of_stations_per_radio_list = number_of_stations_per_radio_list self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) self.cx_profile = self.local_realm.new_l3_cx_profile() + self.multicast_profile = self.local_realm.new_multicast_profile() self.station_profiles = [] - + index = 0 for radio in radios: self.station_profile = self.local_realm.new_station_profile() @@ -59,13 +79,25 @@ class L3VariableTimeLongevity(LFCliBase): self.station_profiles.append(self.station_profile) index += 1 - self.cx_profile.host = self.host - self.cx_profile.port = self.port - self.cx_profile.name_prefix = self.name_prefix - self.cx_profile.side_a_min_bps = side_a_min_rate - self.cx_profile.side_a_max_bps = side_a_max_rate - self.cx_profile.side_b_min_bps = side_b_min_rate - self.cx_profile.side_b_max_bps = side_b_max_rate + if is_multicast: + self.multicast_profile.host = self.host + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = 0 + self.cx_profile.side_a_max_bps = 0 + self.cx_profile.side_b_min_bps = side_b_min_rate + self.cx_profile.side_b_max_bps = side_b_max_rate + + + else: + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = side_a_min_rate + self.cx_profile.side_a_max_bps = side_a_max_rate + self.cx_profile.side_b_min_bps = side_b_min_rate + self.cx_profile.side_b_max_bps = side_b_max_rate def __get_rx_values(self): cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) @@ -86,6 +118,8 @@ class L3VariableTimeLongevity(LFCliBase): expected_passes += 1 if new_list[item] > old_list[item]: passes += 1 + print(item, new_list[item], old_list[item], passes, expected_passes) + if passes == expected_passes: return True else: @@ -106,10 +140,36 @@ class L3VariableTimeLongevity(LFCliBase): temp_stations_list.append(self.side_b) self.local_realm.wait_for_ip(self.resource, temp_station_list) + + temp_station_list = [] + if self.is_multicast: + for station_list in self.station_lists: + for station in range(len(station_list)): + temp_station_list.append(str(self.resource) + "." + station_list[station]) + + # start recievers + self.multicast_profile.start_mc_rx(side_a=temp_station_list) + + # right now the multicast is hard coded, need to pass in station + self.multicast_profile.start_mc_tx(side_b=self.side_b) + + else: + self.cx_profile.start_cx() + cur_time = datetime.datetime.now() - old_cx_rx_values = self.__get_rx_values() + old_rx_values = self.__get_rx_values() + filtered_old_rx_values = [] + if self.is_multicast: + for rx_value in old_rx_values: + for station in self.station_lists: + if rx_value in station: + filtered_old_rx_values += rx_value + else: + filtered_old_rx_values = old_rx_values + + end_time = self.local_realm.parse_time(self.test_duration) + cur_time - self.cx_profile.start_cx() + passes = 0 expected_passes = 0 while cur_time < end_time: @@ -117,15 +177,24 @@ class L3VariableTimeLongevity(LFCliBase): while cur_time < interval_time: cur_time = datetime.datetime.now() time.sleep(1) + + new_rx_values = self.__get_rx_values() + filtered_new_rx_values = [] + if self.is_multicast: + for rx_value in new_rx_values: + for station in self.station_lists: + if rx_value in station: + filtered_new_rx_values += rx_value + else: + filtered_new_rx_values = new_rx_values - new_cx_rx_values = self.__get_rx_values() expected_passes += 1 - if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): + if self.__compare_vals(filtered_old_rx_values, filtered_new_rx_values): passes += 1 else: self._fail("FAIL: Not all stations increased traffic", print_fail) break - old_cx_rx_values = new_cx_rx_values + old_rx_values = new_rx_values cur_time = datetime.datetime.now() if passes == expected_passes: @@ -136,17 +205,52 @@ class L3VariableTimeLongevity(LFCliBase): for station_list in self.station_lists: for station_name in station_list: data = LFUtils.portDownRequest(1, station_name) - url = "json-cli/set_port" + url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, resource): resource = 1 - remove_all_endpoints = True - self.local_realm.remove_all_cxs(remove_all_endpoints) - self.local_realm.remove_all_stations(resource) + data = { + "name":"BLANK", + "action":"overwrite" + } + url = "cli-json/load" + self.json_post(url, data) + #remove_all_endpoints = True + #self.local_realm.remove_all_cxs(remove_all_endpoints) + #self.local_realm.remove_all_stations(resource) + def build(self): + # refactor in LFUtils.port_zero_request() resource = 1 + data ={ + 'shelf':1, + 'resource':1, + 'port':'eth1', + 'ip_addr':'0.0.0.0', + 'netmask':'0.0.0.0', + 'gateway':'0.0.0.0', + 'current_flags':0, + 'interest':402653212 + } + + url = "cli-json/set_port" + self.json_post(url, data) + + # refactor into LFUtils + data ={ + "shelf":1, + "resource": resource, + "port":"br0", + "network_devs":"eth1", + "br_flags":1 + } + url = "cli-json/add_br" + self.json_post(url, data) + + #refactor later + try: data = LFUtils.port_dhcp_up_request(resource, self.side_b) self.json_post("/cli-json/set_port", data) @@ -154,32 +258,38 @@ class L3VariableTimeLongevity(LFCliBase): print("LFUtils.port_dhcp_up_request didn't complete ") print("or the json_post failed either way {} did not set up dhcp so test may no pass ".format(self.side_b)) + #exit(1) + resource = 1 index = 0 for station_profile in self.station_profiles: station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) station_profile.set_number_template(station_profile.number_template) print("Creating stations") - station_profile.set_command_flag("add_sta", "create_admin_down", 1) - station_profile.set_command_param("set_port", "report_timer", 1500) - station_profile.set_command_flag("set_port", "rpt_timer", 1) + #station_profile.set_command_flag("add_sta", "create_admin_down", 1) + #station_profile.set_command_param("set_port", "report_timer", 1500) + #station_profile.set_command_flag("set_port", "rpt_timer", 1) temp_station_list = [] index = 0 for station_list in self.station_lists: for station in range(len(station_list)): temp_station_list.append(str(self.resource) + "." + station_list[station]) - station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=False ) + station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=True ) index += 1 - self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) + if self.is_multicast: + self.multicast_profile.create_mc_tx(self.side_b) + self.multicast_profile.create_mc_rx(side_a=temp_station_list) + else: + self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) self._pass("PASS: Stations build finished") def valid_endp_type(endp_type): - valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6'] + valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] if str(endp_type) in valid_endp_type: return endp_type else: - print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6') + print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6') exit(1) def main(): @@ -200,33 +310,38 @@ def main(): ''', description='''\ - test_l3_longevity.py: - -------------------- - Basic Idea: create stations, create traffic between upstream port and stations, run traffic. - The traffic on the stations will be checked once per minute to verify that traffic is transmitted - and recieved. +test_l3_longevity.py: +-------------------- +Basic Idea: create stations, create traffic between upstream port and stations, run traffic. + The traffic on the stations will be checked once per minute to verify that traffic is transmitted + and recieved. - Test will exit on failure of not recieving traffice for one minute on any station. + Test will exit on failure of not recieving traffice for one minute on any station. - Scripts are executed from: ./lanforge/py-scripts + Scripts are executed from: ./lanforge/py-scripts - Generic command layout: - python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio + Stations start counting form zero, thus stations count from zero - number of las - Note: multiple --radio switches may be entered up to the number of radios available: - --radio --radio +Generic command layout: +python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio - : number followed by one of the following - d - days - h - hours - m - minutes - s - seconds +Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio - : - lf_udp : IPv4 UDP traffic - lf_tcp : IPv4 TCP traffic - lf_udp6 : IPv6 UDP traffic - lf_tcp6 : IPv6 TCP traffic +: number followed by one of the following + d - days + h - hours + m - minutes + s - seconds + +: + lf_udp : IPv4 UDP traffic + lf_tcp : IPv4 TCP traffic + lf_udp6 : IPv6 UDP traffic + lf_tcp6 : IPv6 TCP traffic + + mc_udp : IPv4 multi cast UDP traffic + mc_udp6 : IPv6 multi cast UDP traffic Example: 1. Test duration 4 minutes @@ -247,8 +362,8 @@ def main(): parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') requiredNamed = parser.add_argument_group('required arguments') - requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('', '','',''), - help ='--radio ',required=True) + requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('', '','',''), + help ='--radio ',required=True) args = parser.parse_args() if args.test_duration: @@ -263,6 +378,8 @@ def main(): if args.radio: radios = args.radio + is_multicast = False + radio_offset = 0 number_of_stations_offset = 1 ssid_offset = 2 @@ -275,6 +392,9 @@ def main(): ssid_list = [] ssid_password_list = [] + if endp_type in ['mc_udp','mc_udp6']: + is_multicast = True + index = 0 for radio in radios: radio_name = radio[radio_offset] @@ -303,6 +423,7 @@ def main(): station_lists= station_lists, name_prefix="var_time", endp_type=endp_type, + is_multicast=is_multicast, side_b=side_b, radios=radios, radio_name_list=radio_name_list, From a5c181bbc91ec149fef36ef3e3bad47c3a79fb0e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 09:20:32 -0700 Subject: [PATCH 045/134] Realm: wifi_monitor: start_sniff gains parameter duration_sec --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f6a832da..0bd5e6b8 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1296,7 +1296,7 @@ class WifiMonitor: down_request = LFUtils.portDownRequest(resource_id=self.resource, port_name=self.monitor_name) self.local_realm.json_post("/cli-json/set_port", down_request) - def start_sniff(self, capname=None): + def start_sniff(self, capname=None, duration_sec=60): if capname is None: raise ValueError("Need a capture file name") data = { @@ -1306,7 +1306,7 @@ class WifiMonitor: "display": "NA", "flags": 0x2, "outfile": capname, - "duration": 45 + "duration": duration_sec } self.local_realm.json_post("/cli-json/sniff_port", _data= data) From 7fa76d45172bf3abc4b957c3f3d5bd71aff38d81 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 09:21:16 -0700 Subject: [PATCH 046/134] LFUtils: new snake_case method for wait_until_ports_admin_up() --- py-json/LANforge/LFUtils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 9ed349f5..bcfbb037 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -312,6 +312,9 @@ def waitUntilPortsAdminDown(resource_id=1, base_url="http://localhost:8080", por def waitUntilPortsAdminUp(resource_id=1, base_url="http://localhost:8080", port_list=()): + return wait_until_ports_admin_up(resource_id=resource_id, base_url=base_url, port_list=port_list) + +def wait_until_ports_admin_up(resource_id=1, base_url="http://localhost:8080", port_list=()): print("Waiting until ports appear admin-up...") down_stations = port_list.copy() sleep(1) From afa76898fdc751b0f297afc4301febc841e2ad40 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 09:21:45 -0700 Subject: [PATCH 047/134] tip_station_powersave.py: computes more appropriate sniff duration --- py-scripts/tip_station_powersave.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 97ed32a6..a45267cb 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -226,7 +226,9 @@ class TIPStationPowersave(LFCliBase): date_time = now.strftime("%Y-%m-%d-%H%M%S") curr_mon_name = self.wifi_monitor_profile.monitor_name pcap_file = "/home/lanforge/Documents/%s-%s.pcap"%(curr_mon_name, date_time) - self.wifi_monitor_profile.start_sniff(pcap_file) + + capture_duration = 2 * ( self.test_duration.total_seconds() + self.pause_duration.total_seconds() + 4) + self.wifi_monitor_profile.start_sniff(pcap_file, capture_duration) time.sleep(0.05) self.sta_powersave_disabled_profile.admin_up(resource=1) From 127a5fd55b2c5b309ff9eb5bfe0d359d46b20da2 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 09:37:51 -0700 Subject: [PATCH 048/134] realm.py: adds some defaults and gaurds to wait_for_ip() --- py-json/realm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 0bd5e6b8..a9e91b05 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -313,10 +313,12 @@ class Realm(LFCliBase): return info return [1, int(info[0]), info[1]] - def wait_for_ip(self, resource, station_list, ipv6=False): + def wait_for_ip(self, resource=1, station_list=None, ipv6=False): num_ports = 0 num_ips = 0 print("Waiting for ips...") + if (station_list is None) or (len(station_list) < 1): + raise ValueError("wait_for_ip: expects non-empty list of ports") response = super().json_get("/port/1/%s/%s?fields=alias,ip,port+type" % (resource, ",".join(station_list))) if (response is None) or ("interfaces" not in response): print("station_list: incomplete response:") From 80b783560ba4859ebfc2721aaea8c7c3491f235a Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 09:38:45 -0700 Subject: [PATCH 049/134] tip_station_powersave.py: waits for getting IPs, fixes SSID --- py-scripts/tip_station_powersave.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index a45267cb..1c95b0c2 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -234,9 +234,11 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_disabled_profile.admin_up(resource=1) self.sta_powersave_enabled_profile.admin_up(resource=1) - LFUtils.waitUntilPortsAdminUp(resource_id=self.resource, - base_url=self.local_realm.lfclient_url, - port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + LFUtils.wait_until_ports_admin_up(resource_id=self.resource, + base_url=self.local_realm.lfclient_url, + port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + self.local_realm.wait_for_ip(resource=self.resource, + station_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) self.cx_prof_bg.start_cx() print("Upload starts at: %d"%time.time()) self.cx_prof_upload.start_cx() @@ -274,7 +276,8 @@ def main(): normal_station_list = ["sta1000" ] powersave_station_list = ["sta0001"] #,"sta0002","sta0003","sta0004"] ip_powersave_test = TIPStationPowersave(lfjson_host, lfjson_port, - ssid="jedway-open", + ssid="jedway-open-x2048-5-1", + password="[BLANK]", channel_=157, normal_station_list_=normal_station_list, normal_station_radio_="wiphy0", From 976cb5505ed7ba3f54dfcb662a6826a89e91530d Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 10:30:44 -0700 Subject: [PATCH 050/134] Added check with wait_for_ips that will stop the test if a timeout occurs --- py-scripts/test_generic.py | 6 +++++- py-scripts/test_ipv4_l4.py | 6 +++++- py-scripts/test_ipv4_l4_urls_per_ten.py | 10 +++++++--- py-scripts/test_ipv4_variable_time.py | 6 +++++- py-scripts/test_ipv6_variable_time.py | 6 +++++- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 45d86c1f..06fc550a 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -55,7 +55,11 @@ class GenTest(LFCliBase): self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") - self.local_realm.wait_for_ip(self.resource, temp_stas) + if self.local_realm.wait_for_ip(self.resource, temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) cur_time = datetime.datetime.now() passes = 0 expected_passes = 0 diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index aa43a114..d3b55e13 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -101,7 +101,11 @@ class IPV4L4(LFCliBase): def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() temp_stas.append("eth1") - self.local_realm.wait_for_ip(self.resource, temp_stas) + if self.local_realm.wait_for_ip(self.resource, temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) cur_time = datetime.datetime.now() old_rx_values = self.__get_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index f80fbd45..f255d2bd 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -86,11 +86,15 @@ class IPV4L4(LFCliBase): temp_stas = self.sta_list.copy() temp_stas.append("eth1") cur_time = datetime.datetime.now() - interval_time = cur_time + datetime.timedelta(minutes=2) + interval_time = cur_time + datetime.timedelta(minutes=10) passes = 0 expected_passes = 0 self.station_profile.admin_up(1) - self.local_realm.wait_for_ip(self.resource, temp_stas) + if self.local_realm.wait_for_ip(self.resource, temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) self.cx_profile.start_cx() print("Starting test") for test in range(self.num_tests): @@ -108,7 +112,7 @@ class IPV4L4(LFCliBase): else: self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) break - interval_time = cur_time + datetime.timedelta(minutes=2) + interval_time = cur_time + datetime.timedelta(minutes=10) if passes == expected_passes: self._pass("PASS: All tests passes", print_pass) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index a193f66e..90acad72 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -92,7 +92,11 @@ class IPV4VariableTime(LFCliBase): self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") - self.local_realm.wait_for_ip(self.resource, temp_stas) + if self.local_realm.wait_for_ip(self.resource, temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) cur_time = datetime.datetime.now() old_cx_rx_values = self.__get_rx_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time diff --git a/py-scripts/test_ipv6_variable_time.py b/py-scripts/test_ipv6_variable_time.py index 9e8540a7..ae33c935 100755 --- a/py-scripts/test_ipv6_variable_time.py +++ b/py-scripts/test_ipv6_variable_time.py @@ -93,7 +93,11 @@ class IPV6VariableTime(LFCliBase): self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") - self.local_realm.wait_for_ip(self.resource, temp_stas, ipv6=True) + if self.local_realm.wait_for_ip(self.resource, temp_stas, ipv6=True): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail, ipv6=True) + exit(1) cur_time = datetime.datetime.now() old_cx_rx_values = self.__get_rx_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time From d1689366b80bb56591c3be55cb2109abcd5f01f4 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 10:31:29 -0700 Subject: [PATCH 051/134] Added timeout and boolean return to wait_for_ip, Added start of VAPProfile WIP --- py-json/realm.py | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a9e91b05..26a8a16e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -313,7 +313,7 @@ class Realm(LFCliBase): return info return [1, int(info[0]), info[1]] - def wait_for_ip(self, resource=1, station_list=None, ipv6=False): + def wait_for_ip(self, resource=1, station_list=None, ipv6=False, timeout_sec=60): num_ports = 0 num_ips = 0 print("Waiting for ips...") @@ -333,7 +333,7 @@ class Realm(LFCliBase): if ipv6: num_ports -= 1 # Prevents eth0 from being counted, preventing infinite loop - while num_ips != num_ports: + while num_ips != num_ports and timeout_sec != 0: num_ips = 0 response = super().json_get("/port/1/%s/%s?fields=alias,ip,port+type,ipv6+address" % (resource, ",".join(station_list))) @@ -349,6 +349,7 @@ class Realm(LFCliBase): if v['ip'] != '0.0.0.0': num_ips += 1 time.sleep(1) + timeout_sec -= 1 if ipv6: for x in range(len(response['interfaces'])): for k, v in response['interfaces'][x].items(): @@ -358,6 +359,11 @@ class Realm(LFCliBase): and v['ipv6 address'] != 'AUTO': num_ips += 1 time.sleep(1) + timeout_sec -= 1 + if num_ips == num_ports: + return True + else: + return False def parse_time(self, time_string): if isinstance(time_string, str): @@ -813,7 +819,7 @@ class L3CXProfile(LFCliBase): for port_name in side_a: if port_name.find('.') < 0: - port_name = "%d.%s"(side_a_info[1], port_name) + port_name = "%d.%s" % (side_a_info[1], port_name) side_a_info = self.local_realm.name_to_eid(port_name) side_a_shelf = side_a_info[0] @@ -1311,11 +1317,43 @@ class WifiMonitor: "duration": duration_sec } self.local_realm.json_post("/cli-json/sniff_port", _data= data) - + # "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur)) +class VAPProfile: + def __init__(self, lfclient_url, local_realm, radio, ssid="NA", ssid_pass="NA", mode=0, debug_=False): + self.debug = debug_ + self.lfclient_url = lfclient_url + self.ssid = ssid + self.ssid_pass = ssid_pass + self.mode = mode + self.local_realm = local_realm + self.radio = radio + self.created_vaps = [] + def admin_up(self, resource): + set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portUpRequest(resource, None, debug_on=False) + for vap_name in self.created_vaps: + req_json["port"] = vap_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) + + def admin_down(self, resource): + set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portDownRequest(resource, None, debug_on=False) + for vap_name in self.created_vaps: + req_json["port"] = vap_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) + + def create(self): + pass + + # use the station profile to set the combination of features you want on your stations # once this combination is configured, build the stations with the build(resource, radio, number) call From b79aa43f595ad71fd82d9981c8011bb2bc31ca1a Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 14:13:27 -0700 Subject: [PATCH 052/134] Added port_down_request --- py-json/LANforge/LFUtils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index bcfbb037..534ed554 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -150,8 +150,10 @@ def port_up_request(resource_id, port_name, debug_on=False): debug_printer.pprint(data) return data - def portDownRequest(resource_id, port_name, debug_on=False): + return port_down_request(resource_id, port_name, debug_on) + +def port_down_request(resource_id, port_name, debug_on=False): """ Does not change the use_dhcp flag See http://localhost:8080/help/set_port From 01e574b2fc074244b5db22dd2288cc5cba6b3294 Mon Sep 17 00:00:00 2001 From: Dipti Dhond Date: Fri, 31 Jul 2020 16:07:55 -0700 Subject: [PATCH 053/134] baseline for WAN to LAN l3 traffic test - WIP --- py-scripts/test_l3_WAN_LAN.py | 131 ++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 py-scripts/test_l3_WAN_LAN.py diff --git a/py-scripts/test_l3_WAN_LAN.py b/py-scripts/test_l3_WAN_LAN.py new file mode 100644 index 00000000..7aca5a52 --- /dev/null +++ b/py-scripts/test_l3_WAN_LAN.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +import sys +import os + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils +import realm +import time +import datetime + +class L3LANtoWAN(LFCliBase): + def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.ssid = ssid + self.security = security + self.password = password + self.sta_list = sta_list + self.resource = resource + self.timeout = 120 + self.number_template = number_template + self.debug = _debug_on + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.password, + self.station_profile.security = self.security + self.station_profile.number_template_ = self.number_template + self.station_profile.mode = 0 + + def build(self): + # Build stations + #print("We've gotten into the build stations function") + self.station_profile.use_security(self.security, self.ssid, self.password) + self.station_profile.set_number_template(self.number_template) + print("Creating stations") + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self._pass("PASS: Station build finished") + + def start(self, sta_list, print_pass, print_fail): + self.station_profile.admin_up(1) + associated_map = {} + ip_map = {} + print("Starting test...") + for sec in range(self.timeout): + for sta_name in sta_list: + sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug) + # print(sta_status) + if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None: + continue + if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':': + # print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip']) + associated_map[sta_name] = 1 + if sta_status['interface']['ip'] != '0.0.0.0': + # print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip']) + ip_map[sta_name] = 1 + if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)): + break + else: + time.sleep(1) + + if self.debug: + print("sta_list", len(sta_list), sta_list) + print("ip_map", len(ip_map), ip_map) + print("associated_map", len(associated_map), associated_map) + if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)): + self._pass("PASS: All stations associated with IP", print_pass) + else: + self._fail("FAIL: Not all stations able to associate/get IP", print_fail) + print("sta_list", sta_list) + print("ip_map", ip_map) + print("associated_map", associated_map) + + return self.passes() + + def stop(self): + # Bring stations down + for sta_name in self.sta_list: + data = LFUtils.portDownRequest(1, sta_name) + url = "cli-json/set_port" + # print(sta_name) + self.json_post(url, data) + + def cleanup(self, sta_list): + self.station_profile.cleanup(self.resource, sta_list) + LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + debug=self.debug) + +def main(): + lfjson_host = "localhost" + lfjson_port = 8080 + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) + ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa3-44", password="jedway-wpa3-44", + security="wpa3", sta_list=station_list,_debug_on=False) + #print("created IPv4Test object") + ip_test.cleanup(station_list) + ip_test.timeout = 60 + ip_test.build() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + ip_test.start(station_list, False, False) + ip_test.stop() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + time.sleep(30) + ip_test.cleanup(station_list) + if ip_test.passes(): + print("Full test passed, all stations associated and got IP") + + +if __name__ == "__main__": + main() \ No newline at end of file From 2bccd46dbd0b1c95cea3418d4636481cdc38ec7f Mon Sep 17 00:00:00 2001 From: Dipti Dhond Date: Fri, 31 Jul 2020 16:24:15 -0700 Subject: [PATCH 054/134] changed SSID to jedway-open-1 --- py-scripts/sta_connect2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-scripts/sta_connect2.py b/py-scripts/sta_connect2.py index 13894295..92dc45da 100755 --- a/py-scripts/sta_connect2.py +++ b/py-scripts/sta_connect2.py @@ -30,9 +30,9 @@ WPA2="wpa2" MODE_AUTO=0 class StaConnect2(LFCliBase): - def __init__(self, host, port, _dut_ssid="MyAP", _dut_passwd="NA", _dut_bssid="", + def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="", _user="", _passwd="", _sta_mode="0", _radio="wiphy0", - _resource=1, _upstream_resource=1, _upstream_port="eth2", + _resource=1, _upstream_resource=1, _upstream_port="eth1", _sta_name=None, debug_=False, _dut_security=OPEN, _exit_on_error=False, _cleanup_on_exit=True, _runtime_sec=60, _exit_on_fail=False): # do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn) From 0da7e94581b7a0a6cadaf6c00e43a4fbadd9b827 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 16:31:27 -0700 Subject: [PATCH 055/134] VAPProfile now able to create vaps, added factory method to realm for VAPProfile --- py-json/realm.py | 273 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 252 insertions(+), 21 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 26a8a16e..1b00d4b7 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -8,6 +8,7 @@ from LANforge import LFUtils from LANforge import set_port from LANforge import add_sta from LANforge import lfcli_base +from LANforge import add_vap from LANforge.lfcli_base import LFCliBase from generic_cx import GenericCx from LANforge import add_monitor @@ -483,9 +484,13 @@ class Realm(LFCliBase): return cx_prof def new_generic_cx_profile(self): - cx_prof = GenCXProfile(self.lfclient_host, self.lfclient_port,local_realm=self, debug_=self.debug) + cx_prof = GenCXProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) return cx_prof + def new_vap_profile(self): + vap_prof = VAPProfile(lfclient_url=self.lfclient_url, local_realm=self, debug_=self.debug) + return vap_prof + class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, side_a_min_bps=None, side_b_min_bps=None, @@ -1321,39 +1326,267 @@ class WifiMonitor: # "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur)) -class VAPProfile: - def __init__(self, lfclient_url, local_realm, radio, ssid="NA", ssid_pass="NA", mode=0, debug_=False): +class VAPProfile(LFCliBase): + def __init__(self, lfclient_url, local_realm, vap_name="", ssid="NA", ssid_pass="NA", mode=0, use_ht160=False, debug_=False): self.debug = debug_ self.lfclient_url = lfclient_url self.ssid = ssid self.ssid_pass = ssid_pass self.mode = mode self.local_realm = local_realm - self.radio = radio - self.created_vaps = [] + self.vap_name = vap_name + self.use_ht160 = use_ht160 + self.COMMANDS = ["add_vap", "set_port"] + self.desired_add_vap_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] + self.desired_add_vap_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] + self.add_vap_data = { + "shelf": 1, + "resource": 1, + "radio": None, + "ap_name": None, + "flags": 0, + "flags_mask": 0, + "ssid": None, + "key": None, + "mac": "xx:xx:xx:xx:*:xx" + } + + self.desired_set_port_cmd_flags = [] + self.desired_set_port_current_flags = ["if_down"] + self.desired_set_port_interest_flags = ["current_flags", "ifdown"] + self.set_port_data = { + "shelf": 1, + "resource": 1, + "port": None, + "current_flags": 0, + "interest": 0, # (0x2 + 0x4000 + 0x800000) # current, dhcp, down + } + + if self.use_ht160: + self.desired_add_vap_flags.append("ht160_enable") + self.desired_add_vap_flags_mask.append("ht160_enable") def admin_up(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) req_json = LFUtils.portUpRequest(resource, None, debug_on=False) - for vap_name in self.created_vaps: - req_json["port"] = vap_name - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) + req_json["ap_name"] = self.vap_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) def admin_down(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portDownRequest(resource, None, debug_on=False) - for vap_name in self.created_vaps: - req_json["port"] = vap_name - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) + req_json = LFUtils.port_down_request(resource, None, debug_on=False) + req_json["ap_name"] = self.vap_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) - def create(self): - pass + def use_security(self, security_type, ssid=None, passwd=None): + types = {"wep": "wep_enable", "wpa": "wpa_enable", "wpa2": "wpa2_enable", "wpa3": "use-wpa3", "open": "[BLANK]"} + self.add_vap_data["ssid"] = ssid + if security_type in types.keys(): + if (ssid is None) or (ssid == ""): + raise ValueError("use_security: %s requires ssid" % security_type) + if (passwd is None) or (passwd == ""): + raise ValueError("use_security: %s requires passphrase or [BLANK]" % security_type) + for name in types.values(): + if name in self.desired_add_vap_flags and name in self.desired_add_vap_flags_mask: + self.desired_add_vap_flags.remove(name) + self.desired_add_vap_flags_mask.remove(name) + if security_type != "open": + self.desired_add_vap_flags.append(types[security_type]) + self.desired_add_vap_flags_mask.append(types[security_type]) + else: + passwd = "[BLANK]" + self.set_command_param("add_vap", "ssid", ssid) + self.set_command_param("add_vap", "key", passwd) + # unset any other security flag before setting our present flags + if security_type == "wpa3": + self.set_command_param("add_vap", "ieee80211w", 2) + + def set_command_flag(self, command_name, param_name, value): + # we have to check what the param name is + if (command_name is None) or (command_name == ""): + return + if (param_name is None) or (param_name == ""): + return + if command_name not in self.COMMANDS: + print("Command name name [%s] not defined in %s" % (command_name, self.COMMANDS)) + return + if command_name == "add_vap": + if (param_name not in add_vap.add_vap_flags): + print("Parameter name [%s] not defined in add_vap.py" % param_name) + if self.debug: + pprint(add_vap.add_vap_flags) + return + if (value == 1) and (param_name not in self.desired_add_vap_flags): + self.desired_add_vap_flags.append(param_name) + self.desired_add_vap_flags_mask.append(param_name) + elif value == 0: + self.desired_add_vap_flags.remove(param_name) + self.desired_add_vap_flags_mask.append(param_name) + + elif command_name == "set_port": + if (param_name not in set_port.set_port_current_flags) and (param_name not in set_port.set_port_cmd_flags) and (param_name not in set_port.set_port_interest_flags): + print("Parameter name [%s] not defined in set_port.py" % param_name) + if self.debug: + pprint(set_port.set_port_cmd_flags) + pprint(set_port.set_port_current_flags) + pprint(set_port.set_port_interest_flags) + return + if param_name in set_port.set_port_cmd_flags: + if (value == 1) and (param_name not in self.desired_set_port_cmd_flags): + self.desired_set_port_cmd_flags.append(param_name) + elif value == 0: + self.desired_set_port_cmd_flags.remove(param_name) + elif param_name in set_port.set_port_current_flags: + if (value == 1) and (param_name not in self.desired_set_port_current_flags): + self.desired_set_port_current_flags.append(param_name) + elif value == 0: + self.desired_set_port_current_flags.remove(param_name) + elif param_name in set_port.set_port_interest_flags: + if (value == 1) and (param_name not in self.desired_set_port_interest_flags): + self.desired_set_port_interest_flags.append(param_name) + elif value == 0: + self.desired_set_port_interest_flags.remove(param_name) + else: + raise ValueError("Unknown param name: " + param_name) + + def set_command_param(self, command_name, param_name, param_value): + # we have to check what the param name is + if (command_name is None) or (command_name == ""): + return + if (param_name is None) or (param_name == ""): + return + if command_name not in self.COMMANDS: + self.error("Command name name [%s] not defined in %s" % (command_name, self.COMMANDS)) + return + if command_name == "add_vap": + self.add_vap_data[param_name] = param_value + elif command_name == "set_port": + self.set_port_data[param_name] = param_value + + def add_named_flags(self, desired_list, command_ref): + if desired_list is None: + raise ValueError("addNamedFlags wants a list of desired flag names") + if len(desired_list) < 1: + print("addNamedFlags: empty desired list") + return 0 + if (command_ref is None) or (len(command_ref) < 1): + raise ValueError("addNamedFlags wants a maps of flag values") + + result = 0 + for name in desired_list: + if (name is None) or (name == ""): + continue + if name not in command_ref: + if self.debug: + pprint(command_ref) + raise ValueError("flag %s not in map" % name) + result += command_ref[name] + + return result + + def create(self, resource, radio, up_=None, debug=False, suppress_related_commands_=True): + if up_ is not None: + self.up = up_ + if self.up: + if "create_admin_down" in self.desired_add_vap_flags: + del self.desired_add_vap_flags[self.desired_add_vap_flags.index("create_admin_down")] + elif "create_admin_down" not in self.desired_add_vap_flags: + self.desired_add_vap_flags.append("create_admin_down") + + # create stations down, do set_port on them, then set stations up + self.add_vap_data["flags"] = self.add_named_flags(self.desired_add_vap_flags, add_vap.add_vap_flags) + self.add_vap_data["flags_mask"] = self.add_named_flags(self.desired_add_vap_flags_mask, add_vap.add_vap_flags) + self.add_vap_data["radio"] = radio + + self.add_vap_data["resource"] = resource + self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, + set_port.set_port_current_flags) + self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags, + set_port.set_port_interest_flags) + # these are unactivated LFRequest objects that we can modify and + # re-use inside a loop, reducing the number of object creations + add_vap_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_vap") + set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") + + if suppress_related_commands_: + self.add_vap_data["suppress_preexec_cli"] = "yes" + self.add_vap_data["suppress_preexec_method"] = 1 + self.set_port_data["suppress_preexec_cli"] = "yes" + self.set_port_data["suppress_preexec_method"] = 1 + + # pprint(self.station_names) + # exit(1) + self.set_port_data["port"] = self.vap_name + self.add_vap_data["ap_name"] = self.vap_name + add_vap_r.addPostData(self.add_vap_data) + if debug: + print("- 1502 - %s- - - - - - - - - - - - - - - - - - " % self.vap_name) + pprint(self.add_vap_data) + pprint(self.set_port_data) + pprint(add_vap_r) + print("- ~1502 - - - - - - - - - - - - - - - - - - - ") + + json_response = add_vap_r.jsonPost(debug) + # time.sleep(0.03) + time.sleep(2) + set_port_r.addPostData(self.set_port_data) + json_response = set_port_r.jsonPost(debug) + time.sleep(0.03) + + if (self.up): + self.admin_up(1) + + + def cleanup(self, resource, desired_ports=None, delay=0.03): + print("Cleaning up vaps") + req_url = "/cli-json/rm_vlan" + data = { + "shelf": 1, + "resource": resource, + "port": None + } + if (desired_ports is not None): + if len(desired_ports) < 1: + print("No stations requested for cleanup, returning.") + return + names = ','.join(desired_ports) + current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) + if current_stations is None: + return + if "interfaces" in current_stations: + for station in current_stations['interfaces']: + for eid, info in station.items(): + data["port"] = info["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + time.sleep(delay) + + if "interface" in current_stations: + data["port"] = current_stations["interface"]["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + + return + + names = ','.join(self.station_names) + current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) + if current_stations is None or current_stations['interfaces'] is None: + print("No stations to clean up") + return + + if "interfaces" in current_stations: + for station in current_stations['interfaces']: + for eid, info in station.items(): + data["port"] = info["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) + time.sleep(delay) + + if "interface" in current_stations: + data["port"] = current_stations["interface"]["alias"] + self.local_realm.json_post(req_url, data, debug_=self.debug) - # use the station profile to set the combination of features you want on your stations # once this combination is configured, build the stations with the build(resource, radio, number) call @@ -1408,8 +1641,6 @@ class StationProfile: "interest": 0, # (0x2 + 0x4000 + 0x800000) # current, dhcp, down, } - # TODO: create use_wpa3() - def use_security(self, security_type, ssid=None, passwd=None): types = {"wep": "wep_enable", "wpa": "wpa_enable", "wpa2": "wpa2_enable", "wpa3": "use-wpa3", "open": "[BLANK]"} self.add_sta_data["ssid"] = ssid From b52245228bf722fd4d5092b976b9875bcc922ca7 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 17:11:02 -0700 Subject: [PATCH 056/134] Added channel param for VAPProfile.create() --- py-json/realm.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 1b00d4b7..5de73650 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1488,7 +1488,28 @@ class VAPProfile(LFCliBase): return result - def create(self, resource, radio, up_=None, debug=False, suppress_related_commands_=True): + def create(self, resource, radio, channel=None, up_=None, debug=False, suppress_related_commands_=True): + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), debug_=self.debug) + if jr is None: + raise ValueError("No radio %s.%s found" % (resource, radio)) + + eid = "1.%s.%s" % (resource, radio) + frequency = 0 + country = 0 + if eid in jr: + country = jr[eid]["country"] + + data = { + "shelf": 1, + "resource": resource, + "radio": radio, + "mode": 0, #"NA", #0 for AUTO or "NA" + "channel": channel, + "country": country, + "frequency": self.local_realm.channel_freq(channel_=channel) + } + self.local_realm.json_post("/cli-json/set_wifi_radio", _data=data) + if up_ is not None: self.up = up_ if self.up: @@ -1540,7 +1561,6 @@ class VAPProfile(LFCliBase): if (self.up): self.admin_up(1) - def cleanup(self, resource, desired_ports=None, delay=0.03): print("Cleaning up vaps") req_url = "/cli-json/rm_vlan" From a2f19f9db00facf3af8c66ab56c3469a60268aa7 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 17:19:13 -0700 Subject: [PATCH 057/134] Fixed some bugs in VAPProfile admin_up and admin_down --- py-json/realm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 5de73650..240a4146 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1368,16 +1368,16 @@ class VAPProfile(LFCliBase): def admin_up(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portUpRequest(resource, None, debug_on=False) - req_json["ap_name"] = self.vap_name + req_json = LFUtils.portUpRequest(resource, None, debug_on=self.debug) + req_json["port"] = self.vap_name set_port_r.addPostData(req_json) json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) def admin_down(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.port_down_request(resource, None, debug_on=False) - req_json["ap_name"] = self.vap_name + req_json = LFUtils.port_down_request(resource, None, debug_on=self.debug) + req_json["port"] = self.vap_name set_port_r.addPostData(req_json) json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) From 73573a28da3eaa41ae7890e24f241ff7d52719f3 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 31 Jul 2020 17:27:42 -0700 Subject: [PATCH 058/134] Fixed typo in hostapd_config --- py-json/LANforge/add_vap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/LANforge/add_vap.py b/py-json/LANforge/add_vap.py index 7a0beed3..8797b1ac 100644 --- a/py-json/LANforge/add_vap.py +++ b/py-json/LANforge/add_vap.py @@ -1,6 +1,6 @@ add_vap_flags = { "enable_wpa" : 0x10, # Enable WPA -"hostpad_config" : 0x20, # Use Custom hostapd config file. +"hostapd_config" : 0x20, # Use Custom hostapd config file. "enable_80211d" : 0x40, # Enable 802.11D to broadcast country-code & channels in VAPs "short_preamble" : 0x80, # Allow short-preamble "pri_sec_ch_enable" : 0x100, # Enable Primary/Secondary channel switch. From 730ad7ecdf57e8abf873214f57ff12d043b4c9f9 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 17:43:33 -0700 Subject: [PATCH 059/134] LFRequest.py: adds plain_get() --- py-json/LANforge/LFRequest.py | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index d82c147f..88c6ec57 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -231,4 +231,46 @@ class LFRequest: def addPostData(self, data): self.post_data = data + +def plain_get(url_=None, debug_=False, die_on_error_=False): + myrequest = urllib.request.Request(url=url_) + myresponses = [] + try: + myresponses.append(urllib.request.urlopen(myrequest)) + return myresponses[0] + except urllib.error.HTTPError as error: + if debug_: + print("----- LFRequest::get:181 HTTPError: --------------------------------------------") + print("<%s> HTTP %s: %s"%(myrequest.get_full_url(), error.code, error.reason)) + if error.code != 404: + print("Error: ", sys.exc_info()[0]) + print("Request URL:", myrequest.get_full_url()) + print("Request Content-type:", myrequest.get_header('Content-type')) + print("Request Accept:", myrequest.get_header('Accept')) + print("Request Data:") + LFUtils.debug_printer.pprint(myrequest.data) + + if error.headers: + # the HTTPError is of type HTTPMessage a subclass of email.message + # print(type(error.keys())) + for headername in sorted(error.headers.keys()): + print ("Response %s: %s "%(headername, error.headers.get(headername))) + + if len(myresponses) > 0: + print("----- Response: --------------------------------------------------------") + LFUtils.debug_printer.pprint(myresponses[0].reason) + print("------------------------------------------------------------------------") + if die_on_error_ == True: + # print("--------------------------------------------- s.doe %s v doe %s ---------------------------" % (self.die_on_error, die_on_error_)) + exit(1) + except urllib.error.URLError as uerror: + if debug_: + print("----- LFRequest::get:205 URLError: ---------------------------------------------") + print("Reason: %s; URL: %s"%(uerror.reason, myrequest.get_full_url())) + print("------------------------------------------------------------------------") + if die_on_error_ == True: + exit(1) + return None + + # ~LFRequest From dc91ae92a0019b126a9cf700d37270b08d2909e8 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 31 Jul 2020 17:44:03 -0700 Subject: [PATCH 060/134] tip_station_powersave.py: configures pcap location and starts testing fetch --- py-scripts/tip_station_powersave.py | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 1c95b0c2..dc192591 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -95,6 +95,7 @@ class TIPStationPowersave(LFCliBase): self.cx_prof_download.side_b_min_pdu = pdu_size_ self.cx_prof_download.side_b_max_pdu = 0 + self.pcap_file = None self.test_duration = traffic_duration_ if isinstance(self.test_duration, int): self.test_duration = "%s"%traffic_duration_ @@ -111,6 +112,7 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_disabled_profile = self.local_realm.new_station_profile() self.wifi_monitor_profile = self.local_realm.new_wifi_monitor_profile() + self.pcap_save_path = "/home/lanforge/lf_reports" def build(self): self.sta_powersave_disabled_profile.use_security("open", ssid=self.ssid, passwd=self.password) @@ -195,6 +197,17 @@ class TIPStationPowersave(LFCliBase): side_a=ul_side_a_eids, side_b="1.eth1") + print("Collecting lanforge eth0 IP...") + eth0_resp = self.json_get("/port/1/%s/eth0?fields=port,alias,ip"%self.resource, debug_=self.debug) + if (eth0_resp is None) or ("items" in eth0_resp) or ("interface" not in eth0_resp): + self._fail("Unable to query %s.eth0"%self.resource, print_=True) + exit(1) + self.eth0_ip = eth0_resp["interface"]["ip"] + if self.eth0_ip == "0.0.0.0": + self._fail("eth0 is misconfigured or not our management port", print_=True) + exit(1) + + def __get_rx_values(self): cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False) #print("==============\n", cx_list, "\n==============") @@ -225,10 +238,10 @@ class TIPStationPowersave(LFCliBase): now = datetime.datetime.now() date_time = now.strftime("%Y-%m-%d-%H%M%S") curr_mon_name = self.wifi_monitor_profile.monitor_name - pcap_file = "/home/lanforge/Documents/%s-%s.pcap"%(curr_mon_name, date_time) + self.pcap_file = "%s/%s-%s.pcap"%(self.pcap_save_path, curr_mon_name, date_time) capture_duration = 2 * ( self.test_duration.total_seconds() + self.pause_duration.total_seconds() + 4) - self.wifi_monitor_profile.start_sniff(pcap_file, capture_duration) + self.wifi_monitor_profile.start_sniff(self.pcap_file, capture_duration) time.sleep(0.05) self.sta_powersave_disabled_profile.admin_up(resource=1) @@ -252,6 +265,7 @@ class TIPStationPowersave(LFCliBase): self.cx_prof_download.start_cx() time.sleep(float(self.test_duration.total_seconds())) self.cx_prof_download.stop_cx() + print("Download ends at: %d"%time.time()) def stop(self): @@ -262,6 +276,20 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_enabled_profile.admin_down(self.resource) self.sta_powersave_disabled_profile.admin_down(self.resource) + # check for that pcap file + if self.pcap_file is None: + self._fail("Did not configure pcap file") + homepage_url = "http://%s/"%self.eth0_ip + webpage = LFRequest.plain_get(url_=homepage_url, debug_=True) + if webpage is None: + self._fail("Unable to find wepage for LANforge") + homepage_url="http://%s/lf_reports/"%self.eth0_ip + webpage = LFRequest.plain_get(url_=homepage_url, debug_=True) + if webpage is None: + self._fail("Unable to find /lf_reports/ page") + # now check for the pcap file we just created + + def cleanup(self): self.wifi_monitor_profile.cleanup(resource_=self.resource, desired_ports=[self.monitor_name]) self.cx_prof_download.cleanup() From 6b7626caf691181320c46bb2be7373f7331d8b7e Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 1 Aug 2020 08:42:41 -0600 Subject: [PATCH 061/134] mcast updates --- py-json/realm.py | 102 +++++++------------------------- py-scripts/test_l3_longevity.py | 45 ++++---------- 2 files changed, 31 insertions(+), 116 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 240a4146..dadfcf95 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -493,24 +493,12 @@ class Realm(LFCliBase): class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, - side_a_min_bps=None, side_b_min_bps=None, - side_a_max_bps=0, side_b_max_bps=0, - side_a_min_pdu=-1, side_b_min_pdu=-1, - side_a_max_pdu=0, side_b_max_pdu=0, report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): """ :param lfclient_host: :param lfclient_port: :param local_realm: - :param side_a_min_bps: - :param side_b_min_bps: - :param side_a_max_bps: - :param side_b_max_bps: - :param side_a_min_pdu: - :param side_b_min_pdu: - :param side_a_max_pdu: - :param side_b_max_pdu: :param name_prefix: prefix string for connection :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: @@ -519,14 +507,6 @@ class MULTICASTProfile(LFCliBase): self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm - self.side_a_min_pdu = side_a_min_pdu - self.side_b_min_pdu = side_b_min_pdu - self.side_a_max_pdu = side_a_max_pdu - self.side_b_max_pdu = side_b_max_pdu - self.side_a_min_bps = side_a_min_bps - self.side_b_min_bps = side_b_min_bps - self.side_a_max_bps = side_a_max_bps - self.side_b_max_bps = side_b_max_bps self.report_timer = report_timer_ self.created_mc = {} self.name_prefix = name_prefix_ @@ -538,7 +518,7 @@ class MULTICASTProfile(LFCliBase): def refresh_mc(self): pass - def start_mc_tx(self, side_b, suppress_related_commands=None, debug_ = False ): + def start_mc_tx(self, side_tx, suppress_related_commands=None, debug_ = False ): if self.debug: debut_=True @@ -555,17 +535,17 @@ class MULTICASTProfile(LFCliBase): self.local_realm.json_post(url, json_data) - def start_mc_rx(self,side_a, suppress_related_commands=None, debug_ = False): + def start_mc_rx(self,side_rx, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True - for port_name in side_a: - side_a_info = self.local_realm.name_to_eid(port_name) - side_a_resource = side_a_info[2] - side_a_name = "%s%s"%(self.name_prefix, side_a_info[2]) + for port_name in side_rx: + side_rx_info = self.local_realm.name_to_eid(port_name) + side_rx_resource = side_rx_info[2] + side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) json_data = { - "endp_name":side_a_resource + "endp_name":side_rx_resource } url = "cli-json/start_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) @@ -578,24 +558,20 @@ class MULTICASTProfile(LFCliBase): def cleanup(self): pass - def create_mc_tx(self, side_b, suppress_related_commands=None, debug_ = False ): + def create_mc_tx(self, side_tx, suppress_related_commands=None, debug_ = False ): if self.debug: debug_=True json_data = [] - # need to eventually us this - #mc_tx_name = "%s%s" % (self.name_prefix, side_b) - - # hard code for now + # hard code for now endp_name = 'mcast-xmit-sta' - # add end point - #add_endp mcast-xmit-sta 1 1 eth1 mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 + #add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { 'alias':endp_name, 'shelf':1, 'resource':1, - 'port':side_b, + 'port':side_tx, 'type':'mc_udp', 'ip_port':-1, 'is_rate_bursty': @@ -610,24 +586,10 @@ class MULTICASTProfile(LFCliBase): 'send_bad_crc_per_million':0, 'multi_conn':0 } - url = "/cli-json/add_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - - #set_endp_addr mcast-xmit-sta '0c c4 7a e1 ff b1 ' AUTO 0 0 - json_data = { - 'name':endp_name, - "mac":"xx:xx:xx:xx:*:xx", #'mac':'0c:c4:7a:e1:ff:b1' - 'ip':'AUTO', - 'min_port':0, - 'max_port':0 - } - - url = "cli-json/set_endp_addr" - #self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical json_data = { 'name':endp_name, @@ -639,24 +601,21 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - - - - def create_mc_rx(self,side_a, suppress_related_commands=None, debug_ = False): + def create_mc_rx(self,side_rx, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True - for port_name in side_a: - side_a_info = self.local_realm.name_to_eid(port_name) - side_a_shelf = side_a_info[1] - side_a_resource = side_a_info[2] - side_a_name = "%s%s"%(self.name_prefix, side_a_info[2]) + for port_name in side_rx: + side_rx_info = self.local_realm.name_to_eid(port_name) + side_rx_shelf = side_rx_info[1] + side_rx_resource = side_rx_info[2] + side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_a_resource, - 'shelf':side_a_shelf, + 'alias':side_rx_resource, + 'shelf':side_rx_shelf, 'resource':1, - 'port':side_a_resource, + 'port':side_rx_resource, 'type':'mc_udp', 'ip_port':9999, 'is_rate_bursty': @@ -675,21 +634,8 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/add_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #set_endp_addr mcast-rcv-sta-001 '00 0e 8e 5b 9d 44 ' AUTO 9999 0 - #json_data = { - # 'name':side_a_resource, - # 'mac':'xx:xx:xx:xx:*:xx', - # 'ip':'AUTO', - # 'min_port':9999, - # 'max_port':0 - # } - # - #url = "cli-json/set_endp_addr" - #self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - - # set_mc_endp mcast-rcv-sta-001 32 224.9.9.9 9999 Yes json_data = { - 'name':side_a_resource, + 'name':side_rx_resource, 'ttl':32, 'mcast_group':'224.9.9.9', 'mcast_dest_port':9999, @@ -698,12 +644,6 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - '''json_data = { - "endp_name":side_a_resource - } - url = "cli-json/start_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - ''' def to_string(self): pprint.pprint(self) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index fea2c218..05bc9ce9 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -17,31 +17,13 @@ import realm import time import datetime -#The valid ways to have multiple TX would be if they were on different ports. -# I don't think that we need to add that complexity for now. - -#In fact, it occurs to me that a multicast TX profile might actually already -# know the right amount of information from which to generate it's RX endpoints - -#So if we create a TX endpoint, it has a multicast ip and port. -# Those two pieces of information are also useful for creating RXes. -# I suggest one profile class. - - -#multicast_profile.createTx(port) and multicast_profile.createRX(port_list) - -#the ports have no knowledge of the protocols they will interact with, -#the ports are layer-1 devices with some layer2 and layer3 features (mac addresses, IP addresses) -#so anything you can legally assign an IP to can take a Layer3 connection or better - - class L3VariableTimeLongevity(LFCliBase): def __init__(self, host, port, endp_type, is_multicast, side_b, radios, radio_name_list, number_of_stations_per_radio_list, ssid_list, ssid_password_list, security, station_lists, name_prefix, resource=1, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", - _debug_on=True, + _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) @@ -138,20 +120,20 @@ class L3VariableTimeLongevity(LFCliBase): temp_station_list = station_list.copy() temp_stations_list.append(temp_station_list) temp_stations_list.append(self.side_b) - self.local_realm.wait_for_ip(self.resource, temp_station_list) + if self.local_realm.wait_for_ip(self.resource, temp_station_list,timeout_sec=120): + print("ip's aquired") + else: + print("print failed to get IP's") + temp_station_list = [] if self.is_multicast: for station_list in self.station_lists: for station in range(len(station_list)): temp_station_list.append(str(self.resource) + "." + station_list[station]) - - # start recievers - self.multicast_profile.start_mc_rx(side_a=temp_station_list) - - # right now the multicast is hard coded, need to pass in station - self.multicast_profile.start_mc_tx(side_b=self.side_b) + self.multicast_profile.start_mc_rx(side_rx=temp_station_list) + self.multicast_profile.start_mc_tx(side_tx=self.side_b) else: self.cx_profile.start_cx() @@ -249,8 +231,6 @@ class L3VariableTimeLongevity(LFCliBase): url = "cli-json/add_br" self.json_post(url, data) - #refactor later - try: data = LFUtils.port_dhcp_up_request(resource, self.side_b) self.json_post("/cli-json/set_port", data) @@ -258,28 +238,23 @@ class L3VariableTimeLongevity(LFCliBase): print("LFUtils.port_dhcp_up_request didn't complete ") print("or the json_post failed either way {} did not set up dhcp so test may no pass ".format(self.side_b)) - #exit(1) - resource = 1 index = 0 for station_profile in self.station_profiles: station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) station_profile.set_number_template(station_profile.number_template) print("Creating stations") - #station_profile.set_command_flag("add_sta", "create_admin_down", 1) - #station_profile.set_command_param("set_port", "report_timer", 1500) - #station_profile.set_command_flag("set_port", "rpt_timer", 1) temp_station_list = [] index = 0 for station_list in self.station_lists: for station in range(len(station_list)): temp_station_list.append(str(self.resource) + "." + station_list[station]) - station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=True ) + station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=False ) index += 1 if self.is_multicast: self.multicast_profile.create_mc_tx(self.side_b) - self.multicast_profile.create_mc_rx(side_a=temp_station_list) + self.multicast_profile.create_mc_rx(side_rx=temp_station_list) else: self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) self._pass("PASS: Stations build finished") From 2b42504a9db64cfd287b30429b75c6cd0c761332 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 3 Aug 2020 14:50:40 -0600 Subject: [PATCH 062/134] added admin up for multicase, and debugging --- py-json/realm.py | 17 +++++++++++++++++ py-scripts/test_l3_longevity.py | 21 ++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index dadfcf95..37b7b10e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -518,6 +518,23 @@ class MULTICASTProfile(LFCliBase): def refresh_mc(self): pass + def admin_up_mc_tx(self, resource, side_mc_tx): + set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portUpRequest(resource, None, debug_on=False) + req_json["port"] = side_mc_tx + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) + + def admin_down_mc_tx(self, resource): + set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) + req_json = LFUtils.portDownRequest(resource, None, debug_on=False) + for sta_name in self.station_names: + req_json["port"] = sta_name + set_port_r.addPostData(req_json) + json_response = set_port_r.jsonPost(self.debug) + time.sleep(0.03) + def start_mc_tx(self, side_tx, suppress_related_commands=None, debug_ = False ): if self.debug: debut_=True diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 05bc9ce9..0965778b 100644 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -23,7 +23,7 @@ class L3VariableTimeLongevity(LFCliBase): side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", - _debug_on=False, + _debug_on=True, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) @@ -111,10 +111,16 @@ class L3VariableTimeLongevity(LFCliBase): def start(self, print_pass=False, print_fail=False): print("Bringing up stations") + up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.side_b) + self.local_realm.json_post("/cli-json/set_port", up_request) for station_profile in self.station_profiles: print("Bringing up station {}".format(station_profile)) station_profile.admin_up(self.resource) + if self.is_multicast: + self.multicast_profile.admin_up_mc_tx(self.resource, self.side_b) + + temp_stations_list = [] for station_list in self.station_lists: temp_station_list = station_list.copy() @@ -125,8 +131,6 @@ class L3VariableTimeLongevity(LFCliBase): else: print("print failed to get IP's") - - temp_station_list = [] if self.is_multicast: for station_list in self.station_lists: @@ -149,7 +153,6 @@ class L3VariableTimeLongevity(LFCliBase): else: filtered_old_rx_values = old_rx_values - end_time = self.local_realm.parse_time(self.test_duration) + cur_time passes = 0 @@ -204,8 +207,10 @@ class L3VariableTimeLongevity(LFCliBase): def build(self): - # refactor in LFUtils.port_zero_request() + + # refactor in LFUtils.port_zero_request() resource = 1 + data ={ 'shelf':1, 'resource':1, @@ -219,6 +224,7 @@ class L3VariableTimeLongevity(LFCliBase): url = "cli-json/set_port" self.json_post(url, data) + # refactor into LFUtils data ={ @@ -231,12 +237,13 @@ class L3VariableTimeLongevity(LFCliBase): url = "cli-json/add_br" self.json_post(url, data) + try: data = LFUtils.port_dhcp_up_request(resource, self.side_b) self.json_post("/cli-json/set_port", data) except: print("LFUtils.port_dhcp_up_request didn't complete ") - print("or the json_post failed either way {} did not set up dhcp so test may no pass ".format(self.side_b)) + print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(self.side_b)) resource = 1 index = 0 @@ -250,7 +257,7 @@ class L3VariableTimeLongevity(LFCliBase): for station_list in self.station_lists: for station in range(len(station_list)): temp_station_list.append(str(self.resource) + "." + station_list[station]) - station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=False ) + station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=True ) index += 1 if self.is_multicast: self.multicast_profile.create_mc_tx(self.side_b) From 8b42e51a373964cceea3dae1727c4c113e37727e Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 3 Aug 2020 17:02:37 -0700 Subject: [PATCH 063/134] Added bridge creation to VAPProfile create --- py-json/realm.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 37b7b10e..6c69a570 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1466,7 +1466,6 @@ class VAPProfile(LFCliBase): "frequency": self.local_realm.channel_freq(channel_=channel) } self.local_realm.json_post("/cli-json/set_wifi_radio", _data=data) - if up_ is not None: self.up = up_ if self.up: @@ -1515,11 +1514,20 @@ class VAPProfile(LFCliBase): json_response = set_port_r.jsonPost(debug) time.sleep(0.03) + # create bridge + data = { + "shelf": 1, + "resource": resource, + "port": "br0", + "network_devs": "eth1,%s" % self.vap_name + } + self.local_realm.json_post("cli-json/add_br", data) + if (self.up): self.admin_up(1) def cleanup(self, resource, desired_ports=None, delay=0.03): - print("Cleaning up vaps") + print("Cleaning up VAPs") req_url = "/cli-json/rm_vlan" data = { "shelf": 1, From e5b339ebfb7157bc3adb4283a71665d7626d921f Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Mon, 3 Aug 2020 17:03:19 -0700 Subject: [PATCH 064/134] Added radio argument to specify radio used in creation of stations --- py-scripts/test_ipv4_variable_time.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 90acad72..f9be5880 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -19,7 +19,7 @@ import datetime class IPV4VariableTime(LFCliBase): - def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, radio="wiphy0", side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, number_template="00000", test_duration="5m", @@ -33,6 +33,7 @@ class IPV4VariableTime(LFCliBase): self.sta_list = sta_list self.security = security self.password = password + self.radio = radio self.number_template = number_template self.debug = _debug_on self.resource = resource @@ -149,7 +150,7 @@ class IPV4VariableTime(LFCliBase): temp_sta_list = [] for station in range(len(self.sta_list)): temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(resource=1, radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self.cx_profile.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) self._pass("PASS: Station build finished") From 22c2217acf58c1aab1eae14b1c48bcd19e587905 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Mon, 3 Aug 2020 22:00:54 -0700 Subject: [PATCH 065/134] tip_station_powersave.py: improves timing for connections, and cleanup --- py-scripts/tip_station_powersave.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index dc192591..a7afb8b6 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -252,6 +252,7 @@ class TIPStationPowersave(LFCliBase): port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) self.local_realm.wait_for_ip(resource=self.resource, station_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + time.sleep(2) self.cx_prof_bg.start_cx() print("Upload starts at: %d"%time.time()) self.cx_prof_upload.start_cx() @@ -292,8 +293,9 @@ class TIPStationPowersave(LFCliBase): def cleanup(self): self.wifi_monitor_profile.cleanup(resource_=self.resource, desired_ports=[self.monitor_name]) - self.cx_prof_download.cleanup() - self.cx_prof_upload.cleanup() + #self.cx_prof_download.cleanup() + self.local_realm.remove_all_cxs(remove_all_endpoints=True) + #self.cx_prof_upload.cleanup() self.sta_powersave_enabled_profile.cleanup(resource=self.resource, desired_stations=self.powersave_sta_list) self.sta_powersave_disabled_profile.cleanup(resource=self.resource, desired_stations=self.normal_sta_list) From 56a6b93d451f8aa27af175acecda0e1b7e1927c4 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 4 Aug 2020 10:11:33 -0700 Subject: [PATCH 066/134] Added extra flags for enable 160MHz --- py-json/realm.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6c69a570..2a836b93 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1303,6 +1303,7 @@ class VAPProfile(LFCliBase): "ap_name": None, "flags": 0, "flags_mask": 0, + "mode": 0, "ssid": None, "key": None, "mac": "xx:xx:xx:xx:*:xx" @@ -1319,10 +1320,6 @@ class VAPProfile(LFCliBase): "interest": 0, # (0x2 + 0x4000 + 0x800000) # current, dhcp, down } - if self.use_ht160: - self.desired_add_vap_flags.append("ht160_enable") - self.desired_add_vap_flags_mask.append("ht160_enable") - def admin_up(self, resource): set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) req_json = LFUtils.portUpRequest(resource, None, debug_on=self.debug) @@ -1446,6 +1443,17 @@ class VAPProfile(LFCliBase): return result def create(self, resource, radio, channel=None, up_=None, debug=False, suppress_related_commands_=True): + + if self.use_ht160: + self.desired_add_vap_flags.append("enable_80211d") + self.desired_add_vap_flags_mask.append("enable_80211d") + self.desired_add_vap_flags.append("80211h_enable") + self.desired_add_vap_flags_mask.append("80211h_enable") + self.desired_add_vap_flags.append("ht160_enable") + self.desired_add_vap_flags_mask.append("ht160_enable") + + print("MODE ========= ", self.mode) + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), debug_=self.debug) if jr is None: raise ValueError("No radio %s.%s found" % (resource, radio)) @@ -1460,7 +1468,7 @@ class VAPProfile(LFCliBase): "shelf": 1, "resource": resource, "radio": radio, - "mode": 0, #"NA", #0 for AUTO or "NA" + "mode": self.mode, #"NA", #0 for AUTO or "NA" "channel": channel, "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) @@ -1474,7 +1482,8 @@ class VAPProfile(LFCliBase): elif "create_admin_down" not in self.desired_add_vap_flags: self.desired_add_vap_flags.append("create_admin_down") - # create stations down, do set_port on them, then set stations up + # create vaps down, do set_port on them, then set vaps up + self.add_vap_data["mode"] = self.mode self.add_vap_data["flags"] = self.add_named_flags(self.desired_add_vap_flags, add_vap.add_vap_flags) self.add_vap_data["flags_mask"] = self.add_named_flags(self.desired_add_vap_flags_mask, add_vap.add_vap_flags) self.add_vap_data["radio"] = radio From 3a94735b4b9f4ec9e7c97662c0ddafd84e7d9c05 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 4 Aug 2020 13:23:13 -0700 Subject: [PATCH 067/134] Added options to enable ht160 --- py-scripts/test_ipv4_variable_time.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index f9be5880..8032e2bd 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -22,7 +22,7 @@ class IPV4VariableTime(LFCliBase): def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, radio="wiphy0", side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, - number_template="00000", test_duration="5m", + number_template="00000", test_duration="5m", use_ht160=False, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): @@ -48,7 +48,8 @@ class IPV4VariableTime(LFCliBase): self.station_profile.ssid_pass = self.password, self.station_profile.security = self.security self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 + self.station_profile.mode = 9 + self.station_profile.use_ht160 = use_ht160 self.cx_profile.host = self.host self.cx_profile.port = self.port @@ -161,10 +162,11 @@ def main(): station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) ip_var_test = IPV4VariableTime(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, name_prefix="var_time", - ssid="jedway-wpa2-x2048-4-4", - password="jedway-wpa2-x2048-4-4", + ssid="jedway-wpa2-160", + password="jedway-wpa2-160", resource=1, - security="wpa2", test_duration="5m", + radio="wiphy2", + security="wpa2", test_duration="5m", use_ht160=False, side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=False) ip_var_test.cleanup(station_list) From 8efe1dfd236283976f84f230afe352294acc6bb1 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 4 Aug 2020 13:23:28 -0700 Subject: [PATCH 068/134] Added options to StationProfile to enable ht160 --- py-json/realm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 2a836b93..8bce277d 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1594,7 +1594,7 @@ class VAPProfile(LFCliBase): # class StationProfile: def __init__(self, lfclient_url, local_realm, ssid="NA", ssid_pass="NA", security="open", number_template_="00000", mode=0, up=True, - dhcp=True, debug_=False): + dhcp=True, debug_=False, use_ht160=False): self.debug = debug_ self.lfclient_url = lfclient_url self.ssid = ssid @@ -1604,6 +1604,7 @@ class StationProfile: self.dhcp = dhcp self.security = security self.local_realm = local_realm + self.use_ht160 = use_ht160 self.COMMANDS = ["add_sta", "set_port"] self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.desired_add_sta_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] @@ -1824,6 +1825,12 @@ class StationProfile: # print("Building %s on radio %s.%s" % (num_stations, resource, radio_name)) # except ValueError as e: # print(e) + + if self.use_ht160: + self.desired_add_sta_flags.append("ht160_enable") + self.desired_add_sta_flags_mask.append("ht160_enable") + self.add_sta_data["mode"] = self.mode + if up_ is not None: self.up = up_ From 761dff87ae22442d3dd8028d177650dc62bca211 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 4 Aug 2020 13:25:10 -0700 Subject: [PATCH 069/134] Added ht160 check for station mode --- py-scripts/test_ipv4_variable_time.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 8032e2bd..111fa916 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -48,8 +48,10 @@ class IPV4VariableTime(LFCliBase): self.station_profile.ssid_pass = self.password, self.station_profile.security = self.security self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 9 + self.station_profile.mode = 0 self.station_profile.use_ht160 = use_ht160 + if self.station_profile.use_ht160: + self.station_profile.mode = 9 self.cx_profile.host = self.host self.cx_profile.port = self.port From 8e585a64cc8fdf0f38c03738c891dd9cccc953af Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 4 Aug 2020 13:22:53 -0600 Subject: [PATCH 070/134] initial check in of test_l3_unicast_traffic_gen.py, try except to remove_all_cx --- py-json/realm.py | 29 +- py-scripts/test_l3_unicast_traffic_gen.py | 398 ++++++++++++++++++++++ 2 files changed, 414 insertions(+), 13 deletions(-) create mode 100644 py-scripts/test_l3_unicast_traffic_gen.py diff --git a/py-json/realm.py b/py-json/realm.py index 6c69a570..8dc43558 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -423,19 +423,22 @@ class Realm(LFCliBase): # remove endpoints # nc show endpoints # nc show cross connects - cx_list = list(self.cx_list()) - not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] - if cx_list is not None: - print("Removing all cxs") - for cx_name in cx_list: - if cx_name in not_cx: - continue - req_url = "cli-json/rm_cx" - data = { - "test_mgr": "default_tm", - "cx_name": cx_name - } - self.json_post(req_url, data) + try: + cx_list = list(self.cx_list()) + not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] + if cx_list is not None: + print("Removing all cxs") + for cx_name in cx_list: + if cx_name in not_cx: + continue + req_url = "cli-json/rm_cx" + data = { + "test_mgr": "default_tm", + "cx_name": cx_name + } + self.json_post(req_url, data) + except: + print("no cxs to remove") if remove_all_endpoints: self.remove_all_endps() diff --git a/py-scripts/test_l3_unicast_traffic_gen.py b/py-scripts/test_l3_unicast_traffic_gen.py new file mode 100644 index 00000000..0b466ecd --- /dev/null +++ b/py-scripts/test_l3_unicast_traffic_gen.py @@ -0,0 +1,398 @@ +#!/usr/bin/env python3 + +import sys +import os + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils +import realm +import time +import datetime + +class L3VariableTimeLongevity(LFCliBase): + def __init__(self, host, port, endp_type, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + ssid_list, ssid_password_list, security, station_lists, name_prefix, resource=1, + side_a_min_rate=256000, side_a_max_rate=0, + side_b_min_rate=256000, side_b_max_rate=0, + number_template="00", test_duration="125s", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.endp_type = endp_type + self.side_b = side_b + self.ssid_list = ssid_list + self.ssid_password_list = ssid_password_list + self.station_lists = station_lists + self.security = security + self.number_template = number_template + self.resource = resource + self.name_prefix = name_prefix + self.test_duration = test_duration + self.cx_stations_lists = station_lists + self.radios = radios # from the command line + self.radio_list = radio_name_list + self.number_of_stations_per_radio_list = number_of_stations_per_radio_list + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.cx_profile = self.local_realm.new_l3_cx_profile() + self.station_profiles = [] + + index = 0 + for radio in radios: + self.station_profile = self.local_realm.new_station_profile() + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = ssid_list[index] + self.station_profile.ssid_pass = ssid_password_list[index] + self.station_profile.security = self.security + self.station_profile.number_template = self.number_template + self.station_profile.mode = 0 + self.station_profiles.append(self.station_profile) + index += 1 + + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = side_a_min_rate + self.cx_profile.side_a_max_bps = side_a_max_rate + self.cx_profile.side_b_min_bps = side_b_min_rate + self.cx_profile.side_b_max_bps = side_b_max_rate + + def __get_rx_values(self): + cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=False) + cx_rx_map = {} + for cx_name in cx_list['endpoint']: + if cx_name != 'uri' and cx_name != 'handler': + for item, value in cx_name.items(): + for value_name, value_rx in value.items(): + if value_name == 'rx bytes': + cx_rx_map[item] = value_rx + return cx_rx_map + + def __compare_vals(self, old_list, new_list): + passes = 0 + expected_passes = 0 + if len(old_list) == len(new_list): + for item, value in old_list.items(): + expected_passes += 1 + if new_list[item] > old_list[item]: + passes += 1 + print(item, new_list[item], old_list[item], passes, expected_passes) + + if passes == expected_passes: + return True + else: + return False + else: + return False + + def start(self, print_pass=False, print_fail=False): + print("Bringing up stations") + + up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.side_b) + self.local_realm.json_post("/cli-json/set_port", up_request) + for station_profile, station_list in zip(self.station_profiles, self.station_lists): + print("Bringing up station {}".format(station_profile)) + station_profile.admin_up(self.resource) + if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=120): + print("ip's aquired {}".format(station_list)) + else: + print("print failed to get IP's: {}".format(station_list)) + if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=120): + print("tried again: print failed to get IP's: {}".format(station_list)) + exit(1) + + + + self.cx_profile.start_cx() + + cur_time = datetime.datetime.now() + old_rx_values = self.__get_rx_values() + filtered_old_rx_values = [] + filtered_old_rx_values = old_rx_values + + end_time = self.local_realm.parse_time(self.test_duration) + cur_time + + passes = 0 + expected_passes = 0 + while cur_time < end_time: + interval_time = cur_time + datetime.timedelta(minutes=1) + while cur_time < interval_time: + cur_time = datetime.datetime.now() + time.sleep(1) + + new_rx_values = self.__get_rx_values() + filtered_new_rx_values = [] + filtered_new_rx_values = new_rx_values + + expected_passes += 1 + if self.__compare_vals(filtered_old_rx_values, filtered_new_rx_values): + passes += 1 + else: + self._fail("FAIL: Not all stations increased traffic", print_fail) + break + old_rx_values = new_rx_values + cur_time = datetime.datetime.now() + + if passes == expected_passes: + self._pass("PASS: All tests passed", print_pass) + + def stop(self): + self.cx_profile.stop_cx() + for station_list in self.station_lists: + for station_name in station_list: + data = LFUtils.portDownRequest(1, station_name) + url = "cli-json/set_port" + self.json_post(url, data) + + def cleanup(self, resource): + resource = 1 + data = { + "name":"BLANK", + "action":"overwrite" + } + url = "cli-json/load" + self.json_post(url, data) + + timeout = 20 + done = False + while timeout > 0 and done == False: + time.sleep( 1) + port_r = self.json_get("/port/1/1/list?fields=alias") + print("port interfaces {}".format(port_r["interfaces"])) + for interface in port_r["interfaces"]: + if "sta" in interface: + print("interface {}".format(interface)) + else: + done = True + break + timeout -= 1 + + if timeout <= 0: + print("not all station ports removed {}".format(port_r["interfaces"])) + + def build(self): + # refactor in LFUtils.port_zero_request() + resource = 1 + + data ={ + 'shelf':1, + 'resource':1, + 'port':'eth1', + 'ip_addr':'0.0.0.0', + 'netmask':'0.0.0.0', + 'gateway':'0.0.0.0', + 'current_flags':0, + 'interest':402653212 + } + + url = "cli-json/set_port" + self.json_post(url, data) + + # refactor into LFUtils + data ={ + "shelf":1, + "resource": resource, + "port":"br0", + "network_devs":"eth1", + "br_flags":1 + } + url = "cli-json/add_br" + self.json_post(url, data) + + try: + data = LFUtils.port_dhcp_up_request(resource, self.side_b) + self.json_post("/cli-json/set_port", data) + except: + print("LFUtils.port_dhcp_up_request didn't complete ") + print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(self.side_b)) + + resource = 1 + index = 0 + for station_profile, station_list in zip(self.station_profiles, self.station_lists): + station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) + station_profile.set_number_template(station_profile.number_template) + print("radio: {} station_profile: {} Creating stations: {} ".format(self.radio_list[index],station_profile, station_list)) + + temp_station_list = [] + for station in range(len(station_list)): + temp_station_list.append(str(self.resource) + "." + station_list[station]) + station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=False ) + index += 1 + self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) + self._pass("PASS: Stations build finished") + +def valid_endp_type(endp_type): + valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6'] + if str(endp_type) in valid_endp_type: + return endp_type + else: + print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6') + exit(1) + +def main(): + lfjson_host = "localhost" + lfjson_port = 8080 + + parser = argparse.ArgumentParser( + prog='test_l3_longevity.py', + #formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ +Useful Information: + +1. Polling interval for checking traffic is fixed at 1 minute +2. The test will exit when traffic has not changed on a station for 1 minute +3. The tx/rx rates are fixed at 256000 bits per second +4. Security is fixed at WPA2 +5. Maximum stations per radio is 64 + ''', + + description='''\ +test_l3_longevity.py: +-------------------- +Basic Idea: + +create stations, create traffic between upstream port and stations, run traffic. +The traffic on the stations will be checked once per minute to verify that traffic is transmitted +and recieved. + +Test will exit on failure of not recieving traffice for one minute on any station. + +Scripts are executed from: ./lanforge/py-scripts + +Stations start counting form zero, thus stations count from zero - number of las + +Generic command layout: +python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port + --radio + +Note: +multiple --radio switches may be entered up to the number of radios available: +--radio --radio + +: number followed by one of the following + d - days + h - hours + m - minutes + s - seconds + +: + lf_udp : IPv4 UDP traffic + lf_tcp : IPv4 TCP traffic + lf_udp6 : IPv6 UDP traffic + lf_tcp6 : IPv6 TCP traffic + +Example: + 1. Test duration 4 minutes + 2. Traffic IPv4 TCP + 3. Upstream-port eth1 + 4. Radio #1 wiphy0 has 32 stations, ssid = candelaTech-wpa2-x2048-4-1, ssid password = candelaTech-wpa2-x2048-4-1 + 5. Radio #2 wiphy1 has 64 stations, ssid = candelaTech-wpa2-x2048-5-3, ssid password = candelaTech-wpa2-x2048-5-3 + +Example: +python3 .\\test_l3_longevity.py --test_duration 4m --endp_type lf_tcp --upstream_port eth1 \ + --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 \ + --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 + + ''') + + + parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') + parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type lf_udp, default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6', + default='lf_udp',type=valid_endp_type) + parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') + + requiredNamed = parser.add_argument_group('required arguments') + requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('', '','',''), + help ='--radio ',required=True) + args = parser.parse_args() + + if args.test_duration: + test_duration = args.test_duration + + if args.endp_type: + endp_type = args.endp_type + + side_b = args.upstream_port + + if args.radio: + radios = args.radio + + radio_offset = 0 + number_of_stations_offset = 1 + ssid_offset = 2 + ssid_password_offset = 3 + + MAX_NUMBER_OF_STATIONS = 64 + + radio_name_list = [] + number_of_stations_per_radio_list = [] + ssid_list = [] + ssid_password_list = [] + + index = 0 + for radio in radios: + radio_name = radio[radio_offset] + radio_name_list.append(radio_name) + number_of_stations_per_radio = radio[number_of_stations_offset] + number_of_stations_per_radio_list.append(number_of_stations_per_radio) + ssid = radio[ssid_offset] + ssid_list.append(ssid) + ssid_password = radio[ssid_password_offset] + ssid_password_list.append(ssid_password) + index += 1 + + index = 0 + station_lists = [] + for radio in radios: + number_of_stations = int(number_of_stations_per_radio_list[index]) + if number_of_stations > MAX_NUMBER_OF_STATIONS: + print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) + quit(1) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) + station_lists.append(station_list) + index += 1 + ip_var_test = L3VariableTimeLongevity(lfjson_host, + lfjson_port, + number_template="00", + station_lists= station_lists, + name_prefix="var_time", + endp_type=endp_type, + side_b=side_b, + radios=radios, + radio_name_list=radio_name_list, + number_of_stations_per_radio_list=number_of_stations_per_radio_list, + ssid_list=ssid_list, + ssid_password_list=ssid_password_list, + resource=1, + security="wpa2", test_duration=test_duration, + side_a_min_rate=256000, side_b_min_rate=256000) + + ip_var_test.cleanup(station_list) + ip_var_test.build() + if not ip_var_test.passes(): + print(ip_var_test.get_fail_message()) + exit(1) + ip_var_test.start(False, False) + ip_var_test.stop() + if not ip_var_test.passes(): + print(ip_var_test.get_fail_message()) + exit(1) + time.sleep(30) + ip_var_test.cleanup(station_list) + if ip_var_test.passes(): + print("Full test passed, all connections increased rx bytes") + + +if __name__ == "__main__": + main() From f84332d591d5b683a7c980ea51c3c9c5448e28a1 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Tue, 4 Aug 2020 15:37:47 -0700 Subject: [PATCH 071/134] Fixed typo, removed unnecessary mode set --- py-scripts/test_ipv4_variable_time.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 111fa916..22be50b6 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -45,10 +45,9 @@ class IPV4VariableTime(LFCliBase): self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, + self.station_profile.ssid_pass = self.password self.station_profile.security = self.security self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 self.station_profile.use_ht160 = use_ht160 if self.station_profile.use_ht160: self.station_profile.mode = 9 From 2070f483b8648a362d1de405c890f9ad29a26359 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 5 Aug 2020 06:45:36 -0600 Subject: [PATCH 072/134] changed timing waiting for IP --- py-scripts/test_l3_unicast_traffic_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_unicast_traffic_gen.py b/py-scripts/test_l3_unicast_traffic_gen.py index 0b466ecd..1e55a646 100644 --- a/py-scripts/test_l3_unicast_traffic_gen.py +++ b/py-scripts/test_l3_unicast_traffic_gen.py @@ -103,7 +103,7 @@ class L3VariableTimeLongevity(LFCliBase): for station_profile, station_list in zip(self.station_profiles, self.station_lists): print("Bringing up station {}".format(station_profile)) station_profile.admin_up(self.resource) - if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=120): + if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=10*len(station_list)): print("ip's aquired {}".format(station_list)) else: print("print failed to get IP's: {}".format(station_list)) From 960b87b61fc477b24d634f1896cd956717e3fde2 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 5 Aug 2020 13:13:24 -0700 Subject: [PATCH 073/134] python: flex-longevity, library cleanup. Remove use of 'resource' where possible, use port EIDs instead for multi-resource flexibility. Remove some spurious 'sleep' calls. If you think you need to sleep 2 seconds, you are probably facing a real race bug, so diagnose that instead or put big comments around why you added a sleep. Lots of changes to flex longevity, hopefully it can support multiple connection types now, but not tested that yet. Signed-off-by: Ben Greear --- py-json/LANforge/LFUtils.py | 41 ++- py-json/realm.py | 390 +++++++++++----------- py-scripts/__init__.py | 0 py-scripts/cicd_TipIntegration.py | 0 py-scripts/cicd_testrail.py | 0 py-scripts/cicd_testrailAndInfraSetup.py | 0 py-scripts/test_l3_WAN_LAN.py | 0 py-scripts/test_l3_longevity.py | 295 +++++++--------- py-scripts/test_l3_unicast_traffic_gen.py | 0 py-scripts/test_open_connection.py | 0 py-scripts/test_wanlink.py | 0 11 files changed, 343 insertions(+), 383 deletions(-) mode change 100644 => 100755 py-scripts/__init__.py mode change 100644 => 100755 py-scripts/cicd_TipIntegration.py mode change 100644 => 100755 py-scripts/cicd_testrail.py mode change 100644 => 100755 py-scripts/cicd_testrailAndInfraSetup.py mode change 100644 => 100755 py-scripts/test_l3_WAN_LAN.py mode change 100644 => 100755 py-scripts/test_l3_longevity.py mode change 100644 => 100755 py-scripts/test_l3_unicast_traffic_gen.py mode change 100644 => 100755 py-scripts/test_open_connection.py mode change 100644 => 100755 py-scripts/test_wanlink.py diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 534ed554..9ccf90fd 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -360,7 +360,7 @@ def wait_until_ports_disappear(resource_id=1, base_url="http://localhost:8080", return -def waitUntilPortsAppear(resource_id=1, base_url="http://localhost:8080", port_list=(), debug=False): +def waitUntilPortsAppear(base_url="http://localhost:8080", port_list=(), debug=False): """ Deprecated :param resource_id: @@ -369,12 +369,30 @@ def waitUntilPortsAppear(resource_id=1, base_url="http://localhost:8080", port_l :param debug: :return: """ - return wait_until_ports_appear(resource_id, base_url, port_list, debug=debug) + return wait_until_ports_appear(base_url, port_list, debug=debug) -def wait_until_ports_appear(resource_id=1, base_url="http://localhost:8080", port_list=(), debug=False): +def name_to_eid(eid): + rv = [1, 1, ""]; + info = [] + if (eid is None) or (eid == ""): + raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % eid) + + info = eid.split('.') + if (len(info) == 1): + rv[2] = info[0]; # just port name + if len(info) == 2: # resource.port-name + rv[1] = int(info[0]) + rv[2] = info[1] + if len(info) == 3: # shelf.resource.port-name + rv[0] = int(info[0]) + rv[1] = int(info[1]) + rv[2] = info[2] + + return rv; + +def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debug=False): """ - :param resource_id: :param base_url: :param port_list: :param debug: @@ -391,8 +409,13 @@ def wait_until_ports_appear(resource_id=1, base_url="http://localhost:8080", por while len(found_stations) < len(port_list): found_stations = [] - for port_name in port_list: - sleep(1) + for port_eid in port_list: + + eid = name_to_eid(port_eid) + shelf = eid[0] + resource_id = eid[1] + port_name = eid[2] + uri = "%s/%s/%s" % (port_url, resource_id, port_name) lf_r = LFRequest.LFRequest(base_url, uri) json_response = lf_r.getAsJson(debug_=False) @@ -400,9 +423,11 @@ def wait_until_ports_appear(resource_id=1, base_url="http://localhost:8080", por found_stations.append(port_name) else: lf_r = LFRequest.LFRequest(base_url, ncshow_url) - lf_r.addPostData({"shelf": 1, "resource": resource_id, "port": port_name, "flags": 1}) + lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "flags": 1}) lf_r.formPost() - sleep(2) + if (len(found_stations) < len(port_list)): + sleep(2) + if debug: print("These stations appeared: " + ", ".join(found_stations)) return diff --git a/py-json/realm.py b/py-json/realm.py index f4796307..4168ce53 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -127,6 +127,22 @@ class Realm(LFCliBase): port_list=sta_list, debug=debug_) + def admin_up(self, port_eid): + eid = self.name_to_eid(port_eid) + shelf = eid[0] + resource = eid[1] + port = eid[2] + request = LFUtils.port_up_request(resource_id=resource, port_name=port) + self.json_post("/cli-json/set_port", request) + + def admin_down(self, port_eid): + eid = self.name_to_eid(port_eid) + shelf = eid[0] + resource = eid[1] + port = eid[2] + request = LFUtils.port_down_request(resource_id=resource, port_name=port) + self.json_post("/cli-json/set_port", request) + def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] @@ -303,68 +319,47 @@ class Realm(LFCliBase): return matched_map def name_to_eid(self, eid): - info = [] - if (eid is None) or (eid == "") or ('.' not in eid): - raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % eid) + return LFUtils.name_to_eid(eid) - info = eid.split('.') - info[0] = int(info[0]) - if len(info) == 3: - info[1] = int(info[1]) - return info - return [1, int(info[0]), info[1]] - - def wait_for_ip(self, resource=1, station_list=None, ipv6=False, timeout_sec=60): - num_ports = 0 - num_ips = 0 + def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): print("Waiting for ips...") + print(station_list) + if (station_list is None) or (len(station_list) < 1): raise ValueError("wait_for_ip: expects non-empty list of ports") - response = super().json_get("/port/1/%s/%s?fields=alias,ip,port+type" % (resource, ",".join(station_list))) - if (response is None) or ("interfaces" not in response): - print("station_list: incomplete response:") - pprint(response) - exit(1) - for x in range(len(response['interfaces'])): - for k, v in response['interfaces'][x].items(): - if "wlan" not in v['alias'] and v['port type'] == "WIFI-STA" \ - or v['port type'] == "Ethernet": - num_ports += 1 - if ipv6: - num_ports -= 1 # Prevents eth0 from being counted, preventing infinite loop + wait_more = True + while wait_more and timeout_sec != 0: + wait_more = False - while num_ips != num_ports and timeout_sec != 0: - num_ips = 0 - response = super().json_get("/port/1/%s/%s?fields=alias,ip,port+type,ipv6+address" % - (resource, ",".join(station_list))) - if (response is None) or ("interfaces" not in response): - print("station_list: incomplete response:") - pprint(response) - exit(1) + for sta_eid in station_list: + print("sta-eid: %s"%(sta_eid)) + eid = self.name_to_eid(sta_eid) - if not ipv6: - for x in range(len(response['interfaces'])): - for k, v in response['interfaces'][x].items(): - if "wlan" not in v['alias'] and v['port type'] == "WIFI-STA" or v['port type'] == "Ethernet": - if v['ip'] != '0.0.0.0': - num_ips += 1 + response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % + (eid[0], eid[1], eid[2])) + if (response is None) or ("interface" not in response): + print("station_list: incomplete response:") + pprint(response) + + if ipv4: + for x in range(len(response['interface'])): + for k, v in response['interface'][x].items(): + if v['ip'] == '0.0.0.0': + wait_more = True + print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + if ipv6: + for x in range(len(response['interface'])): + for k, v in response['interface'][x].items(): + if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ + and v['ipv6 address'] != 'AUTO': + wait_more = True + print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + if wait_more: time.sleep(1) timeout_sec -= 1 - if ipv6: - for x in range(len(response['interfaces'])): - for k, v in response['interfaces'][x].items(): - if v['alias'] != "eth0" and "wlan" not in v['alias'] and v['port type'] == "WIFI-STA" \ - or v['port type'] == "Ethernet": - if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ - and v['ipv6 address'] != 'AUTO': - num_ips += 1 - time.sleep(1) - timeout_sec -= 1 - if num_ips == num_ports: - return True - else: - return False + + return not wait_more def parse_time(self, time_string): if isinstance(time_string, str): @@ -521,51 +516,13 @@ class MULTICASTProfile(LFCliBase): def refresh_mc(self): pass - def admin_up_mc_tx(self, resource, side_mc_tx): - set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portUpRequest(resource, None, debug_on=False) - req_json["port"] = side_mc_tx - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) - - def admin_down_mc_tx(self, resource): - set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portDownRequest(resource, None, debug_on=False) - for sta_name in self.station_names: - req_json["port"] = sta_name - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) - - def start_mc_tx(self, side_tx, suppress_related_commands=None, debug_ = False ): - if self.debug: - debut_=True - - print("starting mc_tx") - # hard code for now - endp_name = 'mcast-xmit-sta' - - #start the trasmitter probably should be in start - json_data = { - "endp_name":endp_name, - } - - url = "cli-json/start_endp" - self.local_realm.json_post(url, json_data) - - - def start_mc_rx(self,side_rx, suppress_related_commands=None, debug_ = False): + def start_mc(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True - for port_name in side_rx: - side_rx_info = self.local_realm.name_to_eid(port_name) - side_rx_resource = side_rx_info[2] - side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) - + for endp_name in self.get_mc_names(): json_data = { - "endp_name":side_rx_resource + "endp_name":endp_name } url = "cli-json/start_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) @@ -573,26 +530,45 @@ class MULTICASTProfile(LFCliBase): pass def stop_mc(self): - pass - - def cleanup(self): - pass - - def create_mc_tx(self, side_tx, suppress_related_commands=None, debug_ = False ): if self.debug: debug_=True + for endp_name in self.get_mc_names(): + json_data = { + "endp_name":endp_name + } + url = "cli-json/stop_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + pass + + def cleanup(self): + for endp_name in self.get_mc_names(): + json_data = { + "endp_name":endp_name + } + url = "cli-json/rm_endp" + self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_ = False ): + if self.debug: + debug_=True + + side_tx_info = self.local_realm.name_to_eid(side_tx) + side_tx_shelf = side_tx_info[0] + side_tx_resource = side_tx_info[1] + side_tx_port = side_tx_info[2] + side_tx_name = "mtx-%s-%i-"%(side_tx_port, len(created_mc)) + json_data = [] - # hard code for now - endp_name = 'mcast-xmit-sta' #add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':endp_name, - 'shelf':1, - 'resource':1, - 'port':side_tx, - 'type':'mc_udp', + 'alias':side_tx_name, + 'shelf':side_tx_shelf, + 'resource':side_tx_resource, + 'port':side_tx_port, + 'type':endp_type, 'ip_port':-1, 'is_rate_bursty': 'NO','min_rate':4000000, @@ -612,8 +588,9 @@ class MULTICASTProfile(LFCliBase): #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical json_data = { - 'name':endp_name, - 'ttl':32,'mcast_group':'224.9.9.9', + 'name':side_tx_name, + 'ttl':32, + 'mcast_group':'224.9.9.9', 'mcast_dest_port':9999, 'rcv_mcast':'No' } @@ -621,25 +598,28 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - def create_mc_rx(self,side_rx, suppress_related_commands=None, debug_ = False): + created_mc[side_tx_name] = side_tx_name + + def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True for port_name in side_rx: side_rx_info = self.local_realm.name_to_eid(port_name) - side_rx_shelf = side_rx_info[1] - side_rx_resource = side_rx_info[2] - side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) + side_rx_shelf = side_rx_info[0] + side_rx_resource = side_rx_info[1] + side_rx_port = side_rx_info[2] + side_rx_name = "mrx-%s-%i-"%(side_tx_port, len(created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_rx_resource, + 'alias':side_rx_name, 'shelf':side_rx_shelf, - 'resource':1, - 'port':side_rx_resource, - 'type':'mc_udp', + 'resource':side_rx_resource, + 'port':side_rx_port, + 'type':endp_type, 'ip_port':9999, - 'is_rate_bursty': - 'NO','min_rate':0, + 'is_rate_bursty':'NO', + 'min_rate':0, 'max_rate':0, 'is_pkt_sz_random':'NO', 'min_pkt':1472, @@ -655,7 +635,7 @@ class MULTICASTProfile(LFCliBase): self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) json_data = { - 'name':side_rx_resource, + 'name':side_rx_name, 'ttl':32, 'mcast_group':'224.9.9.9', 'mcast_dest_port':9999, @@ -664,6 +644,8 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + created_mc[side_rx_name] = side_rx_name + def to_string(self): pprint.pprint(self) @@ -708,6 +690,7 @@ class L3CXProfile(LFCliBase): self.side_b_max_bps = side_b_max_bps self.report_timer = report_timer_ self.created_cx = {} + self.created_endp = {} self.name_prefix = name_prefix_ self.number_template = number_template_ @@ -725,6 +708,7 @@ class L3CXProfile(LFCliBase): def start_cx(self): print("Starting CXs...") for cx_name in self.created_cx.keys(): + print("cx-name: %s"%(cx_name)) self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, @@ -780,7 +764,6 @@ class L3CXProfile(LFCliBase): side_b_info = self.local_realm.name_to_eid(side_b) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] - side_b_name = "%s%s" % (self.name_prefix, side_b_info[2]) for port_name in side_a: if port_name.find('.') < 0: @@ -789,13 +772,16 @@ class L3CXProfile(LFCliBase): side_a_info = self.local_realm.name_to_eid(port_name) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] - side_a_name = "%s%s"%(self.name_prefix, side_a_info[2]) + cx_name = "%s%s-%i"%(self.name_prefix, side_a_info[2], len(self.created_cx)) - cx_name = "%s%s" % (self.name_prefix, port_name) - self.created_cx[ cx_name ] = [side_a_name + "-A", side_a_name + "-B"] + endp_a_name = cx_name + "-A"; + endp_b_name = cx_name + "-B"; + self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_endp[endp_a_name] = endp_a_name; + self.created_endp[endp_b_name] = endp_b_name; endp_side_a = { - "alias": side_a_name + "-A", - "shelf": 1, + "alias": endp_a_name, + "shelf": side_a_shelf, "resource": side_a_resource, "port": side_a_info[2], "type": endp_type, @@ -806,8 +792,8 @@ class L3CXProfile(LFCliBase): "ip_port": -1 } endp_side_b = { - "alias": side_a_name + "-B", - "shelf": 1, + "alias": endp_b_name, + "shelf": side_b_shelf, "resource": side_b_resource, "port": side_b_info[2], "type": endp_type, @@ -826,7 +812,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": side_a_name + "-A", + "name": endp_a_name, "flag": "autohelper", "val": 1 } @@ -834,7 +820,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": side_a_name + "-B", + "name": endp_b_name, "flag": "autohelper", "val": 1 } @@ -844,8 +830,8 @@ class L3CXProfile(LFCliBase): data = { "alias": cx_name, "test_mgr": "default_tm", - "tx_endp": side_a_name + "-A", - "rx_endp": side_a_name + "-B" + "tx_endp": endp_a_name, + "rx_endp": endp_b_name, } #pprint(data) cx_post_data.append(data) @@ -868,11 +854,15 @@ class L3CXProfile(LFCliBase): side_b_resource = side_b_info[1] side_b_name = side_b_info[2] - cx_name = "%s%s" % (self.name_prefix, port_name) - self.created_cx[ cx_name ] = [side_a_name + "-A", side_a_name + "-B"] + cx_name = "%s%s-%i" % (self.name_prefix, port_name, len(self.created_cx)) + endp_a_name = cx_name + "-A"; + endp_b_name = ex_name + "-B"; + self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_endp[endp_a_name] = endp_a_name; + self.created_endp[endp_b_name] = endp_b_name; endp_side_a = { - "alias": side_b_name + "-A", - "shelf": 1, + "alias": endp_a_name, + "shelf": side_a_shelf, "resource": side_a_resource, "port": side_a_info[2], "type": endp_type, @@ -883,8 +873,8 @@ class L3CXProfile(LFCliBase): "ip_port": -1 } endp_side_b = { - "alias": side_b_name + "-B", - "shelf": 1, + "alias": endp_b_name, + "shelf": side_b_shelf, "resource": side_b_resource, "port": side_b_info[2], "type": endp_type, @@ -903,7 +893,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": side_b_name + "-A", + "name": endp_a_name, "flag": "autohelper", "val": 1 } @@ -911,7 +901,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": side_b_name + "-B", + "name": enb, "flag": "autohelper", "val": 1 } @@ -920,8 +910,8 @@ class L3CXProfile(LFCliBase): data = { "alias": cx_name, "test_mgr": "default_tm", - "tx_endp": side_b_name + "-A", - "rx_endp": side_b_name + "-B" + "tx_endp": endp_a_name, + "rx_endp": endp_b_name, } cx_post_data.append(data) timer_post_data.append({ @@ -953,6 +943,7 @@ class L4CXProfile(LFCliBase): self.requests_per_ten = 600 self.local_realm = local_realm self.created_cx = {} + self.created_endp = [] def check_errors(self, debug=False): fields_list = ["!conn", "acc.+denied", "bad-proto", "bad-url", "other-err", "total-err", "rslv-p", "rslv-h", @@ -1612,7 +1603,7 @@ class StationProfile: self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.desired_add_sta_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.number_template = number_template_ - self.station_names = [] + self.station_names = [] # eids self.add_sta_data = { "shelf": 1, "resource": 1, @@ -1771,63 +1762,60 @@ class StationProfile: json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) - def cleanup(self, resource, desired_stations=None, delay=0.03): + def cleanup(self, desired_stations=None, delay=0.03): print("Cleaning up stations") + req_url = "/cli-json/rm_vlan" data = { "shelf": 1, - "resource": resource, + "resource": 1, "port": None } - if (desired_stations is not None): - if len(desired_stations) < 1: - print("No stations requested for cleanup, returning.") - return - names = ','.join(desired_stations) - current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) - if current_stations is None: - return - if "interfaces" in current_stations: - for station in current_stations['interfaces']: - for eid,info in station.items(): - data["port"] = info["alias"] - self.local_realm.json_post(req_url, data, debug_=self.debug) - time.sleep(delay) - - if "interface" in current_stations: - data["port"] = current_stations["interface"]["alias"] - self.local_realm.json_post(req_url, data, debug_=self.debug) - + if (desired_stations is None): + return + if len(desired_stations) < 1: return - names = ','.join(self.station_names) - current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) - if current_stations is None or current_stations['interfaces'] is None: - print("No stations to clean up") - return + del_count = len(desired_stations) - if "interfaces" in current_stations: - for station in current_stations['interfaces']: - for eid,info in station.items(): - data["port"] = info["alias"] + # First, request remove on the list. + for port_eid in desired_stations: + eid = self.name_to_eid(port_eid) + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] + self.local_realm.json_post(req_url, data, debug_=self.debug) + time.sleep(delay) + + # And now see if they are gone + count = 0; + while count < (del_count + 10): + found_one = False + for port_eid in desired_stations: + eid = self.name_to_eid(port_eid) + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] + current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) + if not current_stations is None: + found_one = True + # Try again to delete + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] self.local_realm.json_post(req_url, data, debug_=self.debug) time.sleep(delay) - - if "interface" in current_stations: - data["port"] = current_stations["interface"]["alias"] - self.local_realm.json_post(req_url, data, debug_=self.debug) - + if not found_one: + return + count = count + 1 + time.sleep(1) # Checks for errors in initialization values and creates specified number of stations using init parameters - def create(self, resource, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=True): - # try: - # resource = resource_radio[0: resource_radio.index(".")] - # name = resource_radio[resource_radio.index(".") + 1:] - # if name.index(".") >= 0: - # radio_name = name[name.index(".")+1 : ] - # print("Building %s on radio %s.%s" % (num_stations, resource, radio_name)) - # except ValueError as e: - # print(e) + def create(self, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=True, sleep_time=2): + radio_eid = self.local_realm.name_to_eid(radio) + radio_shelf = radio_eid[0] + radio_resource = radio_eid[1] + radio_port = radio_eid[2] if self.use_ht160: self.desired_add_sta_flags.append("ht160_enable") @@ -1849,9 +1837,9 @@ class StationProfile: # create stations down, do set_port on them, then set stations up self.add_sta_data["flags"] = self.add_named_flags(self.desired_add_sta_flags, add_sta.add_sta_flags) self.add_sta_data["flags_mask"] = self.add_named_flags(self.desired_add_sta_flags_mask, add_sta.add_sta_flags) - self.add_sta_data["radio"] = radio + self.add_sta_data["radio"] = radio_port - self.add_sta_data["resource"] = resource + self.add_sta_data["resource"] = radio_resource self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, set_port.set_port_current_flags) self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags, @@ -1860,13 +1848,14 @@ class StationProfile: # re-use inside a loop, reducing the number of object creations add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") - self.station_names = [] - if num_stations > 0: - self.station_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) - else: - self.station_names = sta_names_ - if (len(self.station_names) >= 15) or (suppress_related_commands_ == True): + my_sta_names = []; + if num_stations > 0: + my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) + else: + my_sta_names = sta_names_ + + if (len(my_sta_names) >= 15) or (suppress_related_commands_ == True): self.add_sta_data["suppress_preexec_cli"] = "yes" self.add_sta_data["suppress_preexec_method"] = 1 self.set_port_data["suppress_preexec_cli"] = "yes" @@ -1875,10 +1864,15 @@ class StationProfile: num = 0 #pprint(self.station_names) #exit(1) - for name in self.station_names: + for name in my_sta_names: self.set_port_data["port"] = name num += 1 + self.add_sta_data["shelf"] = radio_shelf + self.add_sta_data["resource"] = radio_resource + self.add_sta_data["radio"] = radio_port self.add_sta_data["sta_name"] = name + + self.station_names.append("%s.%s.%s" %(radio_shelf, radio_resource, name)) add_sta_r.addPostData(self.add_sta_data) if debug: print("- 381 - %s- - - - - - - - - - - - - - - - - - " % name) @@ -1892,12 +1886,12 @@ class StationProfile: json_response = add_sta_r.jsonPost(debug) # time.sleep(0.03) - time.sleep(2) + time.sleep(sleep_time) set_port_r.addPostData(self.set_port_data) json_response = set_port_r.jsonPost(debug) time.sleep(0.03) - LFUtils.waitUntilPortsAppear(resource, self.lfclient_url, self.station_names) + LFUtils.waitUntilPortsAppear(self.lfclient_url, self.station_names) # and set ports up if dry_run: diff --git a/py-scripts/__init__.py b/py-scripts/__init__.py old mode 100644 new mode 100755 diff --git a/py-scripts/cicd_TipIntegration.py b/py-scripts/cicd_TipIntegration.py old mode 100644 new mode 100755 diff --git a/py-scripts/cicd_testrail.py b/py-scripts/cicd_testrail.py old mode 100644 new mode 100755 diff --git a/py-scripts/cicd_testrailAndInfraSetup.py b/py-scripts/cicd_testrailAndInfraSetup.py old mode 100644 new mode 100755 diff --git a/py-scripts/test_l3_WAN_LAN.py b/py-scripts/test_l3_WAN_LAN.py old mode 100644 new mode 100755 diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py old mode 100644 new mode 100755 index 0965778b..d8f6cffe --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -18,8 +18,8 @@ import time import datetime class L3VariableTimeLongevity(LFCliBase): - def __init__(self, host, port, endp_type, is_multicast, side_b, radios, radio_name_list, number_of_stations_per_radio_list, - ssid_list, ssid_password_list, security, station_lists, name_prefix, resource=1, + def __init__(self, host, port, endp_types, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", @@ -29,18 +29,15 @@ class L3VariableTimeLongevity(LFCliBase): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port - self.endp_type = endp_type - self.is_multicast = is_multicast + self.endp_types = endp_types.split() self.side_b = side_b self.ssid_list = ssid_list self.ssid_password_list = ssid_password_list self.station_lists = station_lists - self.security = security + self.ssid_security_list = ssid_security_list self.number_template = number_template - self.resource = resource self.name_prefix = name_prefix self.test_duration = test_duration - self.cx_stations_lists = station_lists self.radios = radios # from the command line self.radio_list = radio_name_list self.number_of_stations_per_radio_list = number_of_stations_per_radio_list @@ -55,42 +52,37 @@ class L3VariableTimeLongevity(LFCliBase): self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = ssid_list[index] self.station_profile.ssid_pass = ssid_password_list[index] - self.station_profile.security = self.security + self.station_profile.security = ssid_security_list[index] self.station_profile.number_template = self.number_template self.station_profile.mode = 0 self.station_profiles.append(self.station_profile) index += 1 - if is_multicast: - self.multicast_profile.host = self.host - self.cx_profile.host = self.host - self.cx_profile.port = self.port - self.cx_profile.name_prefix = self.name_prefix - self.cx_profile.side_a_min_bps = 0 - self.cx_profile.side_a_max_bps = 0 - self.cx_profile.side_b_min_bps = side_b_min_rate - self.cx_profile.side_b_max_bps = side_b_max_rate - - - else: - self.cx_profile.host = self.host - self.cx_profile.port = self.port - self.cx_profile.name_prefix = self.name_prefix - self.cx_profile.side_a_min_bps = side_a_min_rate - self.cx_profile.side_a_max_bps = side_a_max_rate - self.cx_profile.side_b_min_bps = side_b_min_rate - self.cx_profile.side_b_max_bps = side_b_max_rate + self.multicast_profile.host = self.host + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = side_a_min_rate + self.cx_profile.side_a_max_bps = side_a_max_rate + self.cx_profile.side_b_min_bps = side_b_min_rate + self.cx_profile.side_b_max_bps = side_b_max_rate def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) - cx_rx_map = {} - for cx_name in cx_list['endpoint']: - if cx_name != 'uri' and cx_name != 'handler': - for item, value in cx_name.items(): - for value_name, value_rx in value.items(): - if value_name == 'rx bytes': - cx_rx_map[item] = value_rx - return cx_rx_map + endp_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) + endp_rx_map = {} + our_endps = {} + for e in self.multicast_profile.get_mc_names(): + our_endps[e] = e; + for e in self.cx_profile.created_endp.keys(): + our_endps[e] = e; + for endp_name in endp_list['endpoint']: + if endp_name != 'uri' and endp_name != 'handler': + for item, value in endp_name.items(): + if item in our_endps: + for value_name, value_rx in value.items(): + if value_name == 'rx bytes': + endp_rx_map[item] = value_rx + return endp_rx_map def __compare_vals(self, old_list, new_list): passes = 0 @@ -98,9 +90,14 @@ class L3VariableTimeLongevity(LFCliBase): if len(old_list) == len(new_list): for item, value in old_list.items(): expected_passes += 1 - if new_list[item] > old_list[item]: + if item.startswith("mtx"): + # We ignore the mcast transmitter. + # This is a hack based on naming and could be improved. passes += 1 - print(item, new_list[item], old_list[item], passes, expected_passes) + else: + if new_list[item] > old_list[item]: + passes += 1 + print(item, new_list[item], old_list[item], passes, expected_passes) if passes == expected_passes: return True @@ -111,50 +108,32 @@ class L3VariableTimeLongevity(LFCliBase): def start(self, print_pass=False, print_fail=False): print("Bringing up stations") - up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.side_b) - self.local_realm.json_post("/cli-json/set_port", up_request) + up_request = self.local_realm.admin_up(self.side_b) for station_profile in self.station_profiles: - print("Bringing up station {}".format(station_profile)) - station_profile.admin_up(self.resource) - - if self.is_multicast: - self.multicast_profile.admin_up_mc_tx(self.resource, self.side_b) - + for sta in station_profile.station_names: + print("Bringing up station %s"%(sta)) + up_request = self.local_realm.admin_up(sta) temp_stations_list = [] - for station_list in self.station_lists: - temp_station_list = station_list.copy() - temp_stations_list.append(temp_station_list) - temp_stations_list.append(self.side_b) - if self.local_realm.wait_for_ip(self.resource, temp_station_list,timeout_sec=120): - print("ip's aquired") - else: - print("print failed to get IP's") + temp_stations_list.append(self.side_b) + for station_profile in self.station_profiles: + temp_stations_list.extend(station_profile.station_names.copy()) - temp_station_list = [] - if self.is_multicast: - for station_list in self.station_lists: - for station in range(len(station_list)): - temp_station_list.append(str(self.resource) + "." + station_list[station]) - self.multicast_profile.start_mc_rx(side_rx=temp_station_list) - self.multicast_profile.start_mc_tx(side_tx=self.side_b) - + if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): + print("ip's aquired") else: - self.cx_profile.start_cx() + print("print failed to get IP's") + + self.multicast_profile.start_mc() + self.cx_profile.start_cx() cur_time = datetime.datetime.now() old_rx_values = self.__get_rx_values() - filtered_old_rx_values = [] - if self.is_multicast: - for rx_value in old_rx_values: - for station in self.station_lists: - if rx_value in station: - filtered_old_rx_values += rx_value - else: - filtered_old_rx_values = old_rx_values end_time = self.local_realm.parse_time(self.test_duration) + cur_time + print("Monitoring throughput for duration: %s"%(self.test_duration)) + passes = 0 expected_passes = 0 while cur_time < end_time: @@ -164,17 +143,9 @@ class L3VariableTimeLongevity(LFCliBase): time.sleep(1) new_rx_values = self.__get_rx_values() - filtered_new_rx_values = [] - if self.is_multicast: - for rx_value in new_rx_values: - for station in self.station_lists: - if rx_value in station: - filtered_new_rx_values += rx_value - else: - filtered_new_rx_values = new_rx_values expected_passes += 1 - if self.__compare_vals(filtered_old_rx_values, filtered_new_rx_values): + if self.__compare_vals(old_rx_values, new_rx_values): passes += 1 else: self._fail("FAIL: Not all stations increased traffic", print_fail) @@ -187,96 +158,59 @@ class L3VariableTimeLongevity(LFCliBase): def stop(self): self.cx_profile.stop_cx() + self.multicast_profile.stop_mc() for station_list in self.station_lists: for station_name in station_list: - data = LFUtils.portDownRequest(1, station_name) - url = "cli-json/set_port" - self.json_post(url, data) + self.local_realm.admin_down(station_name) - def cleanup(self, resource): - resource = 1 - data = { - "name":"BLANK", - "action":"overwrite" - } - url = "cli-json/load" - self.json_post(url, data) - #remove_all_endpoints = True - #self.local_realm.remove_all_cxs(remove_all_endpoints) - #self.local_realm.remove_all_stations(resource) - + def cleanup(self): + self.cx_profile.cleanup() + self.multicast_profile.cleanup() + for station_profile in self.station_profiles: + station_profile.cleanup() def build(self): + # This is too fragile and limitted, let outside logic configure the upstream port as needed. + #try: + # eid = self.local_realm.name_to_eid(self.side_b) + # data = LFUtils.port_dhcp_up_request(eid[1], eid[2]) + # self.json_post("/cli-json/set_port", data) + #except: + # print("LFUtils.port_dhcp_up_request didn't complete ") + # print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(self.side_b)) - # refactor in LFUtils.port_zero_request() - resource = 1 - - data ={ - 'shelf':1, - 'resource':1, - 'port':'eth1', - 'ip_addr':'0.0.0.0', - 'netmask':'0.0.0.0', - 'gateway':'0.0.0.0', - 'current_flags':0, - 'interest':402653212 - } - - url = "cli-json/set_port" - self.json_post(url, data) - - - # refactor into LFUtils - data ={ - "shelf":1, - "resource": resource, - "port":"br0", - "network_devs":"eth1", - "br_flags":1 - } - url = "cli-json/add_br" - self.json_post(url, data) - - - try: - data = LFUtils.port_dhcp_up_request(resource, self.side_b) - self.json_post("/cli-json/set_port", data) - except: - print("LFUtils.port_dhcp_up_request didn't complete ") - print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(self.side_b)) - - resource = 1 index = 0 for station_profile in self.station_profiles: station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) station_profile.set_number_template(station_profile.number_template) print("Creating stations") - temp_station_list = [] - index = 0 + index = 0 for station_list in self.station_lists: - for station in range(len(station_list)): - temp_station_list.append(str(self.resource) + "." + station_list[station]) - station_profile.create(resource=1, radio=self.radio_list[index], sta_names_=station_list, debug=True ) + station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=True, sleep_time=0) index += 1 - if self.is_multicast: - self.multicast_profile.create_mc_tx(self.side_b) - self.multicast_profile.create_mc_rx(side_rx=temp_station_list) - else: - self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) + + for etype in self.endp_types: + if etype == "mc_udp" or etype == "mc_udp6": + self.multicast_profile.create_mc_tx(etype, self.side_b, etype) + self.multicast_profile.create_mc_rx(etype, side_rx=station_profle.station_names) + else: + self.cx_profile.create(endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0) + self._pass("PASS: Stations build finished") -def valid_endp_type(endp_type): - valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] - if str(endp_type) in valid_endp_type: - return endp_type - else: - print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6') - exit(1) +def valid_endp_types(endp_type): + etypes = endp_type.split() + for endp_type in etypes: + valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] + if not (str(endp_type) in valid_endp_type): + print('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) + exit(1) def main(): lfjson_host = "localhost" lfjson_port = 8080 + endp_types = "lf_udp" parser = argparse.ArgumentParser( prog='test_l3_longevity.py', @@ -287,8 +221,7 @@ def main(): 1. Polling interval for checking traffic is fixed at 1 minute 2. The test will exit when traffic has not changed on a station for 1 minute 3. The tx/rx rates are fixed at 256000 bits per second - 4. Security is fixed at WPA2 - 5. Maximum stations per radio is 64 + 4. Maximum stations per radio is 64 ''', description='''\ @@ -302,10 +235,10 @@ Basic Idea: create stations, create traffic between upstream port and stations, Scripts are executed from: ./lanforge/py-scripts - Stations start counting form zero, thus stations count from zero - number of las + Stations start counting from zero, thus stations count from zero - number of las Generic command layout: -python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio +python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio @@ -333,26 +266,30 @@ Note: multiple --radio switches may be entered up to the number of radios avai 5. Radio #2 wiphy1 has 64 stations, ssid = candelaTech-wpa2-x2048-5-3, ssid password = candelaTech-wpa2-x2048-5-3 Command: - python3 .\\test_l3_longevity.py --test_duration 4m --endp_type lf_tcp --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 + python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 ''') + parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') - parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type lf_udp, default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6', - default='lf_udp',type=valid_endp_type) + parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', + default='lf_udp', type=valid_endp_types) parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') requiredNamed = parser.add_argument_group('required arguments') - requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('', '','',''), - help ='--radio ',required=True) + requiredNamed.add_argument('-r', '--radio', action='append', nargs=5, metavar=('', '', '', '', 'security'), + help ='--radio ', required=True) args = parser.parse_args() if args.test_duration: test_duration = args.test_duration if args.endp_type: - endp_type = args.endp_type + endp_types = args.endp_type + + if args.mgr: + lfjson_host = args.mgr if args.upstream_port: side_b = args.upstream_port @@ -360,12 +297,11 @@ Note: multiple --radio switches may be entered up to the number of radios avai if args.radio: radios = args.radio - is_multicast = False - radio_offset = 0 number_of_stations_offset = 1 ssid_offset = 2 ssid_password_offset = 3 + ssid_security_offset = 4 MAX_NUMBER_OF_STATIONS = 64 @@ -373,11 +309,8 @@ Note: multiple --radio switches may be entered up to the number of radios avai number_of_stations_per_radio_list = [] ssid_list = [] ssid_password_list = [] + ssid_security_list = [] - if endp_type in ['mc_udp','mc_udp6']: - is_multicast = True - - index = 0 for radio in radios: radio_name = radio[radio_offset] radio_name_list.append(radio_name) @@ -385,9 +318,12 @@ Note: multiple --radio switches may be entered up to the number of radios avai number_of_stations_per_radio_list.append(number_of_stations_per_radio) ssid = radio[ssid_offset] ssid_list.append(ssid) - ssid_password = radio[ssid_password_offset] - ssid_password_list.append(ssid_password) - index += 1 + if (len(radio) >= (ssid_password_offset - 1)): + ssid_password_list.append(radio[ssid_password_offset]) + ssid_security_list.append(radio[ssid_security_offset]) + else: + ssid_password_list.append("NA") + ssid_security_list.append("open") index = 0 station_lists = [] @@ -399,38 +335,43 @@ Note: multiple --radio switches may be entered up to the number of radios avai station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) station_lists.append(station_list) index += 1 + ip_var_test = L3VariableTimeLongevity(lfjson_host, lfjson_port, number_template="00", station_lists= station_lists, - name_prefix="var_time", - endp_type=endp_type, - is_multicast=is_multicast, + name_prefix="LT-", + endp_types=endp_types, side_b=side_b, radios=radios, radio_name_list=radio_name_list, number_of_stations_per_radio_list=number_of_stations_per_radio_list, ssid_list=ssid_list, ssid_password_list=ssid_password_list, - resource=1, - security="wpa2", test_duration=test_duration, + ssid_security_list=ssid_security_list, test_duration=test_duration, side_a_min_rate=256000, side_b_min_rate=256000) - ip_var_test.cleanup(station_list) + # This cleanup does not work because objects in the profiles are not yet created. + # Not sure the best way to resolve this currently. --Ben + ip_var_test.cleanup() + ip_var_test.build() if not ip_var_test.passes(): + print("build step failed.") print(ip_var_test.get_fail_message()) exit(1) ip_var_test.start(False, False) ip_var_test.stop() if not ip_var_test.passes(): + print("stop test failed") print(ip_var_test.get_fail_message()) exit(1) + + print("Pausing 30 seconds after run for manual inspection before we clean up.") time.sleep(30) - ip_var_test.cleanup(station_list) + ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes") - if __name__ == "__main__": main() diff --git a/py-scripts/test_l3_unicast_traffic_gen.py b/py-scripts/test_l3_unicast_traffic_gen.py old mode 100644 new mode 100755 diff --git a/py-scripts/test_open_connection.py b/py-scripts/test_open_connection.py old mode 100644 new mode 100755 diff --git a/py-scripts/test_wanlink.py b/py-scripts/test_wanlink.py old mode 100644 new mode 100755 From 5bf449c3f7c30eebc278b3e997aa48fd0832aee7 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 5 Aug 2020 13:29:10 -0700 Subject: [PATCH 074/134] Added PortUtils class, set_ftp method WIP --- py-json/realm.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/py-json/realm.py b/py-json/realm.py index 4168ce53..186233b5 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1575,6 +1575,29 @@ class VAPProfile(LFCliBase): data["port"] = current_stations["interface"]["alias"] self.local_realm.json_post(req_url, data, debug_=self.debug) +class PortUtils(LFCliBase): + def __init__(self, local_realm): + self.local_realm = local_realm + + def set_ftp(self, port_name="", resource=1, on=False): + if port_name != "": + data = { + "shelf": 1, + "resource": resource, + "port": port_name, + "current_flags": 0, + "interest": 0 + } + + if on: + data["current_flags"] = 0x400000000000 + data["interest"] = 0x10000000 + else: + data["interest"] = 0x10000000 + + self.local_realm.json_post("cli-json/set_port", data) + else: + raise ValueError("Port name required") # use the station profile to set the combination of features you want on your stations # once this combination is configured, build the stations with the build(resource, radio, number) call From f717676f358d48d8111ccc12bbd1a16c3d12ac55 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 5 Aug 2020 14:19:30 -0700 Subject: [PATCH 075/134] Fixed StationProfile use of name_to_eid, now uses realm method --- py-json/realm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 186233b5..53c7cc0c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1803,7 +1803,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: - eid = self.name_to_eid(port_eid) + eid = self.local_realm.name_to_eid(port_eid) data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] @@ -1811,11 +1811,11 @@ class StationProfile: time.sleep(delay) # And now see if they are gone - count = 0; + count = 0 while count < (del_count + 10): found_one = False for port_eid in desired_stations: - eid = self.name_to_eid(port_eid) + eid = self.local_realm.name_to_eid(port_eid) data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] @@ -1872,7 +1872,7 @@ class StationProfile: add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") - my_sta_names = []; + my_sta_names = [] if num_stations > 0: my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) else: @@ -1895,7 +1895,7 @@ class StationProfile: self.add_sta_data["radio"] = radio_port self.add_sta_data["sta_name"] = name - self.station_names.append("%s.%s.%s" %(radio_shelf, radio_resource, name)) + self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name)) add_sta_r.addPostData(self.add_sta_data) if debug: print("- 381 - %s- - - - - - - - - - - - - - - - - - " % name) From db4a5b7728466c48bb1841a4a0485c5167a3dba0 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 5 Aug 2020 15:25:22 -0700 Subject: [PATCH 076/134] json: Add methods to wait for cx, endp to be found. This lets scripts wait until we are sure the system can handle further work. Ensure we print out error in case the URL processing logic detects and error and plans to exit. --- py-json/LANforge/LFRequest.py | 2 +- py-json/LANforge/LFUtils.py | 42 ++++++++++++++- py-json/LANforge/lfcli_base.py | 2 +- py-json/realm.py | 95 +++++++++++++++++++++++++++++---- py-scripts/test_l3_longevity.py | 15 ++++-- 5 files changed, 138 insertions(+), 18 deletions(-) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index 88c6ec57..b561c828 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -137,7 +137,7 @@ class LFRequest: response_json_list_.append(j) return responses[0] except urllib.error.HTTPError as error: - if show_error: + if show_error or die_on_error_ or (error.code != 404): print("----- LFRequest::jsonPost:138 HTTPError: --------------------------------------------") print("<%s> HTTP %s: %s"%(request.get_full_url(), error.code, error.reason, )) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 9ccf90fd..95c122c3 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -400,7 +400,6 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu """ print("Waiting until ports appear...") found_stations = [] - sleep(2) port_url = "/port/1" ncshow_url = "/cli-form/nc_show_ports" if base_url.endswith('/'): @@ -432,6 +431,47 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu print("These stations appeared: " + ", ".join(found_stations)) return +def wait_until_endps(base_url="http://localhost:8080", endp_list=(), debug=False): + """ + + :param base_url: + :param port_list: + :param debug: + :return: + """ + print("Waiting until endpoints appear...") + found_endps = [] + port_url = "/port/1" + ncshow_url = "/cli-form/show_endp" + if base_url.endswith('/'): + port_url = port_url[1:] + ncshow_url = ncshow_url[1:] + + while len(found_stations) < len(port_list): + found_stations = [] + for port_eid in port_list: + + eid = name_to_eid(port_eid) + shelf = eid[0] + resource_id = eid[1] + port_name = eid[2] + + uri = "%s/%s/%s" % (port_url, resource_id, port_name) + lf_r = LFRequest.LFRequest(base_url, uri) + json_response = lf_r.getAsJson(debug_=False) + if (json_response != None): + found_stations.append(port_name) + else: + lf_r = LFRequest.LFRequest(base_url, ncshow_url) + lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "flags": 1}) + lf_r.formPost() + if (len(found_stations) < len(port_list)): + sleep(2) + + if debug: + print("These stations appeared: " + ", ".join(found_stations)) + return + def removePort(resource, port_name, baseurl="http://localhost:8080/", debug=False): if debug: diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 560f6f00..ec9918b0 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -196,7 +196,7 @@ class LFCliBase: # use this inside the class to log a failure result def _fail(self, message, print_=False): self.test_results.append(self.fail_pref + message) - if print_: + if print_ or self.exit_on_fail: print(self.fail_pref + message) if self.exit_on_fail: sys.exit(1) diff --git a/py-json/realm.py b/py-json/realm.py index 4168ce53..6a2020bc 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -191,6 +191,53 @@ class Realm(LFCliBase): response = super().json_get("/cx") return response + def waitUntilEndpsAppear(self, these_endp): + wait_more = True; + count = 0 + while wait_more: + wait_more = False + endp_list = self.json_get("/endp") + found_endps = {} + if endp_list is not None: + endp_list = list(endp_list['endpoint']) + for endp_name in range(len(endp_list)): + name = list(endp_list[endp_name])[0] + found_endps[name] = name + + for req in these_endp: + if not req in found_endps: + print("Waiting on endpoint: %s"%(req)) + wait_more = True + count += 1 + if (count > 100): + break + + return not wait_more + + def waitUntilCxsAppear(self, these_cx): + wait_more = True; + count = 0 + while wait_more: + wait_more = False + found_cxs = {} + cx_list = list(self.cx_list()) + not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] + if cx_list is not None: + for cx_name in cx_list: + if cx_name in not_cx: + continue + found_cxs[cx_name] = cx_name + + for req in these_cx: + if not req in found_cxs: + print("Waiting on CX: %s"%(req)) + wait_more = True + count += 1 + if (count > 100): + break + + return not wait_more + # Returns map of all stations with port+type == WIFI-STATION def station_map(self): response = super().json_get("/port/list?fields=_links,alias,device,port+type") @@ -521,6 +568,7 @@ class MULTICASTProfile(LFCliBase): debug_=True for endp_name in self.get_mc_names(): + print("Starting mcast endpoint: %s"%(endp_name)) json_data = { "endp_name":endp_name } @@ -558,7 +606,7 @@ class MULTICASTProfile(LFCliBase): side_tx_shelf = side_tx_info[0] side_tx_resource = side_tx_info[1] side_tx_port = side_tx_info[2] - side_tx_name = "mtx-%s-%i-"%(side_tx_port, len(created_mc)) + side_tx_name = "mtx-%s-%i-"%(side_tx_port, len(self.created_mc)) json_data = [] @@ -598,18 +646,24 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - created_mc[side_tx_name] = side_tx_name + self.created_mc[side_tx_name] = side_tx_name + + these_endp = [side_tx_name] + self.local_realm.waitUntilEndpsAppear(these_endp) + def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True + these_endp = [] + for port_name in side_rx: side_rx_info = self.local_realm.name_to_eid(port_name) side_rx_shelf = side_rx_info[0] side_rx_resource = side_rx_info[1] side_rx_port = side_rx_info[2] - side_rx_name = "mrx-%s-%i-"%(side_tx_port, len(created_mc)) + side_rx_name = "mrx-%s-%i-"%(side_rx_port, len(self.created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { 'alias':side_rx_name, @@ -644,8 +698,10 @@ class MULTICASTProfile(LFCliBase): url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - created_mc[side_rx_name] = side_rx_name + self.created_mc[side_rx_name] = side_rx_name + these_endp.append(side_rx_name) + self.local_realm.waitUntilEndpsAppear(these_endp) def to_string(self): pprint.pprint(self) @@ -732,6 +788,7 @@ class L3CXProfile(LFCliBase): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: for cx_name in self.created_cx.keys(): + print("Cleaning cx: %s"%(cx_name)) req_url = "cli-json/rm_cx" data = { "test_mgr": "default_tm", @@ -740,9 +797,11 @@ class L3CXProfile(LFCliBase): self.json_post(req_url, data) for side in range(len(self.created_cx[cx_name])): + ename = self.created_cx[cx_name][side] + print("Cleaning endpoint: %s"%(ename)) req_url = "cli-json/rm_endp" data = { - "endp_name": self.created_cx[cx_name][side] + "endp_name": ename } self.json_post(req_url, data) @@ -752,6 +811,9 @@ class L3CXProfile(LFCliBase): cx_post_data = [] timer_post_data = [] + these_endp = [] + these_cx = [] + # print(self.side_a_min_rate, self.side_a_max_rate) # print(self.side_b_min_rate, self.side_b_max_rate) if (self.side_a_min_bps is None) \ @@ -779,6 +841,9 @@ class L3CXProfile(LFCliBase): self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name; self.created_endp[endp_b_name] = endp_b_name; + these_cx.append(cx_name) + these_endp.append(endp_a_name) + these_endp.append(endp_b_name) endp_side_a = { "alias": endp_a_name, "shelf": side_a_shelf, @@ -860,6 +925,9 @@ class L3CXProfile(LFCliBase): self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name; self.created_endp[endp_b_name] = endp_b_name; + these_cx.append(cx_name) + these_endp.append(endp_a_name) + these_endp.append(endp_b_name) endp_side_a = { "alias": endp_a_name, "shelf": side_a_shelf, @@ -927,9 +995,12 @@ class L3CXProfile(LFCliBase): url = "/cli-json/add_cx" self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) #print(" napping %f sec"%sleep_time, end='') - time.sleep(sleep_time) + #time.sleep(sleep_time) #print("") + self.local_realm.waitUntilEndpsAppear(these_endp) + self.local_realm.waitUntilCxsAppear(these_cx) + def to_string(self): pprint.pprint(self) @@ -1772,19 +1843,21 @@ class StationProfile: "port": None } if (desired_stations is None): - return + desired_stations = self.station_names; + if len(desired_stations) < 1: + print("ERROR: StationProfile cleanup, list is empty") return del_count = len(desired_stations) # First, request remove on the list. for port_eid in desired_stations: - eid = self.name_to_eid(port_eid) + eid = self.local_realm.name_to_eid(port_eid) data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] - self.local_realm.json_post(req_url, data, debug_=self.debug) + self.local_realm.json_post(req_url, data, debug_=True) #self.debug) time.sleep(delay) # And now see if they are gone @@ -1792,7 +1865,7 @@ class StationProfile: while count < (del_count + 10): found_one = False for port_eid in desired_stations: - eid = self.name_to_eid(port_eid) + eid = self.local_realm.name_to_eid(port_eid) data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] @@ -1803,7 +1876,7 @@ class StationProfile: data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] - self.local_realm.json_post(req_url, data, debug_=self.debug) + self.local_realm.json_post(req_url, data, debug_=True) #self.debug) time.sleep(delay) if not found_one: return diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index d8f6cffe..73b016de 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -124,10 +124,13 @@ class L3VariableTimeLongevity(LFCliBase): else: print("print failed to get IP's") - self.multicast_profile.start_mc() + print("Starting multicast traffic (if any configured)") + self.multicast_profile.start_mc(debug_=True) + print("Starting layer-3 traffic (if any configured)") self.cx_profile.start_cx() cur_time = datetime.datetime.now() + print("Getting initial values.") old_rx_values = self.__get_rx_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time @@ -191,21 +194,23 @@ class L3VariableTimeLongevity(LFCliBase): index += 1 for etype in self.endp_types: + print("Creating connections for endpoint type: %s"%(etype)) if etype == "mc_udp" or etype == "mc_udp6": self.multicast_profile.create_mc_tx(etype, self.side_b, etype) - self.multicast_profile.create_mc_rx(etype, side_rx=station_profle.station_names) + self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names) else: self.cx_profile.create(endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0) self._pass("PASS: Stations build finished") -def valid_endp_types(endp_type): - etypes = endp_type.split() +def valid_endp_types(_endp_type): + etypes = _endp_type.split() for endp_type in etypes: valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] if not (str(endp_type) in valid_endp_type): print('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) exit(1) + return _endp_type def main(): lfjson_host = "localhost" @@ -336,6 +341,8 @@ Note: multiple --radio switches may be entered up to the number of radios avai station_lists.append(station_list) index += 1 + print("endp-types: %s"%(endp_types)) + ip_var_test = L3VariableTimeLongevity(lfjson_host, lfjson_port, number_template="00", From d8aaab8546726d5de77a9c59f69f70c5a836025d Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 5 Aug 2020 16:16:13 -0700 Subject: [PATCH 077/134] Removed unnecessary usage of resource params, cleanup WIP --- py-scripts/test_ipv4_variable_time.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 22be50b6..ce5d75f1 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -48,6 +48,7 @@ class IPV4VariableTime(LFCliBase): self.station_profile.ssid_pass = self.password self.station_profile.security = self.security self.station_profile.number_template_ = self.number_template + self.station_profile.debug = self.debug self.station_profile.use_ht160 = use_ht160 if self.station_profile.use_ht160: self.station_profile.mode = 9 @@ -95,7 +96,7 @@ class IPV4VariableTime(LFCliBase): self.station_profile.admin_up(self.resource) temp_stas = self.sta_list.copy() temp_stas.append("eth1") - if self.local_realm.wait_for_ip(self.resource, temp_stas): + if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: self._fail("Stations failed to get IPs", print_fail) @@ -138,7 +139,7 @@ class IPV4VariableTime(LFCliBase): def cleanup(self, sta_list): self.cx_profile.cleanup() - self.station_profile.cleanup(self.resource, sta_list) + self.station_profile.cleanup(sta_list) LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) @@ -152,7 +153,7 @@ class IPV4VariableTime(LFCliBase): temp_sta_list = [] for station in range(len(self.sta_list)): temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio=self.radio, sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self.cx_profile.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) self._pass("PASS: Station build finished") @@ -168,7 +169,7 @@ def main(): resource=1, radio="wiphy2", security="wpa2", test_duration="5m", use_ht160=False, - side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=False) + side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=True) ip_var_test.cleanup(station_list) ip_var_test.build() From 5451c724fb0a6622ff41a0ae96934fac213ee4c3 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 5 Aug 2020 16:21:32 -0700 Subject: [PATCH 078/134] realm: Fix problem with waiting for IP address. Something I broke earlier. longevity works fairly well now it seems. --- py-json/realm.py | 46 +++++++++++++++++++-------------- py-scripts/test_l3_longevity.py | 28 +++++++++++++------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6a2020bc..fb7c0460 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -370,7 +370,7 @@ class Realm(LFCliBase): def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): print("Waiting for ips...") - print(station_list) + #print(station_list) if (station_list is None) or (len(station_list) < 1): raise ValueError("wait_for_ip: expects non-empty list of ports") @@ -380,28 +380,31 @@ class Realm(LFCliBase): wait_more = False for sta_eid in station_list: - print("sta-eid: %s"%(sta_eid)) + print("checking sta-eid: %s"%(sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % (eid[0], eid[1], eid[2])) + #pprint(response) + if (response is None) or ("interface" not in response): print("station_list: incomplete response:") pprint(response) + wait_more = True + break + + if ipv4: + v = response['interface'] + if v['ip'] == '0.0.0.0': + wait_more = True + print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + if ipv6: + v = response['interface'] + if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ + and v['ipv6 address'] != 'AUTO': + wait_more = True + print("Waiting for port %s to get IPv6 Address."%(sta_eid)) - if ipv4: - for x in range(len(response['interface'])): - for k, v in response['interface'][x].items(): - if v['ip'] == '0.0.0.0': - wait_more = True - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) - if ipv6: - for x in range(len(response['interface'])): - for k, v in response['interface'][x].items(): - if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ - and v['ipv6 address'] != 'AUTO': - wait_more = True - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) if wait_more: time.sleep(1) timeout_sec -= 1 @@ -577,7 +580,7 @@ class MULTICASTProfile(LFCliBase): pass - def stop_mc(self): + def stop_mc(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True @@ -590,7 +593,10 @@ class MULTICASTProfile(LFCliBase): pass - def cleanup(self): + def cleanup(self, suppress_related_commands=None, debug_ = False): + if self.debug: + debug_=True + for endp_name in self.get_mc_names(): json_data = { "endp_name":endp_name @@ -606,7 +612,7 @@ class MULTICASTProfile(LFCliBase): side_tx_shelf = side_tx_info[0] side_tx_resource = side_tx_info[1] side_tx_port = side_tx_info[2] - side_tx_name = "mtx-%s-%i-"%(side_tx_port, len(self.created_mc)) + side_tx_name = "mtx-%s-%i"%(side_tx_port, len(self.created_mc)) json_data = [] @@ -619,7 +625,7 @@ class MULTICASTProfile(LFCliBase): 'type':endp_type, 'ip_port':-1, 'is_rate_bursty': - 'NO','min_rate':4000000, + 'NO','min_rate':256000, 'max_rate':0, 'is_pkt_sz_random':'NO', 'min_pkt':1472, @@ -663,7 +669,7 @@ class MULTICASTProfile(LFCliBase): side_rx_shelf = side_rx_info[0] side_rx_resource = side_rx_info[1] side_rx_port = side_rx_info[2] - side_rx_name = "mrx-%s-%i-"%(side_rx_port, len(self.created_mc)) + side_rx_name = "mrx-%s-%i"%(side_rx_port, len(self.created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { 'alias':side_rx_name, diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 73b016de..d001bf72 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -19,14 +19,13 @@ import datetime class L3VariableTimeLongevity(LFCliBase): def __init__(self, host, port, endp_types, side_b, radios, radio_name_list, number_of_stations_per_radio_list, - ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, + ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, debug_on, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", - _debug_on=True, _exit_on_error=False, _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + super().__init__(host, port, _debug=debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.endp_types = endp_types.split() @@ -41,7 +40,7 @@ class L3VariableTimeLongevity(LFCliBase): self.radios = radios # from the command line self.radio_list = radio_name_list self.number_of_stations_per_radio_list = number_of_stations_per_radio_list - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) self.cx_profile = self.local_realm.new_l3_cx_profile() self.multicast_profile = self.local_realm.new_multicast_profile() self.station_profiles = [] @@ -89,7 +88,7 @@ class L3VariableTimeLongevity(LFCliBase): expected_passes = 0 if len(old_list) == len(new_list): for item, value in old_list.items(): - expected_passes += 1 + expected_passes +=1 if item.startswith("mtx"): # We ignore the mcast transmitter. # This is a hack based on naming and could be improved. @@ -97,13 +96,18 @@ class L3VariableTimeLongevity(LFCliBase): else: if new_list[item] > old_list[item]: passes += 1 - print(item, new_list[item], old_list[item], passes, expected_passes) + print(item, new_list[item], old_list[item], " Difference: ", new_list[item] - old_list[item]) + else: + print("Failed to increase rx data: ", item, new_list[item], old_list[item]) if passes == expected_passes: return True else: return False else: + print("Old-list length: %i new: %i does not match in compare-vals."%(len(old_list), len(new_list))) + print("old-list:",old_list) + print("new-list:",old_list) return False def start(self, print_pass=False, print_fail=False): @@ -120,7 +124,7 @@ class L3VariableTimeLongevity(LFCliBase): temp_stations_list.extend(station_profile.station_names.copy()) if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): - print("ip's aquired") + print("ip's acquired") else: print("print failed to get IP's") @@ -190,7 +194,7 @@ class L3VariableTimeLongevity(LFCliBase): index = 0 for station_list in self.station_lists: - station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=True, sleep_time=0) + station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=self.debug, sleep_time=0) index += 1 for etype in self.endp_types: @@ -216,6 +220,7 @@ def main(): lfjson_host = "localhost" lfjson_port = 8080 endp_types = "lf_udp" + debug_on = False parser = argparse.ArgumentParser( prog='test_l3_longevity.py', @@ -243,7 +248,7 @@ Basic Idea: create stations, create traffic between upstream port and stations, Stations start counting from zero, thus stations count from zero - number of las Generic command layout: -python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio +python .\\test_l3_longevity.py --test_duration --endp_type --upstream_port --radio --debug Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio @@ -278,6 +283,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') + parser.add_argument('--debug', help='--debug: Enable debugging',default=False) parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', default='lf_udp', type=valid_endp_types) parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') @@ -287,6 +293,8 @@ Note: multiple --radio switches may be entered up to the number of radios avai help ='--radio ', required=True) args = parser.parse_args() + debug_on = args.debug + if args.test_duration: test_duration = args.test_duration @@ -356,7 +364,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai ssid_list=ssid_list, ssid_password_list=ssid_password_list, ssid_security_list=ssid_security_list, test_duration=test_duration, - side_a_min_rate=256000, side_b_min_rate=256000) + side_a_min_rate=256000, side_b_min_rate=256000, debug_on=debug_on) # This cleanup does not work because objects in the profiles are not yet created. # Not sure the best way to resolve this currently. --Ben From 7c16c8951944fc2e9118833c4191a037d7a2ffae Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 5 Aug 2020 16:42:57 -0700 Subject: [PATCH 079/134] Added check for existing station before cleanup in StationProfile --- py-json/realm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f3af59d2..65152399 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1886,8 +1886,14 @@ class StationProfile: data["shelf"] = eid[0] data["resource"] = eid[1] data["port"] = eid[2] - self.local_realm.json_post(req_url, data, debug_=True) #self.debug) - time.sleep(delay) + current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) + if not current_stations is None: + eid = self.local_realm.name_to_eid(port_eid) + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] + self.local_realm.json_post(req_url, data, debug_=True) #self.debug) + time.sleep(delay) # And now see if they are gone count = 0 From dc5d84b790bc9b036e98d4ecba90c63923b713c3 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Wed, 5 Aug 2020 17:48:27 -0700 Subject: [PATCH 080/134] Fixed issue with extra ports being created from incorrect name usage --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 65152399..9f1c92e2 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1848,7 +1848,7 @@ class StationProfile: set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) req_json = LFUtils.portUpRequest(resource, None, debug_on=False) for sta_name in self.station_names: - req_json["port"] = sta_name + req_json["port"] = self.local_realm.name_to_eid(sta_name)[-1] set_port_r.addPostData(req_json) json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) @@ -1857,7 +1857,7 @@ class StationProfile: set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) req_json = LFUtils.portDownRequest(resource, None, debug_on=False) for sta_name in self.station_names: - req_json["port"] = sta_name + req_json["port"] = self.local_realm.name_to_eid(sta_name)[-1] set_port_r.addPostData(req_json) json_response = set_port_r.jsonPost(self.debug) time.sleep(0.03) From c17837dc645f9ff27a7c6dc3bb7782fcb3421b8b Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 08:27:58 -0700 Subject: [PATCH 081/134] json: Work on pre-cleanup logic. Still doesn't work, but checking in what I have for now. --- py-json/LANforge/LFUtils.py | 33 +++++++--- py-json/realm.py | 80 +++++++++++------------- py-scripts/test_ipv4_variable_time.py | 90 +++++++++++++++++++-------- 3 files changed, 123 insertions(+), 80 deletions(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 95c122c3..8fb8757e 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -187,7 +187,7 @@ def generateMac(parent_mac, random_octet, debug=False): return ":".join(octets) -def portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000): +def portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, radio=None): """ This produces a named series similar to "sta000, sta001, sta002...sta0(end_id)" the padding_number is added to the start and end numbers and the resulting sum @@ -199,10 +199,10 @@ def portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) :param padding_number_: :return: """ - return port_name_series(prefix=prefix_, start_id=start_id_, end_id=end_id_, padding_number=padding_number_) + return port_name_series(prefix=prefix_, start_id=start_id_, end_id=end_id_, padding_number=padding_number_, radio=radio) -def port_name_series(prefix="sta", start_id=0, end_id=1, padding_number=10000): +def port_name_series(prefix="sta", start_id=0, end_id=1, padding_number=10000, radio=None): """ This produces a named series similar to "sta000, sta001, sta002...sta0(end_id)" the padding_number is added to the start and end numbers and the resulting sum @@ -214,10 +214,18 @@ def port_name_series(prefix="sta", start_id=0, end_id=1, padding_number=10000): :param padding_number_: used for width of resulting station number :return: list of stations """ + + eid = None + if radio != None: + eid = name_to_eid(radio) + name_list = [] for i in range((padding_number + start_id), (padding_number + end_id + 1)): sta_name = prefix + str(i)[1:] - name_list.append(sta_name) + if eid != None: + name_list.append("%i.%i.%s"%(eid[0], eid[1], sta_name)) + else: + name_list.append(sta_name) return name_list @@ -338,18 +346,24 @@ def wait_until_ports_admin_up(resource_id=1, base_url="http://localhost:8080", p sleep(1) return None -def waitUntilPortsDisappear(resource_id=1, base_url="http://localhost:8080", port_list=[], debug=False): - wait_until_ports_disappear(resource_id, base_url, port_list, debug) +def waitUntilPortsDisappear(base_url="http://localhost:8080", port_list=[], debug=False): + wait_until_ports_disappear(base_url, port_list, debug) -def wait_until_ports_disappear(resource_id=1, base_url="http://localhost:8080", port_list=[], debug=False): +def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], debug=False): print("Waiting until ports disappear...") url = "/port/1" found_stations = port_list.copy() - sleep(1) + while len(found_stations) > 0: found_stations = [] sleep(1) - for port_name in port_list: + + for port_eid in port_list: + eid = name_to_eid(port_eid) + shelf = eid[0] + resource_id = eid[1] + port_name = eid[2] + check_url = "%s/%s/%s" % (url, resource_id, port_name) if debug: print("checking:" + check_url) @@ -363,7 +377,6 @@ def wait_until_ports_disappear(resource_id=1, base_url="http://localhost:8080", def waitUntilPortsAppear(base_url="http://localhost:8080", port_list=(), debug=False): """ Deprecated - :param resource_id: :param base_url: :param port_list: :param debug: diff --git a/py-json/realm.py b/py-json/realm.py index 9f1c92e2..a7b1e210 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -118,15 +118,40 @@ class Realm(LFCliBase): self.freq_to_chan[4970] = 194 self.freq_to_chan[4980] = 196 - def wait_until_ports_appear(self, resource_=1, sta_list=None, debug_=False): + def wait_until_ports_appear(self, sta_list=None, debug_=False): if (sta_list is None) or (len(sta_list) < 1): print("realm.wait_until_ports_appear: no stations provided") return - LFUtils.wait_until_ports_appear(resource_id=resource_, - base_url=self.lfclient_url, + LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=sta_list, debug=debug_) + def rm_port(self, port_eid, check_exists=True): + req_url = "/cli-json/rm_vlan" + data = {} + + eid = self.name_to_eid(port_eid) + do_rm = True; + if check_exists: + if not self.port_exists(port_eid): + do_rm = False + if do_rm: + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] + self.json_post(req_url, data, debug_=True) #self.debug) + + def port_exists(self, port_eid): + data = {} + eid = self.name_to_eid(port_eid) + data["shelf"] = eid[0] + data["resource"] = eid[1] + data["port"] = eid[2] + current_stations = self.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) + if not current_stations is None: + return True + return False + def admin_up(self, port_eid): eid = self.name_to_eid(port_eid) shelf = eid[0] @@ -1844,33 +1869,17 @@ class StationProfile: return result - def admin_up(self, resource): - set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portUpRequest(resource, None, debug_on=False) + def admin_up(self): for sta_name in self.station_names: - req_json["port"] = self.local_realm.name_to_eid(sta_name)[-1] - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) + self.local_realm.admin_up(sta_name) - def admin_down(self, resource): - set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug) - req_json = LFUtils.portDownRequest(resource, None, debug_on=False) + def admin_down(self): for sta_name in self.station_names: - req_json["port"] = self.local_realm.name_to_eid(sta_name)[-1] - set_port_r.addPostData(req_json) - json_response = set_port_r.jsonPost(self.debug) - time.sleep(0.03) + self.local_realm.admin_down(sta_name) def cleanup(self, desired_stations=None, delay=0.03): print("Cleaning up stations") - req_url = "/cli-json/rm_vlan" - data = { - "shelf": 1, - "resource": 1, - "port": None - } if (desired_stations is None): desired_stations = self.station_names; @@ -1882,18 +1891,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: - eid = self.local_realm.name_to_eid(port_eid) - data["shelf"] = eid[0] - data["resource"] = eid[1] - data["port"] = eid[2] - current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) - if not current_stations is None: - eid = self.local_realm.name_to_eid(port_eid) - data["shelf"] = eid[0] - data["resource"] = eid[1] - data["port"] = eid[2] - self.local_realm.json_post(req_url, data, debug_=True) #self.debug) - time.sleep(delay) + self.local_relm.rm_port(port_eid, check_exists=True) # And now see if they are gone count = 0 @@ -1907,12 +1905,7 @@ class StationProfile: current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) if not current_stations is None: found_one = True - # Try again to delete - data["shelf"] = eid[0] - data["resource"] = eid[1] - data["port"] = eid[2] - self.local_realm.json_post(req_url, data, debug_=True) #self.debug) - time.sleep(delay) + self.local_relm.rm_port(port_eid, check_exists=False) if not found_one: return count = count + 1 @@ -1972,8 +1965,9 @@ class StationProfile: num = 0 #pprint(self.station_names) #exit(1) - for name in my_sta_names: - self.set_port_data["port"] = name + for eidn in my_sta_names: + eid = self.local_realm.name_to_eid(eidn) + name = eid[2] num += 1 self.add_sta_data["shelf"] = radio_shelf self.add_sta_data["resource"] = radio_resource diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index ce5d75f1..a1f35fb8 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -19,7 +19,7 @@ import datetime class IPV4VariableTime(LFCliBase): - def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, radio="wiphy0", + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream="eth1", radio="wiphy0", side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, number_template="00000", test_duration="5m", use_ht160=False, @@ -27,6 +27,7 @@ class IPV4VariableTime(LFCliBase): _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.upstream = upstream self.host = host self.port = port self.ssid = ssid @@ -36,7 +37,6 @@ class IPV4VariableTime(LFCliBase): self.radio = radio self.number_template = number_template self.debug = _debug_on - self.resource = resource self.name_prefix = name_prefix self.test_duration = test_duration self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) @@ -93,8 +93,8 @@ class IPV4VariableTime(LFCliBase): return False def start(self, print_pass=False, print_fail=False): - self.station_profile.admin_up(self.resource) - temp_stas = self.sta_list.copy() + self.station_profile.admin_up() + temp_stas = self.station_profile.station_names.copy() temp_stas.append("eth1") if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) @@ -132,46 +132,82 @@ class IPV4VariableTime(LFCliBase): def stop(self): self.cx_profile.stop_cx() - for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, sta_name) - url = "cli-json/set_port" - self.json_post(url, data) + self.station_profile.admin_down() - def cleanup(self, sta_list): + def pre_cleanup(self): + for sta in self.sta_list: + self.local_realm.rm_port(sta, check_exists=True) + + def cleanup(self): self.cx_profile.cleanup() - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup() + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.station_profile.station_names, debug=self.debug) def build(self): + self.station_profile.use_security(self.security, self.ssid, self.password) self.station_profile.set_number_template(self.number_template) print("Creating stations") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - temp_sta_list = [] - for station in range(len(self.sta_list)): - temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.cx_profile.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) + self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream, sleep_time=0) self._pass("PASS: Station build finished") def main(): - lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ip_var_test = IPV4VariableTime(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, - name_prefix="var_time", - ssid="jedway-wpa2-160", - password="jedway-wpa2-160", - resource=1, - radio="wiphy2", - security="wpa2", test_duration="5m", use_ht160=False, - side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=True) - ip_var_test.cleanup(station_list) + parser = argparse.ArgumentParser( + prog='test_ipv4_variable_time.py', + #formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ +test_ipv4_variable_time.py: +-------------------- +TBD + +Generic command layout: +python ./test_ipv4_variable_time.py --upstream_port --radio --debug + +Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + + parser.add_argument('--mgr', help='--mgr ',default='localhost') + parser.add_argument('--upstream', help='--upstream <1.eth1, etc>',default='1.eth1') + parser.add_argument('--radio', help='--radio ',default='wiphy2') + parser.add_argument('--ssid', help='--ssid ',default='jedway-wpa2-160') + parser.add_argument('--passwd', help='--passwd ',default='jedway-wpa2-160') + parser.add_argument('--security', help='--security ',default='wpa2') + parser.add_argument('--debug', help='--debug: Enable debugging',default=False) + parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') + + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, radio=args.radio) + + ip_var_test = IPV4VariableTime(args.mgr, lfjson_port, number_template="00", sta_list=station_list, + name_prefix="VT", + upstream=args.upstream, + ssid=args.ssid, + password=args.passwd, + radio=args.radio, + security=args.security, test_duration="5m", use_ht160=False, + side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=args.debug) + + ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) @@ -182,7 +218,7 @@ def main(): print(ip_var_test.get_fail_message()) exit(1) time.sleep(30) - ip_var_test.cleanup(station_list) + ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes") From 1e35f25ff35c2c10eec0bfe0dd20cb18827af0ec Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 09:44:51 -0700 Subject: [PATCH 082/134] Fixed typo --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a7b1e210..077c7f33 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1891,7 +1891,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: - self.local_relm.rm_port(port_eid, check_exists=True) + self.local_realm.rm_port(port_eid, check_exists=True) # And now see if they are gone count = 0 @@ -1905,7 +1905,7 @@ class StationProfile: current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) if not current_stations is None: found_one = True - self.local_relm.rm_port(port_eid, check_exists=False) + self.local_realm.rm_port(port_eid, check_exists=False) if not found_one: return count = count + 1 From 0936b5dc27c53c1b038bea448f4afbc3344eea2f Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 09:59:28 -0700 Subject: [PATCH 083/134] python: Fix wait-for-ip, ipv4 variable time. Had indentation issue in port wait-for-ip logic, tie in some cmd-line args for ipv4 variable time script. --- py-json/realm.py | 17 ++++++++++++----- py-scripts/test_ipv4_variable_time.py | 11 +++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a7b1e210..017bd12c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -245,7 +245,7 @@ class Realm(LFCliBase): while wait_more: wait_more = False found_cxs = {} - cx_list = list(self.cx_list()) + cx_list = self.cx_list() not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] if cx_list is not None: for cx_name in cx_list: @@ -394,7 +394,7 @@ class Realm(LFCliBase): return LFUtils.name_to_eid(eid) def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): - print("Waiting for ips...") + print("Waiting for ips, timeout: %i..."%(timeout_sec)) #print(station_list) if (station_list is None) or (len(station_list) < 1): @@ -423,18 +423,23 @@ class Realm(LFCliBase): if v['ip'] == '0.0.0.0': wait_more = True print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + else: + print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + if ipv6: v = response['interface'] if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ and v['ipv6 address'] != 'AUTO': wait_more = True print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + else: + print("Found IPv6: %s on port: %s"%(v['ipv6 address'], sta_eid)) if wait_more: time.sleep(1) timeout_sec -= 1 - return not wait_more + return not wait_more def parse_time(self, time_string): if isinstance(time_string, str): @@ -1534,7 +1539,8 @@ class VAPProfile(LFCliBase): if self.debug: pprint(command_ref) raise ValueError("flag %s not in map" % name) - result += command_ref[name] + #print("add-named-flags: %s %i"%(name, command_ref[name])) + result |= command_ref[name] return result @@ -1972,7 +1978,8 @@ class StationProfile: self.add_sta_data["shelf"] = radio_shelf self.add_sta_data["resource"] = radio_resource self.add_sta_data["radio"] = radio_port - self.add_sta_data["sta_name"] = name + self.add_sta_data["sta_name"] = name # for create station calls + self.set_port_data["port"] = name # for set_port calls. self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name)) add_sta_r.addPostData(self.add_sta_data) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index a1f35fb8..d926da28 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -19,7 +19,7 @@ import datetime class IPV4VariableTime(LFCliBase): - def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream="eth1", radio="wiphy0", + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream, radio, side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, number_template="00000", test_duration="5m", use_ht160=False, @@ -95,7 +95,7 @@ class IPV4VariableTime(LFCliBase): def start(self, print_pass=False, print_fail=False): self.station_profile.admin_up() temp_stas = self.station_profile.station_names.copy() - temp_stas.append("eth1") + temp_stas.append(self.upstream) if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: @@ -186,13 +186,12 @@ Note: multiple --radio switches may be entered up to the number of radios avai parser.add_argument('--mgr', help='--mgr ',default='localhost') - parser.add_argument('--upstream', help='--upstream <1.eth1, etc>',default='1.eth1') + parser.add_argument('-u', '--upstream_port', help='--upstream_port <1.eth1, etc>',default='1.eth1') parser.add_argument('--radio', help='--radio ',default='wiphy2') parser.add_argument('--ssid', help='--ssid ',default='jedway-wpa2-160') parser.add_argument('--passwd', help='--passwd ',default='jedway-wpa2-160') parser.add_argument('--security', help='--security ',default='wpa2') - parser.add_argument('--debug', help='--debug: Enable debugging',default=False) - parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') + parser.add_argument('--debug', help='--debug: Enable debugging',default=False, action="store_true") args = parser.parse_args() @@ -200,7 +199,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai ip_var_test = IPV4VariableTime(args.mgr, lfjson_port, number_template="00", sta_list=station_list, name_prefix="VT", - upstream=args.upstream, + upstream=args.upstream_port, ssid=args.ssid, password=args.passwd, radio=args.radio, From b737be3110d07c33fbcea7344425374e3e38d39f Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 10:32:27 -0700 Subject: [PATCH 084/134] Commented unused variable --- py-json/realm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a66b4475..c15a2057 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1905,9 +1905,9 @@ class StationProfile: found_one = False for port_eid in desired_stations: eid = self.local_realm.name_to_eid(port_eid) - data["shelf"] = eid[0] - data["resource"] = eid[1] - data["port"] = eid[2] + # data["shelf"] = eid[0] + # data["resource"] = eid[1] + # data["port"] = eid[2] current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) if not current_stations is None: found_one = True From 7252d686bd63ee74ee0a1686ce0f9d9687cdfcab Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 10:42:17 -0700 Subject: [PATCH 085/134] python: longevity gains pre-cleanup logic. No more need for manual removal. Put rm_cx, endp, and rm cxe by prefix in realm class. --- py-json/realm.py | 77 ++++++++++++++++++--------- py-scripts/test_ipv4_variable_time.py | 1 + py-scripts/test_l3_longevity.py | 15 ++++-- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a66b4475..e31e2d5e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -168,6 +168,43 @@ class Realm(LFCliBase): request = LFUtils.port_down_request(resource_id=resource, port_name=port) self.json_post("/cli-json/set_port", request) + def rm_cx(self, cx_name): + req_url = "cli-json/rm_cx" + data = { + "test_mgr": "ALL", + "cx_name": cx_name + } + self.json_post(req_url, data) + + def rm_endp(self, ename, debug_=False, suppress_related_commands_=True): + req_url = "cli-json/rm_endp" + data = { + "endp_name": ename + } + self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + + def stop_cx(self, cx_name): + self.json_post("/cli-json/set_cx_state", { + "test_mgr": "ALL", + "cx_name": cx_name, + "cx_state": "STOPPED" + }, debug_=self.debug) + + def cleanup_cxe_prefix(self, prefix): + cx_list = self.cx_list() + if cx_list is not None: + for cx_name in cx_list: + if cx_name.startswith(prefix): + self.rm_cx(cx_name) + + endp_list = self.json_get("/endp") + if endp_list is not None: + endp_list = list(endp_list['endpoint']) + for idx in range(len(endp_list)): + endp_name = list(endp_list[idx])[0] + if endp_name.startswith(prefix): + self.rm_endp(endp_name) + def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] @@ -225,8 +262,8 @@ class Realm(LFCliBase): found_endps = {} if endp_list is not None: endp_list = list(endp_list['endpoint']) - for endp_name in range(len(endp_list)): - name = list(endp_list[endp_name])[0] + for idx in range(len(endp_list)): + name = list(endp_list[idx])[0] found_endps[name] = name for req in these_endp: @@ -623,16 +660,15 @@ class MULTICASTProfile(LFCliBase): pass + def cleanup_prefix(self): + self.local_realm.cleanup_cxe_prefix(self.name_prefix) + def cleanup(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True for endp_name in self.get_mc_names(): - json_data = { - "endp_name":endp_name - } - url = "cli-json/rm_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.rm_endp(endp_name, debug_=debug_, suppress_related_commands_=suppress_related_commands) def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_ = False ): if self.debug: @@ -642,7 +678,7 @@ class MULTICASTProfile(LFCliBase): side_tx_shelf = side_tx_info[0] side_tx_resource = side_tx_info[1] side_tx_port = side_tx_info[2] - side_tx_name = "mtx-%s-%i"%(side_tx_port, len(self.created_mc)) + side_tx_name = "%smtx-%s-%i"%(self.name_prefix, side_tx_port, len(self.created_mc)) json_data = [] @@ -699,7 +735,7 @@ class MULTICASTProfile(LFCliBase): side_rx_shelf = side_rx_info[0] side_rx_resource = side_rx_info[1] side_rx_port = side_rx_info[2] - side_rx_name = "mrx-%s-%i"%(side_rx_port, len(self.created_mc)) + side_rx_name = "%smrx-%s-%i"%(self.name_prefix, side_rx_port, len(self.created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { 'alias':side_rx_name, @@ -812,34 +848,23 @@ class L3CXProfile(LFCliBase): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.json_post("/cli-json/set_cx_state", { - "test_mgr": "default_tm", - "cx_name": cx_name, - "cx_state": "STOPPED" - }, debug_=self.debug) + self.local_realm.stop_cx(cx_name) print(".", end='') print("") + def cleanup_prefix(self): + self.local_realm.cleanup_cxe_prefix(self.name_prefix) + def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: for cx_name in self.created_cx.keys(): print("Cleaning cx: %s"%(cx_name)) - req_url = "cli-json/rm_cx" - data = { - "test_mgr": "default_tm", - "cx_name": cx_name - } - self.json_post(req_url, data) + self.local_realm.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): - ename = self.created_cx[cx_name][side] print("Cleaning endpoint: %s"%(ename)) - req_url = "cli-json/rm_endp" - data = { - "endp_name": ename - } - self.json_post(req_url, data) + self.local_realm.rm_endp(self.created_cx[cx_name][side]) def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False): if self.debug: diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index d926da28..114eb1bf 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -135,6 +135,7 @@ class IPV4VariableTime(LFCliBase): self.station_profile.admin_down() def pre_cleanup(self): + self.cx_profile.cleanup_prefix() for sta in self.sta_list: self.local_realm.rm_port(sta, check_exists=True) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index d001bf72..25eb4222 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -43,6 +43,7 @@ class L3VariableTimeLongevity(LFCliBase): self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) self.cx_profile = self.local_realm.new_l3_cx_profile() self.multicast_profile = self.local_realm.new_multicast_profile() + self.multicast_profile.name_prefix = "MLT-"; self.station_profiles = [] index = 0 @@ -170,6 +171,13 @@ class L3VariableTimeLongevity(LFCliBase): for station_name in station_list: self.local_realm.admin_down(station_name) + def pre_cleanup(self): + self.cx_profile.cleanup_prefix() + self.multicast_profile.cleanup_prefix() + for station_list in self.station_lists: + for sta in station_list: + self.local_realm.rm_port(sta, check_exists=True) + def cleanup(self): self.cx_profile.cleanup() self.multicast_profile.cleanup() @@ -345,7 +353,8 @@ Note: multiple --radio switches may be entered up to the number of radios avai if number_of_stations > MAX_NUMBER_OF_STATIONS: print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) quit(1) - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, + padding_number_=10000, radio=radio_name[index]) station_lists.append(station_list) index += 1 @@ -366,9 +375,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai ssid_security_list=ssid_security_list, test_duration=test_duration, side_a_min_rate=256000, side_b_min_rate=256000, debug_on=debug_on) - # This cleanup does not work because objects in the profiles are not yet created. - # Not sure the best way to resolve this currently. --Ben - ip_var_test.cleanup() + ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): From 1aeb801a27ddf300ba3034a0b439d82c5548ead0 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 11:39:02 -0700 Subject: [PATCH 086/134] Added static method to parse common arguments --- py-json/LANforge/lfcli_base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index ec9918b0..a3818f66 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -6,6 +6,7 @@ from pprint import pprint import LANforge.LFUtils from LANforge.LFUtils import * +import argparse class LFCliBase: @@ -207,4 +208,19 @@ class LFCliBase: if print_: print(self.pass_pref + message) + @staticmethod + def create_basic_argparse(): + parser = argparse.ArgumentParser() + + parser.add_argument('--mgr', help='--mgr ', default='localhost') + parser.add_argument('-u', '--upstream_port', help='--upstream_port <1.eth1, etc>', default='1.eth1') + parser.add_argument('--radio', help='--radio ', default='wiphy2') + parser.add_argument('--ssid', help='--ssid ', default='jedway-wpa2-160') + parser.add_argument('--passwd', help='--passwd ', default='jedway-wpa2-160') + parser.add_argument('--security', help='--security ', default='wpa2') + parser.add_argument('--debug', help='--debug: Enable debugging', default=False, action="store_true") + + args = parser.parse_args() + return args + # ~class From da34b354217376f5a3b7450a38ae7ef1b9321324 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 11:41:19 -0700 Subject: [PATCH 087/134] create_basic_parser returns parser object now instead of args array --- py-json/LANforge/lfcli_base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index a3818f66..f2b2962b 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -220,7 +220,6 @@ class LFCliBase: parser.add_argument('--security', help='--security ', default='wpa2') parser.add_argument('--debug', help='--debug: Enable debugging', default=False, action="store_true") - args = parser.parse_args() - return args + return parser # ~class From 53d770bf5e67765543d6310ad06c7bc6a77c8a42 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 11:44:39 -0700 Subject: [PATCH 088/134] json: Add ToS support to l3 longevity test. --- py-json/realm.py | 32 +++++++++++++++++++++++++++++--- py-scripts/test_l3_longevity.py | 24 ++++++++++++++++++------ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 2095ce00..81b2c44e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -183,6 +183,24 @@ class Realm(LFCliBase): } self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + def set_endp_tos(self, ename, _tos, debug_=False, suppress_related_commands_=True): + req_url = "cli-json/set_endp_tos" + tos = _tos; + # Convert some human readable values to numeric needed by LANforge. + if _tos == "BK": + tos = "64" + if _tos == "BE": + tos = "96" + if _tos == "VI": + tos = "128" + if _tos == "VO": + tos = "192" + data = { + "name": ename, + "tos": tos + } + self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + def stop_cx(self, cx_name): self.json_post("/cli-json/set_cx_state", { "test_mgr": "ALL", @@ -630,8 +648,11 @@ class MULTICASTProfile(LFCliBase): def get_mc_names(self): return self.created_mc.keys() - def refresh_mc(self): - pass + def refresh_mc(self, debug_=False): + for endp_name in self.get_mc_names(): + self.json_post("/cli-json/show_endpoints", { + "endpoint": endp_name + }, debug_=debug_) def start_mc(self, suppress_related_commands=None, debug_ = False): if self.debug: @@ -866,7 +887,7 @@ class L3CXProfile(LFCliBase): print("Cleaning endpoint: %s"%(ename)) self.local_realm.rm_endp(self.created_cx[cx_name][side]) - def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False): + def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): if self.debug: debug_=True @@ -951,6 +972,11 @@ class L3CXProfile(LFCliBase): "val": 1 } self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + + if tos != None: + self.local_realm.set_endp_tos(endp_a_name, tos) + self.local_realm.set_endp_tos(endp_b_name, tos) + #print("CXNAME366:") #pprint(cx_name) data = { diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 25eb4222..39867bc0 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -18,7 +18,7 @@ import time import datetime class L3VariableTimeLongevity(LFCliBase): - def __init__(self, host, port, endp_types, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + def __init__(self, host, port, endp_types, tos, side_b, radios, radio_name_list, number_of_stations_per_radio_list, ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, debug_on, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, @@ -28,6 +28,7 @@ class L3VariableTimeLongevity(LFCliBase): super().__init__(host, port, _debug=debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port + self.tos = tos.split() self.endp_types = endp_types.split() self.side_b = side_b self.ssid_list = ssid_list @@ -130,9 +131,11 @@ class L3VariableTimeLongevity(LFCliBase): print("print failed to get IP's") print("Starting multicast traffic (if any configured)") - self.multicast_profile.start_mc(debug_=True) + self.multicast_profile.start_mc(debug_=self.debug) + self.multicast_profile.refresh_mc(debug_=self.debug) print("Starting layer-3 traffic (if any configured)") self.cx_profile.start_cx() + self.cx_profile.refresh_cx() cur_time = datetime.datetime.now() print("Getting initial values.") @@ -206,12 +209,14 @@ class L3VariableTimeLongevity(LFCliBase): index += 1 for etype in self.endp_types: - print("Creating connections for endpoint type: %s"%(etype)) if etype == "mc_udp" or etype == "mc_udp6": + print("Creating Multicast connections for endpoint type: %s"%(etype)) self.multicast_profile.create_mc_tx(etype, self.side_b, etype) self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names) else: - self.cx_profile.create(endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0) + for _tos in self.tos: + print("Creating connections for endpoint type: %s TOS: %s"%(etype, _tos)) + self.cx_profile.create(endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos) self._pass("PASS: Stations build finished") @@ -276,21 +281,27 @@ Note: multiple --radio switches may be entered up to the number of radios avai mc_udp : IPv4 multi cast UDP traffic mc_udp6 : IPv6 multi cast UDP traffic +: + BK, BE, VI, VO: Optional wifi related Tos Settings. Or, use your preferred numeric values. + + Example: 1. Test duration 4 minutes 2. Traffic IPv4 TCP 3. Upstream-port eth1 4. Radio #1 wiphy0 has 32 stations, ssid = candelaTech-wpa2-x2048-4-1, ssid password = candelaTech-wpa2-x2048-4-1 5. Radio #2 wiphy1 has 64 stations, ssid = candelaTech-wpa2-x2048-5-3, ssid password = candelaTech-wpa2-x2048-5-3 + 6. Create connections with TOS of BK and VI Command: - python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --tos \"BK VI\" --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 ''') parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') + parser.add_argument('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") parser.add_argument('--debug', help='--debug: Enable debugging',default=False) parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', default='lf_udp', type=valid_endp_types) @@ -358,7 +369,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai station_lists.append(station_list) index += 1 - print("endp-types: %s"%(endp_types)) + #print("endp-types: %s"%(endp_types)) ip_var_test = L3VariableTimeLongevity(lfjson_host, lfjson_port, @@ -366,6 +377,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai station_lists= station_lists, name_prefix="LT-", endp_types=endp_types, + tos=args.tos, side_b=side_b, radios=radios, radio_name_list=radio_name_list, From a99e06d72964abde8c6e5c54f65549dae92cdbd8 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 12:00:12 -0700 Subject: [PATCH 089/134] longevity: Fix problem with multiple radios. Looks like something I added earlier. --- py-scripts/test_l3_longevity.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 39867bc0..e1b29203 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -203,10 +203,8 @@ class L3VariableTimeLongevity(LFCliBase): station_profile.set_number_template(station_profile.number_template) print("Creating stations") - index = 0 - for station_list in self.station_lists: - station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=self.debug, sleep_time=0) - index += 1 + station_profile.create(radio=self.radio_list[index], sta_names_=self.station_lists[index], debug=self.debug, sleep_time=0) + index += 1 for etype in self.endp_types: if etype == "mc_udp" or etype == "mc_udp6": @@ -365,7 +363,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) quit(1) station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, - padding_number_=10000, radio=radio_name[index]) + padding_number_=10000, radio=radio[index]) station_lists.append(station_list) index += 1 From dfb85aa3907767c06e1f097faeb13c1df6aba230 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 12:00:37 -0700 Subject: [PATCH 090/134] Added create_basic_argparse arguments for setting prog, formatter_class, epilog, and description --- py-json/LANforge/lfcli_base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index f2b2962b..b0b27182 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -209,8 +209,12 @@ class LFCliBase: print(self.pass_pref + message) @staticmethod - def create_basic_argparse(): - parser = argparse.ArgumentParser() + def create_basic_argparse(prog=None, formatter_class=None, epilog=None, description=None): + if prog is not None or formatter_class is not None or epilog is not None or description is not None: + parser = argparse.ArgumentParser(prog=prog, formatter_class=formatter_class, epilog=epilog, + description=description) + else: + parser = argparse.ArgumentParser() parser.add_argument('--mgr', help='--mgr ', default='localhost') parser.add_argument('-u', '--upstream_port', help='--upstream_port <1.eth1, etc>', default='1.eth1') From e2f514ef9b30ab9339afbdf4229efa461bf231cc Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 12:03:02 -0700 Subject: [PATCH 091/134] Updated argument parsing, now uses lfcli_base --- py-scripts/test_ipv4_variable_time.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 114eb1bf..6b98bf2b 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -161,7 +161,7 @@ class IPV4VariableTime(LFCliBase): def main(): lfjson_port = 8080 - parser = argparse.ArgumentParser( + parser = LFCliBase.create_basic_argparse( prog='test_ipv4_variable_time.py', #formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, @@ -169,7 +169,7 @@ def main(): Useful Information: 1. TBD ''', - + description='''\ test_ipv4_variable_time.py: -------------------- @@ -185,14 +185,9 @@ Note: multiple --radio switches may be entered up to the number of radios avai ''') - - parser.add_argument('--mgr', help='--mgr ',default='localhost') - parser.add_argument('-u', '--upstream_port', help='--upstream_port <1.eth1, etc>',default='1.eth1') - parser.add_argument('--radio', help='--radio ',default='wiphy2') - parser.add_argument('--ssid', help='--ssid ',default='jedway-wpa2-160') - parser.add_argument('--passwd', help='--passwd ',default='jedway-wpa2-160') - parser.add_argument('--security', help='--security ',default='wpa2') - parser.add_argument('--debug', help='--debug: Enable debugging',default=False, action="store_true") + parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) + parser.add_argument('--b_min', help='--a_min bps rate minimum for side_a', default=256000) + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") args = parser.parse_args() @@ -204,8 +199,8 @@ Note: multiple --radio switches may be entered up to the number of radios avai ssid=args.ssid, password=args.passwd, radio=args.radio, - security=args.security, test_duration="5m", use_ht160=False, - side_a_min_rate=256000, side_b_min_rate=256000, _debug_on=args.debug) + security=args.security, test_duration=args.test_duration, use_ht160=False, + side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug) ip_var_test.pre_cleanup() ip_var_test.build() From f68746c278e7bce45454067f9703c59260614bd7 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 12:45:43 -0700 Subject: [PATCH 092/134] Updated to use new argument parsing --- py-scripts/test_generic.py | 72 +++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 06fc550a..359efe22 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -19,9 +19,9 @@ import datetime class GenTest(LFCliBase): - def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, resource=1, + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream, number_template="00000", test_duration="5m", type="lfping", dest="127.0.0.1", - interval=1, + interval=1, radio="wiphy0", _debug_on=False, _exit_on_error=False, _exit_on_fail=False): @@ -29,11 +29,12 @@ class GenTest(LFCliBase): self.host = host self.port = port self.ssid = ssid + self.radio = radio + self.upstream = upstream self.sta_list = sta_list self.security = security self.password = password self.number_template = number_template - self.resource = resource self.name_prefix = name_prefix self.test_duration = test_duration self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) @@ -52,10 +53,10 @@ class GenTest(LFCliBase): self.cx_profile.interval = interval def start(self, print_pass=False, print_fail=False): - self.station_profile.admin_up(self.resource) + self.station_profile.admin_up() temp_stas = self.sta_list.copy() - temp_stas.append("eth1") - if self.local_realm.wait_for_ip(self.resource, temp_stas): + temp_stas.append(self.upstream) + if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: self._fail("Stations failed to get IPs", print_fail) @@ -102,30 +103,59 @@ class GenTest(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - temp_sta_list = [] - for station in range(len(self.sta_list)): - temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) - self.cx_profile.create(ports=temp_sta_list, sleep_time=.5) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) + self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5) self._pass("PASS: Station build finished") def cleanup(self, sta_list): self.cx_profile.cleanup() - self.station_profile.cleanup(self.resource, sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) def main(): - lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) - generic_test = GenTest(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, - name_prefix="var_time", type="lfping", dest="10.40.0.1", interval=1, - ssid="jedway-wpa2-x2048-4-4", - password="jedway-wpa2-x2048-4-4", - resource=1, - security="wpa2", test_duration="5m", ) + + parser = LFCliBase.create_basic_argparse( + prog='test_generic.py', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_generic.py: + -------------------- + TBD + + Generic command layout: + python ./test_generic.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_generic.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--type', help='--type type of command to run', default="lfping") + parser.add_argument('--dest', help='--dest destination for command', default="10.40.0.1") + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") + parser.add_argument('--interval', help='--interval interval to use when running lfping', default=1) + + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + generic_test = GenTest(args.mgr, lfjson_port, number_template="00", sta_list=station_list, + name_prefix="GT", type=args.type, dest=args.dest, interval=1, + ssid=args.ssid, upstream=args.upstream_port, + password=args.ssid, security=args.security, test_duration=args.test_duration, + _debug_on=args.debug, radio=args.radio) generic_test.cleanup(station_list) generic_test.build() From c7ce635055f07020050ef4d0f4155345bfa525b3 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 13:04:44 -0700 Subject: [PATCH 093/134] Fixed incorrect argument name --- py-scripts/test_generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 359efe22..020038c7 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -154,7 +154,7 @@ def main(): generic_test = GenTest(args.mgr, lfjson_port, number_template="00", sta_list=station_list, name_prefix="GT", type=args.type, dest=args.dest, interval=1, ssid=args.ssid, upstream=args.upstream_port, - password=args.ssid, security=args.security, test_duration=args.test_duration, + password=args.passwd, security=args.security, test_duration=args.test_duration, _debug_on=args.debug, radio=args.radio) generic_test.cleanup(station_list) From f906a281c429b678ef504c9cb10b2ffea0040fb1 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 6 Aug 2020 14:35:42 -0600 Subject: [PATCH 094/134] ename undefinded --- py-json/realm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py-json/realm.py b/py-json/realm.py index 81b2c44e..64363025 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -884,6 +884,7 @@ class L3CXProfile(LFCliBase): self.local_realm.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): + ename = self.created_cx[cx_name][side] print("Cleaning endpoint: %s"%(ename)) self.local_realm.rm_endp(self.created_cx[cx_name][side]) From 501e862682747260ef39d4f811797567c0d98588 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 13:37:11 -0700 Subject: [PATCH 095/134] Updated script to use new arg parsing methods --- py-scripts/test_ipv4_l4.py | 67 ++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index d3b55e13..b3a5c588 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -13,14 +13,15 @@ import argparse from LANforge.lfcli_base import LFCliBase from LANforge.LFUtils import * from LANforge import LFUtils +import argparse import realm import time import datetime class IPV4L4(LFCliBase): - def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, number_template="00000", - resource=1, + def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, + number_template="00000", radio="wiphy0", test_duration="5m", _debug_on=False, _exit_on_error=False, @@ -28,6 +29,7 @@ class IPV4L4(LFCliBase): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port + self.radio = radio self.ssid = ssid self.security = security self.password = password @@ -35,7 +37,6 @@ class IPV4L4(LFCliBase): self.requests_per_ten = requests_per_ten self.number_template = number_template self.sta_list = station_list - self.resource = resource self.test_duration = test_duration self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) @@ -90,18 +91,16 @@ class IPV4L4(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") - temp_sta_list = [] - for station in range(len(self.sta_list)): - temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.cx_profile.create(ports=temp_sta_list, sleep_time=.5, debug_=self.debug, suppress_related_commands_=None) + self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, + suppress_related_commands_=None) def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() temp_stas.append("eth1") - if self.local_realm.wait_for_ip(self.resource, temp_stas): + if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: self._fail("Stations failed to get IPs", print_fail) @@ -109,7 +108,7 @@ class IPV4L4(LFCliBase): cur_time = datetime.datetime.now() old_rx_values = self.__get_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time - self.station_profile.admin_up(1) + self.station_profile.admin_up() self.cx_profile.start_cx() passes = 0 expected_passes = 0 @@ -139,24 +138,58 @@ class IPV4L4(LFCliBase): def stop(self): self.cx_profile.stop_cx() for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, sta_name) + data = LFUtils.port_down_request(1, self.local_realm.name_to_eid(sta_name)[2]) url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): self.cx_profile.cleanup() - self.station_profile.cleanup(self.resource, sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) def main(): lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ip_test = IPV4L4(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4", - security="wpa2", station_list=station_list, url="dl http://10.40.0.1 /dev/null", test_duration="5m", - requests_per_ten=600, _debug_on=False) + + parser = LFCliBase.create_basic_argparse( + prog='test_generic.py', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_generic.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv4_l4.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_l4.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") + parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) + parser.add_argument('--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") + + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, + security=args.security, station_list=station_list, url=args.url, + test_duration=args.test_duration, + requests_per_ten=args.requests_per_ten, _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() if not ip_test.passes(): From 85b5b28de9e0a3271a624e3916eafd5cce6f5619 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 14:17:11 -0700 Subject: [PATCH 096/134] Updated script to use new arg parsing methods --- py-scripts/test_ipv4_l4_urls_per_ten.py | 68 ++++++++++++++++++------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index f255d2bd..8d64f32b 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -20,13 +20,14 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, - target_requests_per_ten=60, number_template="00000", resource=1, num_tests=1, + target_requests_per_ten=60, number_template="00000", num_tests=1, radio="wiphy0", _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port + self.radio = radio self.ssid = ssid self.security = security self.password = password @@ -34,7 +35,6 @@ class IPV4L4(LFCliBase): self.requests_per_ten = requests_per_ten self.number_template = number_template self.sta_list = station_list - self.resource = resource self.num_tests = num_tests self.target_requests_per_ten = target_requests_per_ten @@ -74,13 +74,10 @@ class IPV4L4(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") - temp_sta_list = [] - for station in range(len(self.sta_list)): - temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.cx_profile.create(ports=temp_sta_list, sleep_time=.5, debug_=self.debug, suppress_related_commands_=None) + self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=None) def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() @@ -89,8 +86,8 @@ class IPV4L4(LFCliBase): interval_time = cur_time + datetime.timedelta(minutes=10) passes = 0 expected_passes = 0 - self.station_profile.admin_up(1) - if self.local_realm.wait_for_ip(self.resource, temp_stas): + self.station_profile.admin_up() + if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: self._fail("Stations failed to get IPs", print_fail) @@ -119,25 +116,60 @@ class IPV4L4(LFCliBase): def stop(self): self.cx_profile.stop_cx() for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, sta_name) + data = LFUtils.portDownRequest(1, self.local_realm.name_to_eid(sta_name)[2]) url = "cli-json/set_port" self.json_post(url, data) def cleanup(self, sta_list): self.cx_profile.cleanup() - self.station_profile.cleanup(self.resource, sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) def main(): - lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ip_test = IPV4L4(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4", - security="wpa2", station_list=station_list, url="dl http://10.40.0.1 /dev/null", num_tests=1, - target_requests_per_ten=600, - requests_per_ten=600) + + parser = LFCliBase.create_basic_argparse( + prog='test_generic.py', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_generic.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv4_l4.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_l4.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") + parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) + parser.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) + parser.add_argument('--url', help='--url specifies upload/download, address, and dest', + default="dl http://10.40.0.1 /dev/null") + parser.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90% this value', + default=600) + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, + security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests, + target_requests_per_ten=args.target_per_ten, + requests_per_ten=args.requests_per_ten) ip_test.cleanup(station_list) ip_test.build() ip_test.start() From e35bdcdec072e2276419b03b6a1650cbc192016f Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 14:21:59 -0700 Subject: [PATCH 097/134] Fixed names in argparse info --- py-scripts/test_ipv4_l4_urls_per_ten.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 8d64f32b..73787c21 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -131,7 +131,7 @@ def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( - prog='test_generic.py', + prog='test_ipv4_l4_urls_per_ten', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ @@ -140,17 +140,17 @@ def main(): ''', description='''\ - test_generic.py: + test_ipv4_l4_urls_per_ten.py: -------------------- TBD Generic command layout: - python ./test_ipv4_l4.py --upstream_port --radio --debug + python ./test_ipv4_l4_urls_per_ten.py --upstream_port --radio --debug Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio - python3 ./test_ipv4_l4.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + python3 ./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 ''') From 7bd68683b587ec5ef43bc84b638553ce242367b8 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 14:24:18 -0700 Subject: [PATCH 098/134] Removed unnecessary argument --- py-scripts/test_ipv4_l4_urls_per_ten.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 73787c21..fe90bdc1 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -154,7 +154,6 @@ def main(): ''') - parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) parser.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) parser.add_argument('--url', help='--url specifies upload/download, address, and dest', From 346919156b2dca775c97449a2738d3d78c79ab07 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 14:33:40 -0700 Subject: [PATCH 099/134] Updated script to use new arg parsing methods --- py-scripts/test_ipv4_l4_ftp.py | 210 +++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100755 py-scripts/test_ipv4_l4_ftp.py diff --git a/py-scripts/test_ipv4_l4_ftp.py b/py-scripts/test_ipv4_l4_ftp.py new file mode 100755 index 00000000..4ac62f1d --- /dev/null +++ b/py-scripts/test_ipv4_l4_ftp.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python3 + +import sys + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append('../py-json') + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +from LANforge import LFUtils +import realm +import time +import datetime + + +class IPV4L4(LFCliBase): + def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, number_template="00000", + upstream_port="eth1", + test_duration="5m", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.ssid = ssid + self.upstream_port = upstream_port + self.security = security + self.password = password + self.url = url + self.requests_per_ten = requests_per_ten + self.number_template = number_template + self.sta_list = station_list + self.test_duration = test_duration + + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + self.cx_profile = self.local_realm.new_l4_cx_profile() + + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.password, + self.station_profile.security = self.security + self.station_profile.number_template_ = self.number_template + self.station_profile.mode = 0 + + self.cx_profile.url = self.url + self.cx_profile.requests_per_ten = self.requests_per_ten + + self.port_util = realm.PortUtils(self.local_realm) + + def __compare_vals(self, old_list, new_list): + passes = 0 + expected_passes = 0 + if len(old_list) == len(new_list): + for item, value in old_list.items(): + expected_passes += 1 + if new_list[item] > old_list[item]: + passes += 1 + # print(item, old_list[item], new_list[item], passes, expected_passes) + + if passes == expected_passes: + return True + else: + return False + else: + return False + + def __get_values(self): + time.sleep(1) + cx_list = self.json_get("layer4/list?fields=name,bytes-rd", debug_=self.debug) + # print("==============\n", cx_list, "\n==============") + cx_map = {} + for cx_name in cx_list['endpoint']: + if cx_name != 'uri' and cx_name != 'handler': + for item, value in cx_name.items(): + for value_name, value_rx in value.items(): + if item in self.cx_profile.created_cx.keys() and value_name == 'bytes-rd': + cx_map[item] = value_rx + return cx_map + + def build(self): + # Build stations + self.station_profile.use_security(self.security, self.ssid, self.password) + self.station_profile.set_number_template(self.number_template) + print("Creating stations") + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self._pass("PASS: Station build finished") + + self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=True) + + def start(self, print_pass=False, print_fail=False): + self.port_util.set_ftp(port_name=self.upstream_port, resource=1, on=True) + temp_stas = self.sta_list.copy() + temp_stas.append(self.upstream_port) + if self.local_realm.wait_for_ip(temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) + cur_time = datetime.datetime.now() + old_rx_values = self.__get_values() + end_time = self.local_realm.parse_time(self.test_duration) + cur_time + self.station_profile.admin_up() + self.cx_profile.start_cx() + passes = 0 + expected_passes = 0 + print("Starting Test...") + while cur_time < end_time: + interval_time = cur_time + datetime.timedelta(minutes=1) + while cur_time < interval_time: + cur_time = datetime.datetime.now() + time.sleep(1) + + new_rx_values = self.__get_values() + # print(old_rx_values, new_rx_values) + # print("\n-----------------------------------") + # print(cur_time, end_time, cur_time + datetime.timedelta(minutes=1)) + # print("-----------------------------------\n") + expected_passes += 1 + if self.__compare_vals(old_rx_values, new_rx_values): + passes += 1 + else: + self._fail("FAIL: Not all stations increased traffic", print_fail) + break + old_rx_values = new_rx_values + cur_time = datetime.datetime.now() + if passes == expected_passes: + self._pass("PASS: All tests passes", print_pass) + + def stop(self): + self.port_util.set_ftp(port_name=self.upstream_port, resource=1, on=False) + self.cx_profile.stop_cx() + for sta_name in self.sta_list: + data = LFUtils.portDownRequest(1, self.local_realm.name_to_eid(sta_name)[2]) + url = "cli-json/set_port" + self.json_post(url, data) + + def cleanup(self, sta_list): + self.cx_profile.cleanup() + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, + debug=self.debug) + + +def main(): + lfjson_port = 8080 + + parser = LFCliBase.create_basic_argparse( + prog='test_ipv4_l4_ftp', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_ipv4_l4_ftp.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv4_l4_ftp.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_l4_ftp.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") + parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) + parser.add_argument('--url', help='--url specifies upload/download, address, and dest', + default="dl ftp://10.40.0.1 /dev/null") + + args = parser.parse_args() + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, + security=args.security, station_list=station_list, url=args.url, test_duration=args.test_duration, + requests_per_ten=args.requests_per_ten, _debug_on=args.debug) + ip_test.cleanup(station_list) + ip_test.build() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + ip_test.start(False, False) + ip_test.stop() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + time.sleep(30) + ip_test.cleanup(station_list) + if ip_test.passes(): + print("Full test passed, all endpoints had increased bytes-rd throughout test duration") + + +if __name__ == "__main__": + main() From b19e55fe3a3941184bbcd71c385bb55f274f1381 Mon Sep 17 00:00:00 2001 From: Dipti Dhond Date: Thu, 6 Aug 2020 15:13:17 -0700 Subject: [PATCH 100/134] working now --- py-scripts/sta_connect2.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/py-scripts/sta_connect2.py b/py-scripts/sta_connect2.py index 92dc45da..19663de2 100755 --- a/py-scripts/sta_connect2.py +++ b/py-scripts/sta_connect2.py @@ -22,6 +22,7 @@ from LANforge.lfcli_base import LFCliBase from LANforge.LFUtils import * import realm from realm import Realm +import pprint OPEN="open" WEP="wep" @@ -141,7 +142,7 @@ class StaConnect2(LFCliBase): if (response is not None) and (response["interface"] is not None): for sta_name in self.station_names: LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - LFUtils.wait_until_ports_disappear(self.resource, self.lfclient_url, self.station_names) + LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names) # Create stations and turn dhcp on self.station_profile = self.localrealm.new_station_profile() @@ -153,8 +154,8 @@ class StaConnect2(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) print("Adding new stations ", end="") - self.station_profile.create(resource=self.resource, radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True) - LFUtils.wait_until_ports_appear(self.resource, self.lfclient_url, self.station_names, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True) + LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug) # Create UDP endpoints self.l3_udp_profile = self.localrealm.new_l3_cx_profile() @@ -193,7 +194,7 @@ class StaConnect2(LFCliBase): "port": "ALL", "probe_flags": 1} self.json_post("/cli-json/nc_show_ports", data) - self.station_profile.admin_up(self.resource) + self.station_profile.admin_up() LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names) # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) @@ -329,14 +330,16 @@ class StaConnect2(LFCliBase): if self.cleanup_on_exit: for sta_name in self.station_names: LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - endp_names = [] - + curr_endp_names = [] removeCX(self.lfclient_url, self.l3_udp_profile.get_cx_names()) removeCX(self.lfclient_url, self.l3_tcp_profile.get_cx_names()) for (cx_name, endp_names) in self.l3_udp_profile.created_cx.items(): - endp_names.append(endp_names[0]) - endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, endp_names) + curr_endp_names.append(endp_names[0]) + curr_endp_names.append(endp_names[1]) + for (cx_name, endp_names) in self.l3_tcp_profile.created_cx.items(): + curr_endp_names.append(endp_names[0]) + curr_endp_names.append(endp_names[1]) + removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) # ~class @@ -408,6 +411,7 @@ Example: if args.dut_security is not None: staConnect.dut_security = args.dut_security + # staConnect.cleanup() staConnect.setup() staConnect.start() print("napping %f sec" % staConnect.runtime_secs) From b73338793598770729a75d12d3501595b0a374b1 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 15:36:54 -0700 Subject: [PATCH 101/134] Fixed typo --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 6b98bf2b..04a69d46 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -186,7 +186,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai ''') parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) - parser.add_argument('--b_min', help='--a_min bps rate minimum for side_a', default=256000) + parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") args = parser.parse_args() From fe22cf1b887b0d9c61724d874c8bdc13815fca69 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 15:49:19 -0700 Subject: [PATCH 102/134] Fixed wait_for_ip logic for ipv6 --- py-json/realm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 64363025..271f9647 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -483,12 +483,13 @@ class Realm(LFCliBase): if ipv6: v = response['interface'] + print(v) if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ and v['ipv6 address'] != 'AUTO': + print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) + else: wait_more = True print("Waiting for port %s to get IPv6 Address."%(sta_eid)) - else: - print("Found IPv6: %s on port: %s"%(v['ipv6 address'], sta_eid)) if wait_more: time.sleep(1) From 83c1ea60f5da36935f26725c27f492ebefb4dd91 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 15:50:32 -0700 Subject: [PATCH 103/134] Make cisco_wifi_ctl.py executable. --- cisco_wifi_ctl.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cisco_wifi_ctl.py diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py old mode 100644 new mode 100755 From 93cfc49675f9833b6b8c435d5ae2eb945bc4b9ab Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 15:54:42 -0700 Subject: [PATCH 104/134] Updated script to use new arg parsing methods --- py-scripts/test_ipv6_variable_time.py | 116 +++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/py-scripts/test_ipv6_variable_time.py b/py-scripts/test_ipv6_variable_time.py index ae33c935..d3f5abbd 100755 --- a/py-scripts/test_ipv6_variable_time.py +++ b/py-scripts/test_ipv6_variable_time.py @@ -19,24 +19,25 @@ import datetime class IPV6VariableTime(LFCliBase): - def __init__(self, host, port, ssid, security, password, name_prefix, sta_list, + def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream, radio, side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, - number_template="00000", test_duration="5m", - resource=1, + number_template="00000", test_duration="5m", use_ht160=False, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.upstream = upstream self.host = host self.port = port self.ssid = ssid self.sta_list = sta_list - self.name_prefix = name_prefix self.security = security self.password = password + self.radio = radio self.number_template = number_template - self.resource = resource + self.debug = _debug_on + self.name_prefix = name_prefix self.test_duration = test_duration self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) self.station_profile = self.local_realm.new_station_profile() @@ -44,10 +45,13 @@ class IPV6VariableTime(LFCliBase): self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, + self.station_profile.ssid_pass = self.password self.station_profile.security = self.security self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 + self.station_profile.debug = self.debug + self.station_profile.use_ht160 = use_ht160 + if self.station_profile.use_ht160: + self.station_profile.mode = 9 self.cx_profile.host = self.host self.cx_profile.port = self.port @@ -57,18 +61,17 @@ class IPV6VariableTime(LFCliBase): self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_max_bps = side_b_max_rate - def __get_rx_values(self): cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) # print(self.cx_profile.created_cx.values()) - #print("==============\n", cx_list, "\n==============") + # print("==============\n", cx_list, "\n==============") cx_rx_map = {} for cx_name in cx_list['endpoint']: if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): - cx_rx_map[item] = value_rx + if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): + cx_rx_map[item] = value_rx return cx_rx_map def __compare_vals(self, old_list, new_list): @@ -89,14 +92,13 @@ class IPV6VariableTime(LFCliBase): return False def start(self, print_pass=False, print_fail=False): - print("Starting test") - self.station_profile.admin_up(self.resource) - temp_stas = self.sta_list.copy() - temp_stas.append("eth1") - if self.local_realm.wait_for_ip(self.resource, temp_stas, ipv6=True): + self.station_profile.admin_up() + temp_stas = self.station_profile.station_names.copy() + temp_stas.append(self.upstream) + if self.local_realm.wait_for_ip(temp_stas, ipv4=False, ipv6=True): self._pass("All stations got IPs", print_pass) else: - self._fail("Stations failed to get IPs", print_fail, ipv6=True) + self._fail("Stations failed to get IPs", print_fail) exit(1) cur_time = datetime.datetime.now() old_cx_rx_values = self.__get_rx_values() @@ -129,43 +131,79 @@ class IPV6VariableTime(LFCliBase): def stop(self): self.cx_profile.stop_cx() - for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, sta_name) - url = "cli-json/set_port" - self.json_post(url, data) + self.station_profile.admin_down() - def cleanup(self, sta_list): + def pre_cleanup(self): + self.cx_profile.cleanup_prefix() + for sta in self.sta_list: + self.local_realm.rm_port(sta, check_exists=True) + + def cleanup(self): self.cx_profile.cleanup() - self.station_profile.cleanup(self.resource, sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup() + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.station_profile.station_names, debug=self.debug) def build(self): + self.station_profile.use_security(self.security, self.ssid, self.password) self.station_profile.set_number_template(self.number_template) print("Creating stations") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - temp_sta_list = [] - for station in range(len(self.sta_list)): - temp_sta_list.append(str(self.resource) + "." + self.sta_list[station]) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) - self.cx_profile.create(endp_type="lf_udp6", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.5) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) + self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream, + sleep_time=0) self._pass("PASS: Station build finished") def main(): - lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ip_var_test = IPV6VariableTime(lfjson_host, lfjson_port, number_template="00", sta_list=station_list, - name_prefix="var_time", - ssid="jedway-wpa2-x2048-4-4", - password="jedway-wpa2-x2048-4-4", - resource=1, security="wpa2", test_duration="5m", - side_a_min_rate=256, side_b_min_rate=256) - ip_var_test.cleanup(station_list) + + parser = LFCliBase.create_basic_argparse( + prog='test_ipv6_variable_time.py', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ +test_ipv6_variable_time.py: +-------------------- +TBD + +Generic command layout: +python ./test_ipv6_variable_time.py --upstream_port --radio --debug + +Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv6_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) + parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) + parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") + + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ip_var_test = IPV6VariableTime(args.mgr, lfjson_port, number_template="00", sta_list=station_list, + name_prefix="VT", + upstream=args.upstream_port, + ssid=args.ssid, + password=args.passwd, + radio=args.radio, + security=args.security, test_duration=args.test_duration, use_ht160=False, + side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug) + + ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) @@ -176,7 +214,7 @@ def main(): print(ip_var_test.get_fail_message()) exit(1) time.sleep(30) - ip_var_test.cleanup(station_list) + ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes") From c14c033ad7a202e91cca74f66c0387cb17adf008 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 16:09:33 -0700 Subject: [PATCH 105/134] cisco-ctlr: Add examples for LANforge lab, allow specifying prompt. --- cisco_wifi_ctl.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 6caa9687..fe6ca76e 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -11,7 +11,11 @@ $ sudo yum install python3-pexpect You might need to install pexpect-serial using pip: $ pip3 install pexpect-serial -./cisco_wifi_ctl.py -d 172.19.27.95 -o 2013 -l stdout -a AxelMain -u cisco -p Cisco123 -s telnet +./cisco_wifi_ctl.py -d 172.19.27.95 -o 2013 -l stdout -a AxelMain -u cisco -p Cisco123 -s telnet + +# For LANforge lab system. +./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action summary --prompt "\(Cisco Controller\) >" + ''' @@ -46,6 +50,7 @@ def usage(): print("$0 used connect to controller:") print("-d|--dest: destination host") print("-o|--port: destination port") + print("--prompt: prompt to expect, ie \"\\(Cisco Controller\\) >\"") print("-u|--user: login name") print("-p|--pass: password") print("-s|--scheme (serial|telnet|ssh): connect via serial, ssh or telnet") @@ -71,6 +76,7 @@ def main(): parser = argparse.ArgumentParser(description="Cisco AP Control Script") parser.add_argument("-d", "--dest", type=str, help="address of the cisco controller") parser.add_argument("-o", "--port", type=int, help="control port on the controller") + parser.add_argument("--prompt", type=str, help="Prompt to expect", default="\(Cisco Controller\) >") parser.add_argument("-u", "--user", type=str, help="credential login/username") parser.add_argument("-p", "--passwd", type=str, help="credential password") parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet"], help="Connect via serial, ssh or telnet") @@ -187,12 +193,14 @@ def main(): command = None time.sleep(0.1) - CCPROMPT = '\(Voice-Talwar\) >' + CCPROMPT = args.prompt #'\(Voice-Talwar\) >' LOGOUTPROMPT = 'User:' EXITPROMPT = "Would you like to save them now\? \(y/N\)" AREYOUSURE = "Are you sure you want to continue\? \(y/n\)" CLOSEDBYREMOTE = "closed by remote host." CLOSEDCX = "Connection to .* closed." + + logg.info("waiting for prompt: %s"%(CCPROMPT)) egg.expect(CCPROMPT) logg.info("Ap[%s] Action[%s] Value[%s] "%(args.ap, args.action, args.value)) From 2ce659c385c4aa766918a088549d160a076db592 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Thu, 6 Aug 2020 16:13:04 -0700 Subject: [PATCH 106/134] Updated script to use new arg parsing methods --- py-scripts/test_ipv6_connection.py | 71 +++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/py-scripts/test_ipv6_connection.py b/py-scripts/test_ipv6_connection.py index e9829548..91823620 100755 --- a/py-scripts/test_ipv6_connection.py +++ b/py-scripts/test_ipv6_connection.py @@ -11,14 +11,15 @@ if 'py-json' not in sys.path: import LANforge from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils +import argparse import realm import time import pprint class IPv6Test(LFCliBase): - def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, num_stations=0, prefix="00000", - _debug_on=False, + def __init__(self, host, port, ssid, security, password, sta_list=None, num_stations=0, prefix="00000", + _debug_on=False, timeout=120, radio="wiphy0", _exit_on_error=False, _exit_on_fail=False, number_template="00"): @@ -26,12 +27,12 @@ class IPv6Test(LFCliBase): self.host = host self.port = port self.ssid = ssid + self.radio = radio self.security = security self.password = password self.num_stations = num_stations self.sta_list = sta_list - self.timeout = 120 - self.resource = resource + self.timeout = timeout self.prefix = prefix self.debug = _debug_on self.number_template = number_template @@ -52,17 +53,21 @@ class IPv6Test(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") def start(self, sta_list, print_pass, print_fail): - self.station_profile.admin_up(1) + self.station_profile.admin_up() associated_map = {} ip_map = {} print("Starting test...") for sec in range(self.timeout): for sta_name in sta_list: - sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ipv6+address,ap", debug_=self.debug) + shelf = self.local_realm.name_to_eid(sta_name)[0] + resource = self.local_realm.name_to_eid(sta_name)[1] + name = self.local_realm.name_to_eid(sta_name)[2] + sta_status = self.json_get("port/%s/%s/%s?fields=port,alias,ipv6+address,ap" % (shelf, resource, name), + debug_=self.debug) # print(sta_status) if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None: continue @@ -95,26 +100,52 @@ class IPv6Test(LFCliBase): def stop(self): # Bring stations down - for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, sta_name) - url = "cli-json/set_port" - # print(sta_name) - self.json_post(url, data) + self.station_profile.admin_down() def cleanup(self, sta_list): - self.station_profile.cleanup(self.resource, sta_list) - LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list, + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) def main(): - lfjson_host = "localhost" lfjson_port = 8080 - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ipv6_test = IPv6Test(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4", - security="wpa2", sta_list=station_list) + + parser = LFCliBase.create_basic_argparse( + prog='test_ipv6_connection.py', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_ipv6_connection.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv6_connection.py --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv6_connection.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + + parser.add_argument('--timeout', help='--timeout sets the length of time to wait until a connection is successful', default=120) + + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ipv6_test = IPv6Test(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, + security=args.security, sta_list=station_list) ipv6_test.cleanup(station_list) - ipv6_test.timeout = 60 ipv6_test.build() if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) @@ -124,7 +155,7 @@ def main(): if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) exit(1) - time.sleep(30) + time.sleep(10) ipv6_test.cleanup(station_list) if ipv6_test.passes(): print("Full test passed, all stations associated and got IP") From 432334d60a9991abcc072fd56d6c933929d0cee7 Mon Sep 17 00:00:00 2001 From: Dipti Dhond Date: Thu, 6 Aug 2020 17:20:59 -0700 Subject: [PATCH 107/134] test ipv4 conn that combines wep, wpa, wpa2, wpa3 and open conn - completed --- py-scripts/test_ipv4_connection.py | 163 +++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 py-scripts/test_ipv4_connection.py diff --git a/py-scripts/test_ipv4_connection.py b/py-scripts/test_ipv4_connection.py new file mode 100644 index 00000000..0fddcd7c --- /dev/null +++ b/py-scripts/test_ipv4_connection.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python3 + + +import sys +import os +import argparse + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) +import LANforge +from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils +import realm +import time +import pprint + + +class IPv4Test(LFCliBase): + def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.ssid = ssid + self.security = security + self.password = password + self.sta_list = sta_list + self.timeout = 120 + self.number_template = number_template + self.debug = _debug_on + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.password, + self.station_profile.security = self.security + self.station_profile.number_template_ = self.number_template + self.station_profile.mode = 0 + + def build(self): + # Build stations + self.station_profile.use_security(self.security, self.ssid, self.password) + self.station_profile.set_number_template(self.number_template) + print("Creating stations") + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self._pass("PASS: Station build finished") + + def start(self, sta_list, print_pass, print_fail): + self.station_profile.admin_up() + associated_map = {} + ip_map = {} + print("Starting test...") + for sec in range(self.timeout): + for sta_name in sta_list: + sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug) + # print(sta_status) + if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None: + continue + if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':': + # print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip']) + associated_map[sta_name] = 1 + if sta_status['interface']['ip'] != '0.0.0.0': + # print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip']) + ip_map[sta_name] = 1 + if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)): + break + else: + time.sleep(1) + + if self.debug: + print("sta_list", len(sta_list), sta_list) + print("ip_map", len(ip_map), ip_map) + print("associated_map", len(associated_map), associated_map) + if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)): + self._pass("PASS: All stations associated with IP", print_pass) + else: + self._fail("FAIL: Not all stations able to associate/get IP", print_fail) + print("sta_list", sta_list) + print("ip_map", ip_map) + print("associated_map", associated_map) + + return self.passes() + + def stop(self): + # Bring stations down + for sta_name in self.sta_list: + data = LFUtils.portDownRequest(1, sta_name) + url = "cli-json/set_port" + # print(sta_name) + self.json_post(url, data) + + def cleanup(self, sta_list): + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, + debug=self.debug) + +def main(): + #Params for different tests: + # + # + # + # + # + lfjson_host = "localhost" + lfjson_port = 8080 + + parser = LFCliBase.create_basic_argparse( + prog='test_ipv4_connection.py', + #formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_ipv4_variable_tim.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv4_variable_time.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + + args = parser.parse_args() + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) + ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, + security=args.security, sta_list=station_list) + ip_test.cleanup(station_list) + #ip_test.timeout = 60 + ip_test.build() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + ip_test.start(station_list, False, False) + ip_test.stop() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + time.sleep(30) + ip_test.cleanup(station_list) + if ip_test.passes(): + print("Full test passed, all stations associated and got IP") + + +if __name__ == "__main__": + main() From b711e1b99ed6272d3ebfe203fdf0169744b8dc26 Mon Sep 17 00:00:00 2001 From: Dipti Dhond Date: Thu, 6 Aug 2020 17:22:22 -0700 Subject: [PATCH 108/134] additional security descriptions in help --- py-json/LANforge/lfcli_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index b0b27182..da027ce8 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -221,7 +221,7 @@ class LFCliBase: parser.add_argument('--radio', help='--radio ', default='wiphy2') parser.add_argument('--ssid', help='--ssid ', default='jedway-wpa2-160') parser.add_argument('--passwd', help='--passwd ', default='jedway-wpa2-160') - parser.add_argument('--security', help='--security ', default='wpa2') + parser.add_argument('--security', help='--security ', default='wpa2') parser.add_argument('--debug', help='--debug: Enable debugging', default=False, action="store_true") return parser From e2c79832e9f0358813d54c5ba05ca34f5c6e9210 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 6 Aug 2020 17:58:10 -0700 Subject: [PATCH 109/134] longevity: Fix initial port cleanup. Quieten some output by default. --- cisco_wifi_ctl.py | 2 +- py-json/realm.py | 29 +++++++++----- py-scripts/test_l3_longevity.py | 69 +++++++++++++++++++++++++++++++-- 3 files changed, 85 insertions(+), 15 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index fe6ca76e..725af2fb 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -15,7 +15,7 @@ $ pip3 install pexpect-serial # For LANforge lab system. ./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action summary --prompt "\(Cisco Controller\) >" - +./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action cmd --value "show ap config general APA453.0E7B.CF9C" ''' diff --git a/py-json/realm.py b/py-json/realm.py index 271f9647..92129667 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -140,6 +140,8 @@ class Realm(LFCliBase): data["resource"] = eid[1] data["port"] = eid[2] self.json_post(req_url, data, debug_=True) #self.debug) + return True + return False def port_exists(self, port_eid): data = {} @@ -271,7 +273,7 @@ class Realm(LFCliBase): response = super().json_get("/cx") return response - def waitUntilEndpsAppear(self, these_endp): + def waitUntilEndpsAppear(self, these_endp, debug=False): wait_more = True; count = 0 while wait_more: @@ -286,7 +288,8 @@ class Realm(LFCliBase): for req in these_endp: if not req in found_endps: - print("Waiting on endpoint: %s"%(req)) + if debug: + print("Waiting on endpoint: %s"%(req)) wait_more = True count += 1 if (count > 100): @@ -294,7 +297,7 @@ class Realm(LFCliBase): return not wait_more - def waitUntilCxsAppear(self, these_cx): + def waitUntilCxsAppear(self, these_cx, debug=False): wait_more = True; count = 0 while wait_more: @@ -310,7 +313,8 @@ class Realm(LFCliBase): for req in these_cx: if not req in found_cxs: - print("Waiting on CX: %s"%(req)) + if debug: + print("Waiting on CX: %s"%(req)) wait_more = True count += 1 if (count > 100): @@ -448,7 +452,7 @@ class Realm(LFCliBase): def name_to_eid(self, eid): return LFUtils.name_to_eid(eid) - def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): + def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60, debug=False): print("Waiting for ips, timeout: %i..."%(timeout_sec)) #print(station_list) @@ -460,7 +464,8 @@ class Realm(LFCliBase): wait_more = False for sta_eid in station_list: - print("checking sta-eid: %s"%(sta_eid)) + if debug: + print("checking sta-eid: %s"%(sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % @@ -477,19 +482,23 @@ class Realm(LFCliBase): v = response['interface'] if v['ip'] == '0.0.0.0': wait_more = True - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + if debug: + print("Waiting for port %s to get IPv4 Address."%(sta_eid)) else: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + if debug: + print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) if ipv6: v = response['interface'] print(v) if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ and v['ipv6 address'] != 'AUTO': - print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) + if debug: + print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) else: wait_more = True - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + if debug: + print("Waiting for port %s to get IPv6 Address."%(sta_eid)) if wait_more: time.sleep(1) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index e1b29203..70060777 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -16,9 +16,12 @@ from LANforge import LFUtils import realm import time import datetime +import subprocess +import re + class L3VariableTimeLongevity(LFCliBase): - def __init__(self, host, port, endp_types, tos, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + def __init__(self, host, port, endp_types, args, tos, side_b, radios, radio_name_list, number_of_stations_per_radio_list, ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, debug_on, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, @@ -46,6 +49,7 @@ class L3VariableTimeLongevity(LFCliBase): self.multicast_profile = self.local_realm.new_multicast_profile() self.multicast_profile.name_prefix = "MLT-"; self.station_profiles = [] + self.args = args index = 0 for radio in radios: @@ -112,6 +116,38 @@ class L3VariableTimeLongevity(LFCliBase): print("new-list:",old_list) return False + def verify_controller(self): + if self.args == None: + return + + if self.args.cisco_ctlr == None: + return + + advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap, "--action", "summary"], capture_output=True) + pss = advanced.stdout.decode('utf-8', 'ignore'); + print(pss) + + # Find our station count + searchap = False + for line in pss.splitlines(): + if (line.startswith("---------")): + searchap = True + continue + + if (searchap): + pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+.* \S+\s+\S+\s+(\S+)\s+\["%(self.args.cisco_ap) + #print("AP line: %s"%(line)) + m = re.search(pat, line) + if (m != None): + sta_count = m.group(1) + print("AP line: %s"%(line)) + print("sta-count: %s"%(sta_count)) + if (sta_count != self.total_stas): + print("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) + + def start(self, print_pass=False, print_fail=False): print("Bringing up stations") up_request = self.local_realm.admin_up(self.side_b) @@ -130,6 +166,8 @@ class L3VariableTimeLongevity(LFCliBase): else: print("print failed to get IP's") + self.verify_controller() + print("Starting multicast traffic (if any configured)") self.multicast_profile.start_mc(debug_=self.debug) self.multicast_profile.refresh_mc(debug_=self.debug) @@ -177,9 +215,25 @@ class L3VariableTimeLongevity(LFCliBase): def pre_cleanup(self): self.cx_profile.cleanup_prefix() self.multicast_profile.cleanup_prefix() + self.total_stas = 0 for station_list in self.station_lists: for sta in station_list: self.local_realm.rm_port(sta, check_exists=True) + self.total_stas += 1 + + # Make sure they are gone + count = 0 + while (count < 10): + more = False + for station_list in self.station_lists: + for sta in station_list: + rv = self.local_realm.rm_port(sta, check_exists=True) + if (rv): + more = True + if not more: + break + count += 1 + time.sleep(5) def cleanup(self): self.cx_profile.cleanup() @@ -296,7 +350,13 @@ Note: multiple --radio switches may be entered up to the number of radios avai ''') - + + parser.add_argument('--cisco_ctlr', help='--cisco_ctlr ',default=None) + parser.add_argument('--cisco_user', help='--cisco_user ',default="admin") + parser.add_argument('--cisco_passwd', help='--cisco_passwd ',default="Cisco123") + parser.add_argument('--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") + parser.add_argument('--cisco_ap', help='--cisco_ap ',default="APA453.0E7B.CF9C") + parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') parser.add_argument('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") @@ -369,8 +429,9 @@ Note: multiple --radio switches may be entered up to the number of radios avai #print("endp-types: %s"%(endp_types)) - ip_var_test = L3VariableTimeLongevity(lfjson_host, - lfjson_port, + ip_var_test = L3VariableTimeLongevity(lfjson_host, + lfjson_port, + args=args, number_template="00", station_lists= station_lists, name_prefix="LT-", From a7eb40abfde5d9d8290f01a3ca241c1e74007f17 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 6 Aug 2020 22:33:41 -0700 Subject: [PATCH 110/134] realm.py: Fixes 404s that did not call /thing/list --- py-json/realm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 92129667..65f62d85 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -217,7 +217,7 @@ class Realm(LFCliBase): if cx_name.startswith(prefix): self.rm_cx(cx_name) - endp_list = self.json_get("/endp") + endp_list = self.json_get("/endp/list") if endp_list is not None: endp_list = list(endp_list['endpoint']) for idx in range(len(endp_list)): @@ -270,7 +270,7 @@ class Realm(LFCliBase): # Returns json response from webpage of all layer 3 cross connects def cx_list(self): - response = super().json_get("/cx") + response = self.json_get("/cx/list") return response def waitUntilEndpsAppear(self, these_endp, debug=False): @@ -278,7 +278,7 @@ class Realm(LFCliBase): count = 0 while wait_more: wait_more = False - endp_list = self.json_get("/endp") + endp_list = self.json_get("/endp/list") found_endps = {} if endp_list is not None: endp_list = list(endp_list['endpoint']) @@ -546,7 +546,7 @@ class Realm(LFCliBase): self.json_post(req_url, data) def remove_all_endps(self): - endp_list = self.json_get("/endp") + endp_list = self.json_get("/endp/list") if endp_list is not None: print("Removing all endps") endp_list = list(endp_list['endpoint']) From 063c15e6a9e882a5b4e9004f689a90db30bbcee9 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 6 Aug 2020 22:43:55 -0700 Subject: [PATCH 111/134] realm.py: adds gaurd to test if we're getting a no items --- py-json/realm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 65f62d85..1124d4f4 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -547,7 +547,9 @@ class Realm(LFCliBase): def remove_all_endps(self): endp_list = self.json_get("/endp/list") - if endp_list is not None: + if "items" in endp_list: + return + if endp_list is not None or endp_list : print("Removing all endps") endp_list = list(endp_list['endpoint']) for endp_name in range(len(endp_list)): @@ -1341,7 +1343,7 @@ class WifiMonitor: self.aid = "NA" # used when sniffing /ax radios self.bsssid = "00:00:00:00:00:00" # used when sniffing on /ax radios - def create(self, resource_=1,channel=None, radio_="wiphy0", name_="moni0" ): + def create(self, resource_=1, channel=None, radio_="wiphy0", name_="moni0" ): print("Creating monitor " + name_) self.monitor_name = name_ computed_flags = 0 From b12a40f4d6d0d091b001c786bc69dbbc31859870 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 6 Aug 2020 22:44:37 -0700 Subject: [PATCH 112/134] tip_station_powersave.py: fixes 'resources' parameters, some gaurds --- py-scripts/tip_station_powersave.py | 38 +++++++++++++---------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index a7afb8b6..c28fbd16 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -131,34 +131,32 @@ class TIPStationPowersave(LFCliBase): channel=self.channel, radio_=self.monitor_radio, name_=self.monitor_name) - LFUtils.wait_until_ports_appear(resource_id=1, - base_url=self.local_realm.lfclient_url, + LFUtils.wait_until_ports_appear(base_url=self.local_realm.lfclient_url, port_list=[self.monitor_name]) time.sleep(0.2) mon_j = self.json_get("/port/1/%s/%s"%(self.resource, self.monitor_name)) if ("interface" not in mon_j): raise ValueError("No monitor found") - self.sta_powersave_disabled_profile.create(resource=1, - radio=self.normal_sta_radio, + self.sta_powersave_disabled_profile.create(radio=self.normal_sta_radio, sta_names_=self.normal_sta_list, debug=self.debug, suppress_related_commands_=True) - self.sta_powersave_enabled_profile.create(resource=1, - radio=self.powersave_sta_radio, - sta_names_=self.powersave_sta_list, - debug=self.debug, - suppress_related_commands_=True) + self.sta_powersave_enabled_profile.create(radio=self.powersave_sta_radio, + sta_names_=self.powersave_sta_list, + debug=self.debug, + suppress_related_commands_=True) temp_sta_map = {} for name in self.powersave_sta_list + self.normal_sta_list: - if (name in self.sta_powersave_disabled_profile.station_names) \ - or (name in self.sta_powersave_enabled_profile.station_names): temp_sta_map[name]=1 print("Stations we want:") pprint.pprint(temp_sta_map) - self.local_realm.wait_until_ports_appear(self.resource, temp_sta_map.keys()) + if len(temp_sta_map) < 1: + self._fail("Misconfigured build(), bye", print_=True) + exit(1) + self.local_realm.wait_until_ports_appear(temp_sta_map.keys()) if len(temp_sta_map) == (len(self.sta_powersave_disabled_profile.station_names) + len(self.sta_powersave_enabled_profile.station_names)): self._pass("Stations created", print_=True) @@ -247,11 +245,9 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_disabled_profile.admin_up(resource=1) self.sta_powersave_enabled_profile.admin_up(resource=1) - LFUtils.wait_until_ports_admin_up(resource_id=self.resource, - base_url=self.local_realm.lfclient_url, + LFUtils.wait_until_ports_admin_up(base_url=self.local_realm.lfclient_url, port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) - self.local_realm.wait_for_ip(resource=self.resource, - station_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + self.local_realm.wait_for_ip(station_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) time.sleep(2) self.cx_prof_bg.start_cx() print("Upload starts at: %d"%time.time()) @@ -274,8 +270,8 @@ class TIPStationPowersave(LFCliBase): self.wifi_monitor_profile.admin_down() self.cx_prof_download.stop_cx() self.cx_prof_upload.stop_cx() - self.sta_powersave_enabled_profile.admin_down(self.resource) - self.sta_powersave_disabled_profile.admin_down(self.resource) + self.sta_powersave_enabled_profile.admin_down() + self.sta_powersave_disabled_profile.admin_down() # check for that pcap file if self.pcap_file is None: @@ -292,12 +288,12 @@ class TIPStationPowersave(LFCliBase): def cleanup(self): - self.wifi_monitor_profile.cleanup(resource_=self.resource, desired_ports=[self.monitor_name]) + self.wifi_monitor_profile.cleanup(desired_ports=[self.monitor_name]) #self.cx_prof_download.cleanup() self.local_realm.remove_all_cxs(remove_all_endpoints=True) #self.cx_prof_upload.cleanup() - self.sta_powersave_enabled_profile.cleanup(resource=self.resource, desired_stations=self.powersave_sta_list) - self.sta_powersave_disabled_profile.cleanup(resource=self.resource, desired_stations=self.normal_sta_list) + self.sta_powersave_enabled_profile.cleanup(desired_stations=self.powersave_sta_list) + self.sta_powersave_disabled_profile.cleanup(desired_stations=self.normal_sta_list) def main(): lfjson_host = "localhost" From 8b50c3585478c7e787037634beb679598640a59c Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 6 Aug 2020 23:03:24 -0700 Subject: [PATCH 113/134] realm.py: fixes loops that expire without actually doing time.sleep()... - adds snake_case methods for some wait methods - adds tiny sleep when adding cross connects - passes around debug flag --- py-json/realm.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 1124d4f4..2425407c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -274,13 +274,17 @@ class Realm(LFCliBase): return response def waitUntilEndpsAppear(self, these_endp, debug=False): + return self.wait_until_endps_appear(these_endp, debug=debug) + + def wait_until_endps_appear(self, these_endp, debug=False): wait_more = True; count = 0 while wait_more: + time.sleep(1) wait_more = False endp_list = self.json_get("/endp/list") found_endps = {} - if endp_list is not None: + if (endp_list is not None) and ("items" not in endp_list): endp_list = list(endp_list['endpoint']) for idx in range(len(endp_list)): name = list(endp_list[idx])[0] @@ -298,9 +302,13 @@ class Realm(LFCliBase): return not wait_more def waitUntilCxsAppear(self, these_cx, debug=False): + return self.wait_until_cxs_appear(these_cx, debug=debug) + + def wait_until_cxs_appear(self, these_cx, debug=False): wait_more = True; count = 0 while wait_more: + time.sleep(1) wait_more = False found_cxs = {} cx_list = self.cx_list() @@ -703,7 +711,7 @@ class MULTICASTProfile(LFCliBase): for endp_name in self.get_mc_names(): self.local_realm.rm_endp(endp_name, debug_=debug_, suppress_related_commands_=suppress_related_commands) - def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_ = False ): + def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_=False): if self.debug: debug_=True @@ -754,7 +762,7 @@ class MULTICASTProfile(LFCliBase): self.created_mc[side_tx_name] = side_tx_name these_endp = [side_tx_name] - self.local_realm.waitUntilEndpsAppear(these_endp) + self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_ = False): @@ -806,7 +814,7 @@ class MULTICASTProfile(LFCliBase): self.created_mc[side_rx_name] = side_rx_name these_endp.append(side_rx_name) - self.local_realm.waitUntilEndpsAppear(these_endp) + self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) def to_string(self): pprint.pprint(self) @@ -1021,7 +1029,7 @@ class L3CXProfile(LFCliBase): cx_name = "%s%s-%i" % (self.name_prefix, port_name, len(self.created_cx)) endp_a_name = cx_name + "-A"; - endp_b_name = ex_name + "-B"; + endp_b_name = cx_name + "-B"; self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name; self.created_endp[endp_b_name] = endp_b_name; @@ -1069,7 +1077,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": enb, + "name": endp_a_name, "flag": "autohelper", "val": 1 } @@ -1090,16 +1098,14 @@ class L3CXProfile(LFCliBase): else: raise ValueError("side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (type(side_a), type(side_b))) - #print("post_data", cx_post_data) + self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) + for data in cx_post_data: url = "/cli-json/add_cx" self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print(" napping %f sec"%sleep_time, end='') - #time.sleep(sleep_time) - #print("") + time.sleep(0.01) - self.local_realm.waitUntilEndpsAppear(these_endp) - self.local_realm.waitUntilCxsAppear(these_cx) + self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_) def to_string(self): pprint.pprint(self) From 10638681b874db421cacc326d0e65205d526b22e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 6 Aug 2020 23:03:49 -0700 Subject: [PATCH 114/134] tip_station_powersave.py: removes more resource parameters --- py-scripts/tip_station_powersave.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index c28fbd16..483c3d6c 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -242,8 +242,8 @@ class TIPStationPowersave(LFCliBase): self.wifi_monitor_profile.start_sniff(self.pcap_file, capture_duration) time.sleep(0.05) - self.sta_powersave_disabled_profile.admin_up(resource=1) - self.sta_powersave_enabled_profile.admin_up(resource=1) + self.sta_powersave_disabled_profile.admin_up() + self.sta_powersave_enabled_profile.admin_up() LFUtils.wait_until_ports_admin_up(base_url=self.local_realm.lfclient_url, port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) From 344dc92699c0d85425c65660d2ad190f0681f66e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 08:16:09 -0700 Subject: [PATCH 115/134] realm.py: fixes side-a to side-b typo --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 2425407c..49a26fa4 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1077,7 +1077,7 @@ class L3CXProfile(LFCliBase): url = "cli-json/set_endp_flag" data = { - "name": endp_a_name, + "name": endp_b_name, "flag": "autohelper", "val": 1 } From 9c679d27836c764d0191e6db6029e6fd1ec0b4ac Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 08:18:11 -0700 Subject: [PATCH 116/134] tip_station_powersave.py: adds new way of testing for no results --- py-scripts/tip_station_powersave.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 483c3d6c..6a453df2 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -197,7 +197,8 @@ class TIPStationPowersave(LFCliBase): print("Collecting lanforge eth0 IP...") eth0_resp = self.json_get("/port/1/%s/eth0?fields=port,alias,ip"%self.resource, debug_=self.debug) - if (eth0_resp is None) or ("items" in eth0_resp) or ("interface" not in eth0_resp): + # would be nice to have a not_found() kind of method + if (eth0_resp is None) or ("items" in eth0_resp) or ("empty" in eth0_resp) or ("interface" not in eth0_resp): self._fail("Unable to query %s.eth0"%self.resource, print_=True) exit(1) self.eth0_ip = eth0_resp["interface"]["ip"] From 800f774a5d6a8dc3bebefcabd6d0809077e10386 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 7 Aug 2020 10:04:31 -0600 Subject: [PATCH 117/134] try except added when no endpoint in endp_list --- py-json/realm.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 49a26fa4..80f76c43 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -219,11 +219,14 @@ class Realm(LFCliBase): endp_list = self.json_get("/endp/list") if endp_list is not None: - endp_list = list(endp_list['endpoint']) - for idx in range(len(endp_list)): - endp_name = list(endp_list[idx])[0] - if endp_name.startswith(prefix): - self.rm_endp(endp_name) + try: + endp_list = list(endp_list['endpoint']) + for idx in range(len(endp_list)): + endp_name = list(endp_list[idx])[0] + if endp_name.startswith(prefix): + self.rm_endp(endp_name) + except: + print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list) ) def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] From 78f2d3daa8c6481dee2ea48d3dd983edce7401b3 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 7 Aug 2020 10:29:56 -0600 Subject: [PATCH 118/134] added check to see if 'end_point' in endp_list --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 80f76c43..7a2ece18 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -219,13 +219,13 @@ class Realm(LFCliBase): endp_list = self.json_get("/endp/list") if endp_list is not None: - try: + if 'endpoint' in endp_list: endp_list = list(endp_list['endpoint']) for idx in range(len(endp_list)): endp_name = list(endp_list[idx])[0] if endp_name.startswith(prefix): self.rm_endp(endp_name) - except: + else: print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list) ) def channel_freq(self, channel_=0): From f0dd5a389b2ff89effe81245bab5a582001cce31 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 10:16:38 -0700 Subject: [PATCH 119/134] Added upstream port to object creation --- py-scripts/test_ipv4_l4_ftp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4_ftp.py b/py-scripts/test_ipv4_l4_ftp.py index 4ac62f1d..38ae3ced 100755 --- a/py-scripts/test_ipv4_l4_ftp.py +++ b/py-scripts/test_ipv4_l4_ftp.py @@ -189,7 +189,7 @@ def main(): ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, security=args.security, station_list=station_list, url=args.url, test_duration=args.test_duration, - requests_per_ten=args.requests_per_ten, _debug_on=args.debug) + requests_per_ten=args.requests_per_ten, _debug_on=args.debug, upstream_port=args.upstream_port) ip_test.cleanup(station_list) ip_test.build() if not ip_test.passes(): From 1c23dc0a49d8ec4cfd67c96411e7193cc786c05d Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 7 Aug 2020 11:35:17 -0700 Subject: [PATCH 120/134] longevity: Fix station count comparison. Evidently, cannot compare a string to an int and get expected result, so cast to int explicitly. Signed-off-by: Ben Greear --- py-scripts/test_l3_longevity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 70060777..9245818b 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -144,7 +144,7 @@ class L3VariableTimeLongevity(LFCliBase): sta_count = m.group(1) print("AP line: %s"%(line)) print("sta-count: %s"%(sta_count)) - if (sta_count != self.total_stas): + if (int(sta_count) != int(self.total_stas)): print("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) From 43572b418f9d79b973c0d15d07ee73fade710eae Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 11:45:31 -0700 Subject: [PATCH 121/134] Fixed upstream port name for setting ftp --- py-scripts/test_ipv4_l4_ftp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py-scripts/test_ipv4_l4_ftp.py b/py-scripts/test_ipv4_l4_ftp.py index 38ae3ced..f53a43d3 100755 --- a/py-scripts/test_ipv4_l4_ftp.py +++ b/py-scripts/test_ipv4_l4_ftp.py @@ -98,9 +98,9 @@ class IPV4L4(LFCliBase): self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=True) def start(self, print_pass=False, print_fail=False): - self.port_util.set_ftp(port_name=self.upstream_port, resource=1, on=True) + self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=True) temp_stas = self.sta_list.copy() - temp_stas.append(self.upstream_port) + temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: @@ -137,7 +137,7 @@ class IPV4L4(LFCliBase): self._pass("PASS: All tests passes", print_pass) def stop(self): - self.port_util.set_ftp(port_name=self.upstream_port, resource=1, on=False) + self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=False) self.cx_profile.stop_cx() for sta_name in self.sta_list: data = LFUtils.portDownRequest(1, self.local_realm.name_to_eid(sta_name)[2]) From ee46137890ba90090d867d059bf8acc3f43988da Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 11:52:00 -0700 Subject: [PATCH 122/134] Added upstream port param --- py-scripts/test_ipv4_l4.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index b3a5c588..0458cf8d 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -22,7 +22,7 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, number_template="00000", radio="wiphy0", - test_duration="5m", + test_duration="5m", upstream_port="eth1", _debug_on=False, _exit_on_error=False, _exit_on_fail=False): @@ -30,6 +30,7 @@ class IPV4L4(LFCliBase): self.host = host self.port = port self.radio = radio + self.upstream_port = upstream_port self.ssid = ssid self.security = security self.password = password @@ -99,7 +100,7 @@ class IPV4L4(LFCliBase): def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() - temp_stas.append("eth1") + temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: @@ -188,7 +189,7 @@ def main(): ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, security=args.security, station_list=station_list, url=args.url, - test_duration=args.test_duration, + test_duration=args.test_duration, upstream_port=args.upstream_port, requests_per_ten=args.requests_per_ten, _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() From 68b13e39c5d5bd3695d71f83e5850db8dc5067a2 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 11:53:10 -0700 Subject: [PATCH 123/134] Added upstream port param --- py-scripts/test_ipv4_l4_urls_per_ten.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index fe90bdc1..c5fd88ee 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -21,13 +21,14 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, target_requests_per_ten=60, number_template="00000", num_tests=1, radio="wiphy0", - _debug_on=False, + _debug_on=False, upstream_port="eth1", _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.radio = radio + self.upstream_port = upstream_port self.ssid = ssid self.security = security self.password = password @@ -81,7 +82,7 @@ class IPV4L4(LFCliBase): def start(self, print_pass=False, print_fail=False): temp_stas = self.sta_list.copy() - temp_stas.append("eth1") + temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) cur_time = datetime.datetime.now() interval_time = cur_time + datetime.timedelta(minutes=10) passes = 0 @@ -165,7 +166,7 @@ def main(): station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, radio=args.radio) - ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, + ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, upstream_port=args.upstream_port, security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests, target_requests_per_ten=args.target_per_ten, requests_per_ten=args.requests_per_ten) From 43bda976ff54e9ee4ff7aaff163ce3af1e0be08f Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 16:00:58 -0700 Subject: [PATCH 124/134] Changed file name to show upload, reordered start function, added radio arg --- ...pv4_l4_ftp.py => test_ipv4_l4_ftp_upload.py} | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) rename py-scripts/{test_ipv4_l4_ftp.py => test_ipv4_l4_ftp_upload.py} (92%) diff --git a/py-scripts/test_ipv4_l4_ftp.py b/py-scripts/test_ipv4_l4_ftp_upload.py similarity index 92% rename from py-scripts/test_ipv4_l4_ftp.py rename to py-scripts/test_ipv4_l4_ftp_upload.py index f53a43d3..d5ea42d8 100755 --- a/py-scripts/test_ipv4_l4_ftp.py +++ b/py-scripts/test_ipv4_l4_ftp_upload.py @@ -20,7 +20,7 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, number_template="00000", - upstream_port="eth1", + upstream_port="eth1", radio="wiphy0", test_duration="5m", _debug_on=False, _exit_on_error=False, @@ -29,6 +29,7 @@ class IPV4L4(LFCliBase): self.host = host self.port = port self.ssid = ssid + self.radio = radio self.upstream_port = upstream_port self.security = security self.password = password @@ -80,7 +81,7 @@ class IPV4L4(LFCliBase): if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if item in self.cx_profile.created_cx.keys() and value_name == 'bytes-rd': + if item in self.cx_profile.created_cx.keys() and value_name == 'bytes-wr': cx_map[item] = value_rx return cx_map @@ -92,7 +93,7 @@ class IPV4L4(LFCliBase): self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) self._pass("PASS: Station build finished") self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=True) @@ -100,6 +101,7 @@ class IPV4L4(LFCliBase): def start(self, print_pass=False, print_fail=False): self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=True) temp_stas = self.sta_list.copy() + self.station_profile.admin_up() temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) @@ -109,7 +111,6 @@ class IPV4L4(LFCliBase): cur_time = datetime.datetime.now() old_rx_values = self.__get_values() end_time = self.local_realm.parse_time(self.test_duration) + cur_time - self.station_profile.admin_up() self.cx_profile.start_cx() passes = 0 expected_passes = 0 @@ -164,24 +165,24 @@ def main(): ''', description='''\ - test_ipv4_l4_ftp.py: + test_ipv4_l4_ftp_upload.py: -------------------- TBD Generic command layout: - python ./test_ipv4_l4_ftp.py --upstream_port --radio --debug + python ./test_ipv4_l4_ftp_upload.py --upstream_port --radio --debug Note: multiple --radio switches may be entered up to the number of radios available: --radio --radio - python3 ./test_ipv4_l4_ftp.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + python3 ./test_ipv4_l4_ftp_upload.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 ''') parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) parser.add_argument('--url', help='--url specifies upload/download, address, and dest', - default="dl ftp://10.40.0.1 /dev/null") + default="ul ftp://10.40.0.1 /dev/null") args = parser.parse_args() station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, From 799a577925a67a373ca0bc3d8556f35e9e671e8c Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 16:16:33 -0700 Subject: [PATCH 125/134] Added test for ftp urls/10 min --- py-scripts/test_ipv4_l4_ftp_urls_per_ten.py | 188 ++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 py-scripts/test_ipv4_l4_ftp_urls_per_ten.py diff --git a/py-scripts/test_ipv4_l4_ftp_urls_per_ten.py b/py-scripts/test_ipv4_l4_ftp_urls_per_ten.py new file mode 100755 index 00000000..2cd2fe6b --- /dev/null +++ b/py-scripts/test_ipv4_l4_ftp_urls_per_ten.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 + +import sys +import os +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) + +import argparse +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +from LANforge import LFUtils +import realm +import time +import datetime + + +class IPV4L4(LFCliBase): + def __init__(self, host, port, ssid, security, password, url, requests_per_ten, station_list, + target_requests_per_ten=60, number_template="00000", num_tests=1, radio="wiphy0", + _debug_on=False, upstream_port="eth1", + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.radio = radio + self.upstream_port = upstream_port + self.ssid = ssid + self.security = security + self.password = password + self.url = url + self.requests_per_ten = requests_per_ten + self.number_template = number_template + self.sta_list = station_list + self.num_tests = num_tests + self.target_requests_per_ten = target_requests_per_ten + + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + self.cx_profile = self.local_realm.new_l4_cx_profile() + + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.password, + self.station_profile.security = self.security + self.station_profile.number_template_ = self.number_template + self.station_profile.mode = 0 + self.cx_profile.url = self.url + self.cx_profile.requests_per_ten = self.requests_per_ten + + self.port_util = realm.PortUtils(self.local_realm) + + def __check_request_rate(self): + endp_list = self.json_get("layer4/list?fields=urls/s") + expected_passes = 0 + passes = 0 + if endp_list is not None and endp_list['endpoint'] is not None: + endp_list = endp_list['endpoint'] + for item in endp_list: + for name, info in item.items(): + if name in self.cx_profile.created_cx.keys(): + expected_passes += 1 + if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + passes += 1 + + return passes == expected_passes + + def build(self): + # Build stations + self.station_profile.use_security(self.security, self.ssid, self.password) + print("Creating stations") + self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) + self.station_profile.set_command_param("set_port", "report_timer", 1500) + self.station_profile.set_command_flag("set_port", "rpt_timer", 1) + self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) + self._pass("PASS: Station build finished") + + self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=None) + + def start(self, print_pass=False, print_fail=False): + self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=True) + temp_stas = self.sta_list.copy() + temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) + cur_time = datetime.datetime.now() + interval_time = cur_time + datetime.timedelta(minutes=10) + passes = 0 + expected_passes = 0 + self.station_profile.admin_up() + if self.local_realm.wait_for_ip(temp_stas): + self._pass("All stations got IPs", print_pass) + else: + self._fail("Stations failed to get IPs", print_fail) + exit(1) + self.cx_profile.start_cx() + print("Starting test") + for test in range(self.num_tests): + expected_passes += 1 + while cur_time < interval_time: + time.sleep(1) + cur_time = datetime.datetime.now() + + if self.cx_profile.check_errors(self.debug): + if self.__check_request_rate(): + passes += 1 + else: + self._fail("FAIL: Request rate did not exceed 90% target rate", print_fail) + break + else: + self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) + break + interval_time = cur_time + datetime.timedelta(minutes=10) + if passes == expected_passes: + self._pass("PASS: All tests passes", print_pass) + + def stop(self): + self.cx_profile.stop_cx() + self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=False) + self.station_profile.admin_down() + + def cleanup(self, sta_list): + self.cx_profile.cleanup() + self.station_profile.cleanup(sta_list) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, + debug=self.debug) + + +def main(): + lfjson_port = 8080 + + parser = LFCliBase.create_basic_argparse( + prog='test_ipv4_l4_urls_per_ten', + # formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + Useful Information: + 1. TBD + ''', + + description='''\ + test_ipv4_l4_urls_per_ten.py: + -------------------- + TBD + + Generic command layout: + python ./test_ipv4_l4_urls_per_ten.py --upstream_port --radio --debug + + Note: multiple --radio switches may be entered up to the number of radios available: + --radio --radio + + python3 ./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 + + ''') + + parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) + parser.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) + parser.add_argument('--url', help='--url specifies upload/download, address, and dest', + default="dl http://10.40.0.1 /dev/null") + parser.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90% this value', + default=600) + args = parser.parse_args() + + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000, + radio=args.radio) + + ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, upstream_port=args.upstream_port, + security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests, + target_requests_per_ten=args.target_per_ten, + requests_per_ten=args.requests_per_ten) + ip_test.cleanup(station_list) + ip_test.build() + ip_test.start() + ip_test.stop() + if not ip_test.passes(): + print(ip_test.get_fail_message()) + exit(1) + time.sleep(30) + ip_test.cleanup(station_list) + if ip_test.passes(): + print("Full test passed, all endpoints met or exceeded 90% of the target rate") + + +if __name__ == "__main__": + main() From 00039d772ba971f161c1148afd2b388a037d4b79 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 7 Aug 2020 16:16:58 -0700 Subject: [PATCH 126/134] Updated to use StationProfile.admin_down() --- py-scripts/test_ipv4_l4_ftp_upload.py | 5 +---- py-scripts/test_ipv4_l4_urls_per_ten.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/py-scripts/test_ipv4_l4_ftp_upload.py b/py-scripts/test_ipv4_l4_ftp_upload.py index d5ea42d8..25fc441f 100755 --- a/py-scripts/test_ipv4_l4_ftp_upload.py +++ b/py-scripts/test_ipv4_l4_ftp_upload.py @@ -140,10 +140,7 @@ class IPV4L4(LFCliBase): def stop(self): self.port_util.set_ftp(port_name=self.local_realm.name_to_eid(self.upstream_port)[2], resource=1, on=False) self.cx_profile.stop_cx() - for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, self.local_realm.name_to_eid(sta_name)[2]) - url = "cli-json/set_port" - self.json_post(url, data) + self.station_profile.admin_down() def cleanup(self, sta_list): self.cx_profile.cleanup() diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index c5fd88ee..d9d3b43e 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -116,10 +116,7 @@ class IPV4L4(LFCliBase): def stop(self): self.cx_profile.stop_cx() - for sta_name in self.sta_list: - data = LFUtils.portDownRequest(1, self.local_realm.name_to_eid(sta_name)[2]) - url = "cli-json/set_port" - self.json_post(url, data) + self.station_profile.admin_down() def cleanup(self, sta_list): self.cx_profile.cleanup() From aea67cb61fb7f4b4ab92a3c4874fe2ccf0dee20e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 12:40:18 -0700 Subject: [PATCH 127/134] realm.py: tests for 'empty' key for empty lists --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 7a2ece18..9c550523 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -558,7 +558,7 @@ class Realm(LFCliBase): def remove_all_endps(self): endp_list = self.json_get("/endp/list") - if "items" in endp_list: + if "items" in endp_list or "empty" in endp_list: return if endp_list is not None or endp_list : print("Removing all endps") @@ -578,7 +578,7 @@ class Realm(LFCliBase): # nc show cross connects try: cx_list = list(self.cx_list()) - not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] + not_cx = ['warnings', 'errors', 'handler', 'uri', 'items', 'empty'] if cx_list is not None: print("Removing all cxs") for cx_name in cx_list: From c39d50f69817e0f56f9c165e380a8e137080ff77 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 15:35:22 -0700 Subject: [PATCH 128/134] realm.py: improves delay for rm port and rm port formatting --- py-json/realm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 9c550523..36f52a23 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -128,18 +128,18 @@ class Realm(LFCliBase): def rm_port(self, port_eid, check_exists=True): req_url = "/cli-json/rm_vlan" - data = {} - eid = self.name_to_eid(port_eid) do_rm = True; if check_exists: if not self.port_exists(port_eid): do_rm = False if do_rm: - data["shelf"] = eid[0] - data["resource"] = eid[1] - data["port"] = eid[2] - self.json_post(req_url, data, debug_=True) #self.debug) + data = { + "shelf": eid[0], + "resource": eid[1], + "port": eid[2] + } + rsp = self.json_post(req_url, data, debug_=self.debug) return True return False @@ -1985,10 +1985,11 @@ class StationProfile: if not current_stations is None: found_one = True self.local_realm.rm_port(port_eid, check_exists=False) + time.sleep(delay) if not found_one: return count = count + 1 - time.sleep(1) + # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=True, sleep_time=2): From 88a60f3bda49815bdf7f0a1574464674b1017be9 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 16:19:36 -0700 Subject: [PATCH 129/134] LFRequest.py: whitespace --- py-json/LANforge/LFRequest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index b561c828..36b59eac 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -20,8 +20,7 @@ class LFRequest: No_Data = {'No Data':0} requested_url = "" post_data = No_Data - default_headers = { - 'Accept': 'application/json'} + default_headers = { 'Accept': 'application/json'} def __init__(self, url, uri=None, debug_=False, die_on_error_=False): self.debug = debug_ From c84061de9619e6dc21a5dbcfdfcc1bb37cbac469 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 16:20:07 -0700 Subject: [PATCH 130/134] LFUtils.py: correct post method, should have been jsonPost --- py-json/LANforge/LFUtils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 8fb8757e..a5d40a60 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -422,7 +422,6 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu while len(found_stations) < len(port_list): found_stations = [] for port_eid in port_list: - eid = name_to_eid(port_eid) shelf = eid[0] resource_id = eid[1] @@ -435,8 +434,8 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu found_stations.append(port_name) else: lf_r = LFRequest.LFRequest(base_url, ncshow_url) - lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "flags": 1}) - lf_r.formPost() + lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "flags": "1"}) + lf_r.jsonPost() if (len(found_stations) < len(port_list)): sleep(2) From 9f92c77859c71fb3a4b8d3cad81006546aec56f8 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 16:20:51 -0700 Subject: [PATCH 131/134] realm.py: uses existing method --- py-json/realm.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 36f52a23..6c09b58c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1960,7 +1960,7 @@ class StationProfile: print("Cleaning up stations") if (desired_stations is None): - desired_stations = self.station_names; + desired_stations = self.station_names if len(desired_stations) < 1: print("ERROR: StationProfile cleanup, list is empty") @@ -1973,22 +1973,7 @@ class StationProfile: self.local_realm.rm_port(port_eid, check_exists=True) # And now see if they are gone - count = 0 - while count < (del_count + 10): - found_one = False - for port_eid in desired_stations: - eid = self.local_realm.name_to_eid(port_eid) - # data["shelf"] = eid[0] - # data["resource"] = eid[1] - # data["port"] = eid[2] - current_stations = self.local_realm.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2])) - if not current_stations is None: - found_one = True - self.local_realm.rm_port(port_eid, check_exists=False) - time.sleep(delay) - if not found_one: - return - count = count + 1 + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) # Checks for errors in initialization values and creates specified number of stations using init parameters From 66d0fcaa8aaf020090a3358f09c1c9855fdb14fd Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 16:24:18 -0700 Subject: [PATCH 132/134] tip_station_powersave.py: progress creating and removing ports; collecting mac addresses for tshark --- py-scripts/tip_station_powersave.py | 43 ++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 6a453df2..4adb10f6 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -58,6 +58,7 @@ class TIPStationPowersave(LFCliBase): self.normal_sta_radio = normal_station_radio_ self.powersave_sta_list = powersave_station_list_ self.powersave_sta_radio = powersave_station_radio_ + self.sta_mac_map = {} self.debug = debug_on_ self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, @@ -126,11 +127,11 @@ class TIPStationPowersave(LFCliBase): self.sta_powersave_enabled_profile.set_command_flag("set_port", "rpt_timer", 1) self.sta_powersave_enabled_profile.set_command_flag("add_sta", "power_save_enable", 1) - self.wifi_monitor_profile.create(resource_=self.resource, channel=self.channel, radio_=self.monitor_radio, name_=self.monitor_name) + LFUtils.wait_until_ports_appear(base_url=self.local_realm.lfclient_url, port_list=[self.monitor_name]) time.sleep(0.2) @@ -147,7 +148,6 @@ class TIPStationPowersave(LFCliBase): sta_names_=self.powersave_sta_list, debug=self.debug, suppress_related_commands_=True) - temp_sta_map = {} for name in self.powersave_sta_list + self.normal_sta_list: temp_sta_map[name]=1 @@ -206,6 +206,8 @@ class TIPStationPowersave(LFCliBase): self._fail("eth0 is misconfigured or not our management port", print_=True) exit(1) + self.sta_mac_map = {} + def __get_rx_values(self): cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False) @@ -250,6 +252,17 @@ class TIPStationPowersave(LFCliBase): port_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) self.local_realm.wait_for_ip(station_list=self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) time.sleep(2) + # collect BSSID of AP so we can tshark on it + uri = "/port/1/%s/%s?fields=alias,ip,mac,ap"%( + self.resource, + ",".join(self.sta_powersave_disabled_profile.station_names + self.sta_powersave_enabled_profile.station_names) + ) + port_info_r = self.json_get(uri) + if (port_info_r is None) or ("empty" in port_info_r): + self._fail("unable to query for mac addresses", print_=True) + exit(1) + self.sta_mac_map = LFUtils.portListToAliasMap(port_info_r) + self.cx_prof_bg.start_cx() print("Upload starts at: %d"%time.time()) self.cx_prof_upload.start_cx() @@ -269,6 +282,7 @@ class TIPStationPowersave(LFCliBase): def stop(self): #switch off new monitor self.wifi_monitor_profile.admin_down() + self.cx_prof_bg.stop_cx() self.cx_prof_download.stop_cx() self.cx_prof_upload.stop_cx() self.sta_powersave_enabled_profile.admin_down() @@ -276,16 +290,31 @@ class TIPStationPowersave(LFCliBase): # check for that pcap file if self.pcap_file is None: - self._fail("Did not configure pcap file") + self._fail("Did not configure pcap file", print_=True) + exit(1) homepage_url = "http://%s/"%self.eth0_ip webpage = LFRequest.plain_get(url_=homepage_url, debug_=True) if webpage is None: - self._fail("Unable to find wepage for LANforge") + self._fail("Unable to find wepage for LANforge", print_=True) + exit(1) homepage_url="http://%s/lf_reports/"%self.eth0_ip webpage = LFRequest.plain_get(url_=homepage_url, debug_=True) if webpage is None: - self._fail("Unable to find /lf_reports/ page") + self._fail("Unable to find /lf_reports/ page", print_=True) + exit(1) + + pprint.pprint(self.sta_mac_map) + interesting_macs = {} + for eid,record in self.sta_mac_map.items(): + interesting_macs[record["mac"]] = 1 + interesting_macs[record["ap"]] = 1 + + mac_str = "-e wlan.addr ".join(interesting_macs.keys()) + tshark_filter = "tshark -e wlan.addr=="+mac_str+" -r "+self.pcap_file # now check for the pcap file we just created + print("TSHARK COMMAND: "+tshark_filter) + self._fail("not done writing pcap logic", print_=True) + exit(1) def cleanup(self): @@ -316,8 +345,8 @@ def main(): side_b_min_rate_=56000, traffic_duration_="5s", pause_duration_="2s", - debug_on_=True, - exit_on_error_=False, + debug_on_=False, + exit_on_error_=True, exit_on_fail_=True) ip_powersave_test.cleanup() ip_powersave_test.build() From 1e545c15b265792f91be398e46059a52f578ae81 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 7 Aug 2020 16:31:50 -0700 Subject: [PATCH 133/134] LFUtils.py: fixes json-post for waiting on ports --- py-json/LANforge/LFUtils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index a5d40a60..1dbd902c 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -414,7 +414,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu print("Waiting until ports appear...") found_stations = [] port_url = "/port/1" - ncshow_url = "/cli-form/nc_show_ports" + ncshow_url = "/cli-json/nc_show_ports" if base_url.endswith('/'): port_url = port_url[1:] ncshow_url = ncshow_url[1:] @@ -434,7 +434,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu found_stations.append(port_name) else: lf_r = LFRequest.LFRequest(base_url, ncshow_url) - lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "flags": "1"}) + lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "probe_flags": "1"}) lf_r.jsonPost() if (len(found_stations) < len(port_list)): sleep(2) From 737c752e91bf0c59b1df8266fb38497a7d1939bc Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 13 Aug 2020 10:59:28 -0700 Subject: [PATCH 134/134] WIP- WAN to LAN build function added --- py-scripts/test_l3_WAN_LAN.py | 123 +++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 33 deletions(-) diff --git a/py-scripts/test_l3_WAN_LAN.py b/py-scripts/test_l3_WAN_LAN.py index 7aca5a52..a58b7887 100755 --- a/py-scripts/test_l3_WAN_LAN.py +++ b/py-scripts/test_l3_WAN_LAN.py @@ -15,10 +15,11 @@ from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils import realm import time +import pprint import datetime class L3LANtoWAN(LFCliBase): - def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False, + def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=True, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) @@ -33,26 +34,83 @@ class L3LANtoWAN(LFCliBase): self.number_template = number_template self.debug = _debug_on self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - + + #build bridge and rdd pair def build(self): - # Build stations - #print("We've gotten into the build stations function") - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) - self._pass("PASS: Station build finished") + # Build bridge + req_url_br = "cli-json/add_br" + data_br = { + "shelf": 1, + "resource": 1, + "port": 'br0', + "network_devs": 'rd0a', + "br_flags": 0, + "br_priority": 65535, + "br_aging_time": -1, + "br_max_age": -1, + "br_hello_time": -1, + "br_forwarding_delay":-1 + + } + + super().json_post(req_url_br, data_br, debug_ = self.debug) + + #set port json post + req_url_set_port = "cli-json/set_port" + data_set_port = { + "shelf": 1, + "resource": 1, + "port": 'br0', + "current_flags": 131072, + "interest": 8548171804, + "report_timer": 3000, + "br_priority": 65535, + "br_aging_time": -1, + "br_max_age": -1, + "br_hello_time": -1, + "br_forwarding_delay":-1, + "br_port_cost": -1, + "br_port_priority":255, + "current_flags_msk": 135107988821114880 + } + super().json_post(req_url_set_port, data_set_port, debug_ = self.debug) + + #add_vrcx + req_url_add_vrcx= "cli-json/add_vcrx" + data_add_vrcx = { + "shelf": 1, + "resource": 1, + "vr_name": 'Router-0', + "local_dev": 'br-0', + "x": 583, + "y": 117, + "width": 10, + "height": 10, + "flags": 257, + "subnets": '5.0.0.0/16', + "nexthop":'10.40.11.202', + "dhcp_lease_time": 43200, + "dhcp_dns":'0.0.0.0', + "interface_cost": 1, + "rip_metric": 1, + "vrrp_ip_prefix": 25, + "vrrp_id":1, + "vrrp_priority":100, + "vrrp_interval":1 + } + super().json_post(req_url_add_vrcx, data_add_vrcx, debug_ = self.debug) + + #add_vrcx2 + req_url_add_vrcx2= "cli-json/add_vrcx2" + data_add_vrcx2 = { + "shelf": 1, + "resource": 1, + "vr_name": 'Router-0', + "local_dev": 'br-0', + } + super().json_post(req_url_add_vrcx2, data_add_vrcx2, debug_ = self.debug) + + def start(self, sta_list, print_pass, print_fail): self.station_profile.admin_up(1) @@ -107,24 +165,23 @@ def main(): lfjson_host = "localhost" lfjson_port = 8080 station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000) - ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa3-44", password="jedway-wpa3-44", - security="wpa3", sta_list=station_list,_debug_on=False) - #print("created IPv4Test object") - ip_test.cleanup(station_list) + ip_test = L3LANtoWAN(lfjson_host, lfjson_port, ssid="jedway-open-1", password="[BLANK]", + security="open", sta_list=station_list,_debug_on=False) + #ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) - ip_test.start(station_list, False, False) - ip_test.stop() - if not ip_test.passes(): - print(ip_test.get_fail_message()) - exit(1) - time.sleep(30) - ip_test.cleanup(station_list) - if ip_test.passes(): - print("Full test passed, all stations associated and got IP") + #ip_test.start(station_list, False, False) + #ip_test.stop() + #if not ip_test.passes(): + # print(ip_test.get_fail_message()) + # exit(1) + #time.sleep(30) + #ip_test.cleanup(station_list) + #if ip_test.passes(): + # print("Full test passed, all stations associated and got IP") if __name__ == "__main__":