From 097d2f42f55401b7420e995ef465bad8ba84161f Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 4 Oct 2021 11:51:02 -0700 Subject: [PATCH] Improving py-scripts files to fix errors with regression test updating to_pip.sh Signed-off-by: Matthew Stidham --- py-scripts/create_qvlan.py | 2 +- py-scripts/layer3_test.py | 48 +++---- py-scripts/lf_atten_mod_test.py | 11 +- py-scripts/lf_multipsk.py | 63 +++++---- py-scripts/lf_rx_sensitivity_test.py | 0 py-scripts/regression_test.sh | 144 +++++---------------- py-scripts/rvr_scenario.py | 2 +- py-scripts/scenario.py | 186 ++++++++++++++++++++------- py-scripts/tools/lf_check.py | 2 +- to_pip.sh | 6 +- 10 files changed, 235 insertions(+), 229 deletions(-) mode change 100644 => 100755 py-scripts/lf_rx_sensitivity_test.py diff --git a/py-scripts/create_qvlan.py b/py-scripts/create_qvlan.py index 7eaeb90d..771a02ea 100755 --- a/py-scripts/create_qvlan.py +++ b/py-scripts/create_qvlan.py @@ -68,7 +68,7 @@ def main(): --------------------- Generic command ''') parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') - parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None) + parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None, required=True) parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) parser.add_argument('--num_ports', help='number of ports to create', default=1) parser.add_argument('--first_qvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) diff --git a/py-scripts/layer3_test.py b/py-scripts/layer3_test.py index 6199babf..89df5101 100755 --- a/py-scripts/layer3_test.py +++ b/py-scripts/layer3_test.py @@ -14,18 +14,20 @@ if sys.version_info[0] != 3: sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) LFUtils = importlib.import_module("py-json.LANforge.LFUtils") -lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base") -LFCliBase = lfcli_base.LFCliBase realm = importlib.import_module("py-json.realm") Realm = realm.Realm -class Layer3Test(LFCliBase): +class Layer3Test(Realm): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, num_sta=2, dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", name_prefix="L3Test", - traffic_type="lf_udp",side_a_speed="0M", side_b_speed="10M", session_id="Layer3Test", duration="1m",_debug_on=False, _exit_on_error=False, _exit_on_fail=False): - super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _exit_on_fail=_exit_on_fail) + traffic_type="lf_udp", + side_a_min_rate=256000, side_a_max_rate=0, + side_b_min_rate=256000, side_b_max_rate=0, + session_id="Layer3Test", duration="1m", + _debug_on=False, _exit_on_error=False, _exit_on_fail=False): + super().__init__(lfclient_host=lfclient_host, lfclient_port=lfclient_port, debug_=_debug_on, _exit_on_fail=_exit_on_fail) print("Test is about to start") self.host = lfclient_host self.port = lfclient_port @@ -42,29 +44,27 @@ class Layer3Test(LFCliBase): self.password = dut_passwd self.session_id = session_id self.traffic_type = traffic_type - self.side_a_speed = side_a_speed - self.side_b_speed = side_b_speed - 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_l3_cx_profile() + self.station_profile = self.new_station_profile() + self.cx_profile = self.new_l3_cx_profile() 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 = self.local_realm.parse_speed(self.side_a_speed) - self.cx_profile.side_a_max_bps = self.local_realm.parse_speed(self.side_a_speed) - self.cx_profile.side_b_min_bps = self.local_realm.parse_speed(self.side_b_speed) - self.cx_profile.side_b_max_bps = self.local_realm.parse_speed(self.side_b_speed) + 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 print("Test is Initialized") def precleanup(self): print("precleanup started") - self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id, end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio) + self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id, + end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio) self.cx_profile.cleanup_prefix() for sta in self.station_list: - self.local_realm.rm_port(sta, check_exists=True) + self.rm_port(sta, check_exists=True) time.sleep(1) self.cx_profile.cleanup() @@ -81,8 +81,9 @@ class Layer3Test(LFCliBase): 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.station_list, debug=self.debug) - self.local_realm.wait_until_ports_appear(sta_list=self.station_list) - self.cx_profile.create(endp_type=self.traffic_type, side_a=self.station_profile.station_names, side_b=self.upstream, sleep_time=0) + self.wait_until_ports_appear(sta_list=self.station_list) + self.cx_profile.create(endp_type=self.traffic_type, side_a=self.station_profile.station_names, + side_b=self.upstream, sleep_time=0) print("Test Build done") pass @@ -92,7 +93,7 @@ class Layer3Test(LFCliBase): 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)): + if self.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) else: self._fail("Stations failed to get IPs", print_fail) @@ -101,13 +102,13 @@ class Layer3Test(LFCliBase): try: for i in self.cx_profile.get_cx_names(): self.cx_names.append(i) - while self.local_realm.json_get("/cx/" + i).get(i).get('state') != 'Run': + while self.json_get("/cx/" + i).get(i).get('state') != 'Run': continue except Exception as e: pass print("Test Started") self.cur_time = datetime.datetime.now() - self.end_time = self.local_realm.parse_time(self.test_duration) + self.cur_time + self.end_time = self.parse_time(self.test_duration) + self.cur_time print(self.end_time-self.cur_time) self.start_monitor() pass @@ -137,7 +138,7 @@ class Layer3Test(LFCliBase): def main(): # This has --mgr, --mgr_port and --debug - parser = LFCliBase.create_basic_argparse( + parser = Realm.create_basic_argparse( prog="layer3_test.py", formatter_class=argparse.RawTextHelpFormatter, epilog="About This Script") @@ -156,7 +157,8 @@ def main(): obj = Layer3Test(lfclient_host=args.mgr, lfclient_port=args.mgr_port, duration=args.test_duration, session_id=args.session_id, traffic_type=args.traffic_type, - dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, num_sta=args.num_client, side_a_speed=args.side_a_min_speed, side_b_speed=args.side_b_min_speed, radio=args.radio) + dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, num_sta=args.num_client, + side_a_min_rate=args.side_a_min_speed, side_b_min_rate=args.side_b_min_speed, radio=args.radio,_debug_on=args.debug) obj.precleanup() obj.build() obj.start() diff --git a/py-scripts/lf_atten_mod_test.py b/py-scripts/lf_atten_mod_test.py index 9a7e91d5..d6badd26 100755 --- a/py-scripts/lf_atten_mod_test.py +++ b/py-scripts/lf_atten_mod_test.py @@ -30,25 +30,22 @@ if sys.version_info[0] != 3: sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) -lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base") -LFCliBase = lfcli_base.LFCliBase -LFUtils = importlib.import_module("py-json.LANforge.LFUtils") realm = importlib.import_module("py-json.realm") Realm = realm.Realm -class CreateAttenuator(LFCliBase): +class CreateAttenuator(Realm): def __init__(self, host, port, serno, idx, val, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): - super().__init__(host, port, _local_realm=realm.Realm(host, port), _debug=_debug_on, _exit_on_fail=_exit_on_fail) + super().__init__(host, port, debug_=_debug_on, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.serno = serno self.idx = idx self.val = val - self.attenuator_profile = self.local_realm.new_attenuator_profile() + self.attenuator_profile = self.new_attenuator_profile() self.attenuator_profile.atten_idx = self.idx self.attenuator_profile.atten_val = self.val self.attenuator_profile.atten_serno = self.serno @@ -58,7 +55,7 @@ class CreateAttenuator(LFCliBase): self.attenuator_profile.show() def main(): - parser = LFCliBase.create_basic_argparse( + parser = Realm.create_basic_argparse( prog='lf_atten_mod_test.py', formatter_class=argparse.RawTextHelpFormatter, epilog=None, diff --git a/py-scripts/lf_multipsk.py b/py-scripts/lf_multipsk.py index 298247e8..accf11c4 100755 --- a/py-scripts/lf_multipsk.py +++ b/py-scripts/lf_multipsk.py @@ -45,7 +45,7 @@ Realm = realm.Realm class MultiPsk(Realm): def __init__(self, host=None, - port=None, + port=8080, ssid=None, input=None, security=None, @@ -57,8 +57,10 @@ class MultiPsk(Realm): sta_prefix="sta", debug_=False, ): - self.host = host - self.port = port + super().__init__(lfclient_host=host, + lfclient_port=port), + self.lfclient_host = host + self.lfclient_port = port self.ssid = ssid self.input = input self.security = security @@ -69,8 +71,7 @@ class MultiPsk(Realm): self.resource = resource self.sta_prefix = sta_prefix self.debug = debug_ - 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 = self.new_station_profile() def build(self): station_list = [] @@ -84,30 +85,30 @@ class MultiPsk(Realm): else: station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=self.start_id, end_id_=input['num_station'] - 1, padding_number_=100, - radio=input['radio']) + radio=self.radio) # implementation for non vlan pending **** print("creating stations") - self.station_profile.use_security(self.security, self.ssid, str(input['password'])) + self.station_profile.use_security(self.security, self.ssid, self.passwd) 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=input['radio'], sta_names_=station_list, debug=self.local_realm.debug) - self.local_realm.wait_until_ports_appear(sta_list=station_list) + self.station_profile.create(radio=self.radio, sta_names_=station_list, debug=self.debug) + self.wait_until_ports_appear(sta_list=station_list) self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list, timeout_sec=120): + if self.wait_for_ip(station_list, timeout_sec=120): print("All stations got IPs") else: print("Stations failed to get IPs") print("create udp endp") - self.cx_profile_udp = self.local_realm.new_l3_cx_profile() + self.cx_profile_udp = self.new_l3_cx_profile() self.cx_profile_udp.side_a_min_bps = 128000 self.cx_profile_udp.side_b_min_bps = 128000 self.cx_profile_udp.side_a_min_pdu = 1200 self.cx_profile_udp.side_b_min_pdu = 1500 self.cx_profile_udp.report_timer = 1000 self.cx_profile_udp.name_prefix = "udp" - port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix)) + port_list = list(self.find_ports_like("%s+" % self.sta_prefix)) # print("port list", port_list) if (port_list is None) or (len(port_list) < 1): raise ValueError("Unable to find ports named '%s'+" % self.sta_prefix) @@ -118,13 +119,13 @@ class MultiPsk(Realm): # Create TCP endpoints print("create tcp endp") - self.l3_tcp_profile = self.local_realm.new_l3_cx_profile() + self.l3_tcp_profile = self.new_l3_cx_profile() self.l3_tcp_profile.side_a_min_bps = 128000 self.l3_tcp_profile.side_b_min_bps = 56000 self.l3_tcp_profile.name_prefix = "tcp" self.l3_tcp_profile.report_timer = 1000 self.l3_tcp_profile.create(endp_type="lf_tcp", - side_a=list(self.local_realm.find_ports_like("%s+" % self.sta_prefix)), + side_a=list(self.find_ports_like("%s+" % self.sta_prefix)), side_b="%d.%s" % (self.resource, input['upstream']), suppress_related_commands=True) @@ -140,7 +141,7 @@ class MultiPsk(Realm): if "." in i['upstream']: # print(str(i['upstream']) + " is a vlan upstream port") print("checking its ip ..") - data = self.local_realm.json_get("ports/list?fields=IP") + data = self.json_get("ports/list?fields=IP") for val in data["interfaces"]: for j in val: if "1." + str(self.resource) + "." + str(i['upstream']) == j: @@ -157,7 +158,7 @@ class MultiPsk(Realm): if "." not in i['upstream']: # print(str(i['upstream']) + " is not an vlan upstream port") print("checking its ip ..") - data = self.local_realm.json_get("ports/list?fields=IP") + data = self.json_get("ports/list?fields=IP") for val in data["interfaces"]: for j in val: if "1." + str(self.resource) + "." + str(i['upstream']) == j: @@ -168,11 +169,8 @@ class MultiPsk(Realm): return non_vlan_ips def get_sta_ip(self): - # this function gives station ip dict eg{'eth2.100': '172.17.0.100'} - # self.input = [{'password': 'lanforge1', 'upstream': 'eth2.100', 'mac': '', 'num_station': 1, 'radio': 'wiphy4'}, {'password': 'lanforge2', 'upstream': 'eth2.200', 'mac': '', 'num_station': 1, 'radio': 'wiphy4'}, {'password': 'lanforge3', 'upstream': 'eth2', 'mac': '', 'num_station': 1, 'radio': 'wiphy0'}] - # port_list = ['1.1.sta200', '1.1.sta00', '1.1.sta100'] station_ip = {} - port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix)) + port_list = list(self.find_ports_like("%s+" % self.sta_prefix)) # print("port list", port_list) # port list ['1.1.sta200', '1.1.sta00', '1.1.sta100'] for name, id in zip(port_list, self.input): @@ -182,7 +180,7 @@ class MultiPsk(Realm): # print(x) if name == "1." + str(self.resource) + ".sta" + str(x): - data = self.local_realm.json_get("ports/list?fields=IP") + data = self.json_get("ports/list?fields=IP") for i in data["interfaces"]: # print(i) for j in i: @@ -227,7 +225,7 @@ class MultiPsk(Realm): # print(x) if name == "1." + str(self.resource) + ".sta" + str(x): - data = self.local_realm.json_get("ports/list?fields=IP") + data = self.json_get("ports/list?fields=IP") for i in data["interfaces"]: # print(i) for j in i: @@ -241,7 +239,7 @@ class MultiPsk(Realm): def get_non_vlan_sta_ip(self): station_nonvlan_ip = {} x = "" - port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix)) + port_list = list(self.find_ports_like("%s+" % self.sta_prefix)) # print("port list", port_list) for id in self.input: if "." not in id['upstream']: @@ -249,7 +247,7 @@ class MultiPsk(Realm): # print(x) for name in port_list: if name == "1.1.sta00": - data = self.local_realm.json_get("ports/list?fields=IP") + data = self.json_get("ports/list?fields=IP") for i in data["interfaces"]: # print(i) for j in i: @@ -312,27 +310,21 @@ class MultiPsk(Realm): self.cx_profile_udp.cleanup() self.l3_tcp_profile.cleanup() self.station_profile.cleanup() - LFUtils.wait_until_ports_disappear(base_url=self.local_realm.lfclient_url, port_list=self.station_profile.station_names, + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_host, port_list=self.station_profile.station_names, debug=self.debug) print("Test Completed") def main(): - parser = argparse.ArgumentParser( + parser = Realm.create_basic_argparse( prog="lf_multipsk.py", formatter_class=argparse.RawTextHelpFormatter, description="lanforge webpage download Test Script") - parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost') - parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080) - parser.add_argument('--ssid', help='WiFi SSID for client to associate to') - parser.add_argument('--security', help='WiFi Security protocol: {open|wep|wpa2|wpa3', default="wpa2") - parser.add_argument('--mode', help="specify mode of ap eg BRIDGE or NAT", default="BRIDGE") parser.add_argument('--n_vlan', help="type number of vlan using in test eg 1 or 2", default=1) - # parser.add_argument('--input', nargs="+", help="specify list of parameters like passwords,upstream,mac address, number of clients and radio as input, eg password@123,eth2.100,"",1,wiphy0 lanforge@123,eth2.100,"",1,wiphy1") args = parser.parse_args() input_data = [{ - "password": "lanforge1", + "password": args.passwd, "upstream": "eth2.100", "mac": "", "num_station": 1, @@ -364,8 +356,11 @@ def main(): multi_obj = MultiPsk(host=args.mgr, port=args.mgr_port, ssid=args.ssid, + passwd=args.passwd, input=input_data, - security=args.security) + security=args.security, + debug_=args.debug, + radio=args.radio) multi_obj.build() multi_obj.start() diff --git a/py-scripts/lf_rx_sensitivity_test.py b/py-scripts/lf_rx_sensitivity_test.py old mode 100644 new mode 100755 diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 8cb3715b..9fe96ec4 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -57,7 +57,7 @@ while getopts ":h:s:p:w:m:A:r:F:B:U:D:H:" option; do DUT2=${OPTARG} ;; H) - HELP=1 + ./lf_help_check.bash ;; *) @@ -142,100 +142,8 @@ function testgroup_delete_group() { ./testgroup.py --group_name group1 --add_group --add_cx cx0000,cx0001,cx0002 --remove_cx cx0003 ./testgroup.py --group_name group1--del_group --debug --mgr "$MGR" } -if [[ $HELP -eq 1 ]]; then - testCommands=( - "./create_bond.py --help --mgr $MGR" - "./create_bridge.py --help --mgr $MGR" - "./create_chamberview.py --help -m $MGR" - "./create_chamberview_dut.py --help --lfmgr $MGR" - "./create_l3.py --help --mgr $MGR" - "./create_l4.py --help --mgr $MGR" - "./create_macvlan.py --help --mgr $MGR" - "./create_qvlan.py --help --mgr $MGR" - "./create_station.py --help --mgr $MGR" - "./create_vap.py --help --mgr $MGR" - "./create_vr.py --help --mgr $MGR" - "./create_wanlink.py --help --mgr $MGR" - "./csv_convert.py --help --mgr $MGR" - "./csv_processor.py --help --mgr $MGR" - "./csv_to_grafana.py --help --mgr $MGR" - "./csv_to_influx.py --help --mgr $MGR" - "./cv_manager.py --help --mgr $MGR" - "./cv_to_grafana.py --help --mgr $MGR" - "./docstrings.py --help --mgr $MGR" - "./event_breaker --help --mgr $MGR" - "./event_flood --help --mgr $MGR" - "./example_security_connection.py --help --mgr $MGR" - "./ftp_html.py --help --mgr $MGR" - "./ghost_profile.py --help --mgr $MGR" - "./grafana_profile.py --help --mgr $MGR" - "./html_template.py --help --mgr $MGR" - "./influx.py --help --mgr $MGR" - "./layer3_test.py --help --mgr $MGR" - "./layer4_test.py --help --mgr $MGR" - "./lf_ap_auto_test.py --help --mgr $MGR" - "./lf_atten_mod_test.py --help --mgr $MGR" - "./lf_csv.py --help --mgr $MGR" - "./lf_dataplane_config.py --help --mgr $MGR" - "./lf_dataplane_test.py --help --mgr $MGR" - "./lf_dfs_test.py --help --mgr $MGR" - "./lf_dut_sta_vap_test.py --help --mgr $MGR" - "./lf_ftp.py --help --mgr $MGR" - "./lf_ftp_test.py --help --mgr $MGR" - "./lf_graph.py --help --mgr $MGR" - "./lf_mesh_test.py --help --mgr $MGR" - "./lf_multipsk.py --help --mgr $MGR" - "./lf_report.py --help --mgr $MGR" - "./lf_report_test.py --help --mgr $MGR" - "./lf_rvr_test.py --help --mgr $MGR" - "./lf_rx_sensitivity_test.py --help --mgr $MGR" - "./lf_sniff_radio.py --help --mgr $MGR" - "./lf_snp_test.py -0-help --mgr $MGR" - "./lf_tr398_test.py --help --mgr $MGR" - "./lf_webpage.py --help --mgr $MGR" - "./lf_wifi_capacity_test.py --help --mgr $MGR" - "./measure_station_time_up.py --help --mgr $MGR" - "./modify_station.py --help --mgr $MGR" - "./modify_vap.py --help --mgr $MGR" - "./recordinflux.py --help --mgr $MGR" - "./run_cv_scenario.py --help --mgr $MGR" - "./rvr_scenario.py --help --mgr $MGR" - "./scenario.py --help --mgr $MGR" - "./sta_connect.py --help --mgr $MGR" - "./sta_connect2.py --help --mgr $MGR" - "./sta_connect_bssid_mac.py --help --mgr $MGR" - "./sta_connect_example.py --help --mgr $MGR" - "./sta_connect_multi_example.py --help --mgr $MGR" - "./sta_scan_test.py --help --mgr $MGR" - "./station_layer3.py --help --mgr $MGR" - "./stations_connected.py --help --mgr $MGR" - "./test_1k_clients_jedtest.py --help --mgr $MGR" - "./test_client_admission.py --help --mgr $MGR" - "./test_fileio.py --help --mgr $MGR" - "./test_generic.py --help --mgr $MGR" - "./test_ip_connection.py --help --mgr $MGR" - "./test_ip_variable_time.py --help --mgr $MGR" - "./test_ipv4_ps.py --help --mgr $MGR" - "./test_ipv4_ttls.py --help --mgr $MGR" - "./test_l3_WAN_LAN.py --help --mgr $MGR" - "./test_l3_longevity.py --help --mgr $MGR" - "./test_l3_scenario_throughput.py -h -m $MGR" - "./test_l3_unicast_traffic_gen.py --help --mgr $MGR" - "./test_l4.py --help --mgr $MGR" - "./test_status_msg.py --help --mgr $MGR" - "./test_wanlink.py --help --mgr $MGR" - "./test_wpa_passphrases.py --help --mgr $MGR" - "./testgroup.py --help --mgr $MGR" - "./testgroup2.py --help --mgr $MGR" - "./testgroup_delete_group --mgr $MGR" - "./testgroup_list_connections --help --mgr $MGR" - "./testgroup_list_groups.py --help --mgr $MGR" - "./tip_station_powersave.py --help --mgr $MGR" - "./video_rates.py --help --mgr $MGR" - "./wlan_capacity_calculator.py -h --mgr $MGR" - "./ws_generic_monitor_test.py --help --mgr $MGR" - ) -elif [[ $MGRLEN -gt 0 ]]; then + +if [[ $MGRLEN -gt 0 ]]; then testCommands=( "./create_bond.py --network_dev_list eth0,eth1 --debug --mgr $MGR" "./create_bridge.py --radio $RADIO_USED --upstream_port eth1 --target_device sta0000 --debug --mgr $MGR" @@ -248,7 +156,7 @@ elif [[ $MGRLEN -gt 0 ]]; then "./create_l3_stations.py --mgr $MGR --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug" "./create_l4.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_macvlan.py --radio 1.$RADIO_USED --macvlan_parent eth1 --debug --mgr $MGR" - "./create_qvlan.py --first_qvlan_ip 192.168.1.50 --mgr $MGR" + "./create_qvlan.py --first_qvlan_ip 192.168.1.50 --mgr $MGR --qvlan_parent eth1" "./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_vap.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_vr.py --mgr $MGR --vr_name 2.vr0 --ports 2.br0,2.vap2 --services 1.br0=dhcp,nat --services 1.vr0=radvd --debug" @@ -270,7 +178,7 @@ elif [[ $MGRLEN -gt 0 ]]; then #./html_template #./influx "./layer3_test.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./layer4_test --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./layer4_test.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" "./lf_ap_auto_test.py --mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \ --instance_name ap-auto-instance --config_name test_con --upstream 1.1.eth2 \ --dut5_0 \"$DUT5 (2)\" --dut2_0 \"$DUT2 (1)\" --max_stations_2 100 --max_stations_5 100 --max_stations_dual 200 \ @@ -299,7 +207,7 @@ elif [[ $MGRLEN -gt 0 ]]; then #"./lf_ftp.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --bands 5G --direction Download \ # --file_size 2MB --num_stations 2" "./lf_graph.py --mgr $MGR" - "./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID' --debug" + "./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID'" #"./lf_multipsk.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --debug" "./lf_report.py" "./lf_report_test.py" @@ -320,7 +228,7 @@ elif [[ $MGRLEN -gt 0 ]]; then --influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \ --influx_bucket ben \ --influx_tag testbed Ferndale-01" - "lf_sniff_radio.py + "./lf_sniff_radio.py --mgr $MGR --mgr_port 8080 --outfile /home/lanforge/test_sniff.pcap @@ -337,22 +245,40 @@ elif [[ $MGRLEN -gt 0 ]]; then #--influx_host c7-graphana --influx_port 8086 --influx_org Candela \ #--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \ #--influx_bucket ben \ - #measure_station_time_up.py - #modify_station.py - #modify_vap.py + #"./measure_station_time_up.py --radio $RADIO_USED --num_stations 3 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --debug --report_file measure_station_time_up.txt" + "./modify_station.py + --radio $RADIO_USED + --station 1.1.sta0000 + --security $SECURITY + --ssid $SSID_USED + --passwd $PASSWD_USED + --enable_flag osen_enable + --disable_flag ht160_enable + --debug" + "./modify_vap.py --radio $RADIO_USED --vap 1.1.vap0000 --security $SECURITY -ssid $SSID_USED \ + --passwd $PASSWD_USED --enable_flag osen_enable --disable_flag ht160_enable --debug" #recordinflux.py - #run_cv_scenario.py - #rvr_scenario.py + "./load_ap_scenario.py --lfmgr $MGR --scenario_db 'handsets' --cv_test --test_scenario 'test-20'" + "./rvr_scenario.py --lfmgr $MGR --lanforge_db 'handsets' --cv_test --test_scenario 'test-20'" #scenario.py - #sta_connect2.py - #sta_connect_bssid_mac.py + #"./sta_connect2.py --dest 192.168.100.209 --dut_ssid OpenWrt-2 --dut_bssid 24:F5:A2:08:21:6C" + #./sta_connect_bssid_mac.py #sta_connect_example.py #sta_connect_multi_example.py #sta_connect.py - #sta_scan_test.py + "./sta_scan_test.py --ssid $SSID --security $SECURITY --passwd $PASSWD_USED --radio $RADIO_USED" #station_layer3.py #stations_connected.py - #test_1k_clients_jedtest.py + #"./test_1k_clients_jedtest.py + # --mgr $MGR + # --mgr_port 8080 + # --sta_per_radio 300 + # --test_duration 3m + # --a_min 1000 + # --b_min 1000 + # --a_max 0 + # --b_max 0 + # --debug" #test_client_admission.py "./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --test_duration 30s --mgr $MGR" # Better tested on Kelly, where VRF is turned off #"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest $TEST_HTTP_IP --debug --mgr $MGR" @@ -369,7 +295,7 @@ elif [[ $MGRLEN -gt 0 ]]; then #"./test_ip_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format csv --layer3_cols $COL_NAMES --debug --mgr $MGR --traffic_type lf_udp" "./test_ip_connection.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR --ipv6" #"./test_ip_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --debug --mgr $MGR --ipv6 --traffic_type lf_udp" - #./test_ipv4_ps + "./test_ipv4_ps.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" #./test_ipv4_ttls "./test_l3_longevity.py --mgr $MGR --endp_type 'lf_udp lf_tcp' --upstream_port 1.1.$UPSTREAM \ --radio \"radio==1.1.wiphy0 stations==10 ssid==ASUS_70 ssid_pw==[BLANK] security==open\" \ diff --git a/py-scripts/rvr_scenario.py b/py-scripts/rvr_scenario.py index 45d09daa..80b666af 100755 --- a/py-scripts/rvr_scenario.py +++ b/py-scripts/rvr_scenario.py @@ -163,7 +163,7 @@ def main(): formatter_class=argparse.RawTextHelpFormatter, description="""LANforge Reporting Script: Load a scenario and run a RvR report Example: -./load_ap_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test --test_scenario 'test-20' +./rvr_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test --test_scenario 'test-20' """) parser.add_argument("-m", "--lfmgr", type=str, help="address of the LANforge GUI machine (localhost is default)") diff --git a/py-scripts/scenario.py b/py-scripts/scenario.py index 418de7a8..c1df589d 100755 --- a/py-scripts/scenario.py +++ b/py-scripts/scenario.py @@ -3,12 +3,12 @@ import sys import os import importlib import argparse +import time if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) - sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base") @@ -18,63 +18,151 @@ realm = importlib.import_module("py-json.realm") Realm = realm.Realm -parser = LFCliBase.create_bare_argparse( - prog='scenario.py', - formatter_class=argparse.RawTextHelpFormatter, - epilog='''Load a database file and control test groups\n''', - description='''scenario.py --------------------- -Generic command example: -scenario.py --load db1 --action overwrite --clean_dut --clean_chambers +def get_events(event_log, value): + results = [] + for event in event_log: + try: + results.append(list(event.values())[0][value]) + except: + pass + return results -scenario.py --start test_group1 -scenario.py --quiesce test_group1 +def find_new_events(original, new): + new_times = list() + new_events = list() + original_times = get_events(original['events'], 'time-stamp') + current_times = get_events(new['events'], 'time-stamp') + for x in current_times: + if x not in original_times: + new_times.append(x) + for x in new['events']: + if list(x.values())[0]['time-stamp'] in new_times: + new_events.append(x) + return new_events -scenario.py --stop test_group1 -''') -group = parser.add_mutually_exclusive_group() +class LoadScenario(Realm): + def __init__(self, + mgr='localhost', + mgr_port=8080, + scenario=None, + action='overwrite', + clean_dut=True, + clean_chambers=True, + start=None, + stop=None, + quiesce=None, + timeout=120, + debug=False): + super().__init__(lfclient_host=mgr, + lfclient_port=mgr_port, + debug_=debug) + self.mgr = mgr + self.scenario = scenario + self.action = action + self.clean_dut = clean_dut + self.clean_chambers = clean_chambers + self.start = start + self.stop = stop + self.quiesce = quiesce + self.timeout = timeout -parser.add_argument('--load', help='name of database to load', default=None) + starting_events = self.json_get('/events/since=time/1h') -parser.add_argument('--action', help='action to take with database {overwrite | append}', default="overwrite") + if self.scenario is not None: + data = { + "name": self.scenario, + "action": self.action, + "clean_dut": "no", + "clean_chambers": "no" + } + if self.clean_dut: + data['clean_dut'] = "yes" + if self.clean_chambers: + data['clean_chambers'] = "yes" + print("Loading database %s" % self.scenario) + self.json_post("/cli-json/load", data) -parser.add_argument('--clean_dut', - help='use to cleanup DUT will be when overwrite is selected, otherwise they will be kept', - action="store_true") -parser.add_argument('--clean_chambers', - help='use to cleanup Chambers will be when overwrite is selected, otherwise they will be kept', - action="store_true") + elif self.start is not None: + print("Starting test group %s..." % self.start) + self.json_post("/cli-json/start_group", {"name": self.start}) + elif self.stop is not None: + print("Stopping test group %s..." % self.stop) + self.json_post("/cli-json/stop_group", {"name": self.stop}) + elif self.quiesce is not None: + print("Quiescing test group %s..." % self.quiesce) + self.json_post("/cli-json/quiesce_group", {"name": self.quiesce}) -group.add_argument('--start', help='name of test group to start', default=None) -group.add_argument('--quiesce', help='name of test group to quiesce', default=None) -group.add_argument('--stop', help='name of test group to stop', default=None) -args = parser.parse_args() + completed = False + timer = 0 + while not completed: + current_events = self.json_get('/events/since=time/1h') + new_events = find_new_events(starting_events, current_events) + if 'LOAD-DB: Load attempt has been completed.' in get_events(new_events, 'event description'): + completed = True + print('Scenario %s fully loaded after %s seconds' % (self.scenario, timer)) + else: + timer += 1 + time.sleep(1) + if timer > self.timeout: + completed = True + print('Scenario failed to load after 120 seconds') + else: + print('Waiting %s out of %s seconds to load scenario %s' % (timer, self.timeout, self.scenario)) -local_realm = realm.Realm(lfclient_host=args.mgr, lfclient_port=args.mgr_port, debug_=args.debug) -if args.load is not None: - data = { - "name": args.load, - "action": args.action, - "clean_dut": "no", - "clean_chambers": "no" - } - if args.clean_dut: - data['clean_dut'] = "yes" - if args.clean_chambers: - data['clean_chambers'] = "yes" - print("Loading database %s" % args.load) - local_realm.json_post("/cli-json/load", data) +def main(): + parser = LFCliBase.create_bare_argparse( + prog='scenario.py', + formatter_class=argparse.RawTextHelpFormatter, + epilog='''Load a database file and control test groups\n''', + description='''scenario.py + -------------------- + Generic command example: + scenario.py --load db1 --action overwrite --clean_dut --clean_chambers + + scenario.py --start test_group1 + + scenario.py --quiesce test_group1 + + scenario.py --stop test_group1 + ''') -elif args.start is not None: - print("Starting test group %s..." % args.start) - local_realm.json_post("/cli-json/start_group", {"name": args.start}) -elif args.stop is not None: - print("Stopping test group %s..." % args.stop) - local_realm.json_post("/cli-json/stop_group", {"name": args.stop}) -elif args.quiesce is not None: - print("Quiescing test group %s..." % args.quiesce) - local_realm.json_post("/cli-json/quiesce_group", {"name": args.quiesce}) + group = parser.add_mutually_exclusive_group() + + parser.add_argument('--load', help='name of database to load', default=None) + + parser.add_argument('--action', help='action to take with database {overwrite | append}', default="overwrite") + + parser.add_argument('--clean_dut', + help='use to cleanup DUT will be when overwrite is selected, otherwise they will be kept', + action="store_true") + + parser.add_argument('--clean_chambers', + help='use to cleanup Chambers will be when overwrite is selected, otherwise they will be kept', + action="store_true") + + group.add_argument('--start', help='name of test group to start', default=None) + group.add_argument('--quiesce', help='name of test group to quiesce', default=None) + group.add_argument('--stop', help='name of test group to stop', default=None) + parser.add_argument('--timeout', help='Stop trying to load scenario after this many seconds', default=120) + args = parser.parse_args() + + LoadScenario(mgr=args.mgr, + scenario=args.load, + action=args.action, + clean_dut=args.clean_dut, + clean_chambers=args.clean_chambers, + start=args.start, + stop=args.stop, + quiesce=args.quiesce, + timeout=args.timeout, + debug=args.debug) + + # LoadScenario.scenario() + + +if __name__ == '__main__': + main() diff --git a/py-scripts/tools/lf_check.py b/py-scripts/tools/lf_check.py index 5bda08d5..6f0e6b36 100755 --- a/py-scripts/tools/lf_check.py +++ b/py-scripts/tools/lf_check.py @@ -715,7 +715,7 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) # no spaces after FACTORY_DFLT command = "./{} {}".format("scenario.py", "--load FACTORY_DFLT") - process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + process = subprocess.Popen(command.split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) # wait for the process to terminate out, err = process.communicate() diff --git a/to_pip.sh b/to_pip.sh index 6dca63d4..f2c4aced 100755 --- a/to_pip.sh +++ b/to_pip.sh @@ -92,11 +92,9 @@ from .csv_convert import CSVParcer from .csv_processor import L3CSVParcer from .csv_to_influx import CSVtoInflux from .csv_to_grafana import UseGrafana -from .download_test import DownloadTest from .event_breaker import EventBreaker from .event_flood import EventBreaker as EventFlood from .example_security_connection import IPv4Test -from .ghost_profile import UseGhost from .grafana_profile import UseGrafana from .influx import RecordInflux from .layer3_test import Layer3Test @@ -107,7 +105,6 @@ from .lf_csv import lf_csv, lf_kpi_csv from .lf_dataplane_test import DataplaneTest from .lf_dfs_test import FileAdapter, CreateCtlr, L3VariableTime from .lf_dut_sta_vap_test import Login_DUT, LoadScenario, CreateSTA_CX -from .lf_ftp_test import ftp_test from .lf_ftp import FtpTest from .lf_graph import lf_bar_graph, lf_stacked_graph, lf_horizontal_stacked_graph, lf_scatter_graph, lf_line_graph from .lf_mesh_test import MeshTest @@ -320,6 +317,7 @@ sed -i -- 's/PortUtils = port_utils.PortUtils/ /g' *.py sed -i -- 's/LFCliBase = lfcli_base.LFCliBase/ /g' *.py sed -i -- 's/pandas_extensions = importlib.import_module("py-json.LANforge.pandas_extensions")/from .LANforge.pandas_extensions import pandas_extensions/g' *.py sed -i -- 's/pandas_extensions.pandas_extensions/pandas_extensions/g' *.py +sed -i -- 's/vr_profile2 = importlib.import_module("py-json.vr_profile2")/from ..py_json import vr_profile2/g' *.py # fix py_dashboard files sed -i -- 's/from GrafanaRequest/from ..py_dashboard.GrafanaRequest/g' *.py @@ -370,7 +368,7 @@ cd LANforge echo " from .add_dut import dut_params, dut_flags from .add_file_endp import fe_fstype, fe_payload_list, fe_fio_flags, fe_base_endpoint_types -from .lf_json_autogen import LFJsonGet, LFJsonPost +#from .lf_json_autogen import LFJsonGet, LFJsonPost from .lfcli_base import LFCliBase from .LFRequest import LFRequest from .LFUtils import *