def setup(self): self.clear_test_results() self.check_connect() upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) if upstream_json is None: self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) return False if upstream_json['interface']['ip'] == "0.0.0.0": if self.debug: pprint.pprint(upstream_json) self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) return False # remove old stations print("Removing old stations") for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) response = self.json_get(sta_url) 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.lfclient_url, self.station_names) # Create stations and turn dhcp on self.station_profile = self.localrealm.new_station_profile() # Build stations self.station_profile.use_security(self.security, self.ssid, passwd="[BLANK]") 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.set_wifi_extra(key_mgmt=self.key_mgmt, eap=self.eap, identity=self.identity, passwd=self.ttls_passwd, realm=self.ttls_realm, domain=self.domain, hessid=self.hessid) self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug, use_radius=True, hs20_enable=False) self._pass("PASS: Station build finished")
def cleanup(self): for sta_name in self.station_names: LFUtils.removePort(self.resource, sta_name, self.lfclient_url) endp_names = [] removeCX(self.lfclient_url, self.cx_names.keys()) for cx_name in self.cx_names: endp_names.append(self.cx_names[cx_name]["a"]) endp_names.append(self.cx_names[cx_name]["b"]) removeEndps(self.lfclient_url, endp_names)
def cleanup_tcp(self): # remove all endpoints and cxs if self.cleanup_on_exit: for sta_name in self.station_names: LFUtils.removePort(self.resource, sta_name, self.lfclient_url) curr_endp_names = [] removeCX(self.lfclient_url, self.l3_tcp_tput_profile.get_cx_names()) for (cx_name, endp_names) in self.l3_tcp_tput_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)
def remove_stations(self): for name in self.station_names: LFUtils.removePort(self.resource, name, self.lfclient_url)
def setup(self): self.clear_test_results() self.check_connect() upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) if upstream_json is None: self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) return False if upstream_json['interface']['ip'] == "0.0.0.0": if self.debug: pprint.pprint(upstream_json) self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) return False # remove old stations print("Removing old stations") for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) response = self.json_get(sta_url) 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.lfclient_url, self.station_names) # Create stations and turn dhcp on self.station_profile = self.localrealm.new_station_profile() if self.dut_security == WPA2: self.station_profile.use_security(security_type="wpa2", ssid=self.dut_ssid, passwd=self.dut_passwd) elif self.dut_security == WPA: self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd) elif self.dut_security == OPEN: self.station_profile.use_security(security_type="open", ssid=self.dut_ssid, passwd="[BLANK]") elif self.dut_security == WPA: self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd) elif self.dut_security == WEP: self.station_profile.use_security(security_type="wep", ssid=self.dut_ssid, passwd=self.dut_passwd) self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) print("Adding new stations ", end="") 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)
def setup(self): self.clear_test_results() self.check_connect() eth1IP = self.json_get(self.get_upstream_url()) if eth1IP is None: self._fail("Unable to query %s, bye" % self.upstream_port, True) return False if eth1IP['interface']['ip'] == "0.0.0.0": self._fail("Warning: %s lacks ip address" % self.get_upstream_url()) return False for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) response = self.json_get(sta_url) if response is not None: if response["interface"] is not None: print("removing old station") for sta_name in self.station_names: LFUtils.removePort(self.resource, sta_name, self.lfclient_url) LFUtils.waitUntilPortsDisappear(self.resource, self.lfclient_url, self.station_names) # Create stations and turn dhcp on flags = 0x10000 if self.dut_security == WPA2: flags += 0x400 elif self.dut_security == OPEN: pass add_sta_data = { "shelf": 1, "resource": self.resource, "radio": self.radio, "ssid": self.dut_ssid, "key": self.dut_passwd, "mode": self.sta_mode, "mac": "xx:xx:xx:xx:*:xx", "flags": flags # verbose, wpa2 } print("Adding new stations ", end="") for sta_name in self.station_names: add_sta_data["sta_name"] = sta_name print(" %s," % sta_name, end="") self.json_post("/cli-json/add_sta", add_sta_data, suppress_related_commands_=True) time.sleep(0.01) set_port_data = { "shelf": 1, "resource": self.resource, "current_flags": 0x80000000, # use DHCP, not down "interest": 0x4002 # set dhcp, current flags } print("\nConfiguring ") for sta_name in self.station_names: set_port_data["port"] = sta_name print(" %s," % sta_name, end="") self.json_post("/cli-json/set_port", set_port_data, suppress_related_commands_=True) time.sleep(0.01) print("\nBringing ports up...") data = { "shelf": 1, "resource": self.resource, "port": "ALL", "probe_flags": 1 } self.json_post("/cli-json/nc_show_ports", data, suppress_related_commands_=True) LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names) # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) duration = 0 maxTime = 300 ip = "0.0.0.0" ap = "" print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="") connected_stations = {} while (len(connected_stations.keys()) < len( self.station_names)) and (duration < maxTime): duration += 3 time.sleep(3) print(".", end="") for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) station_info = self.json_get(sta_url + "?fields=port,ip,ap") # LFUtils.debug_printer.pprint(station_info) if (station_info is not None) and ("interface" in station_info): if "ip" in station_info["interface"]: ip = station_info["interface"]["ip"] if "ap" in station_info["interface"]: ap = station_info["interface"]["ap"] if (ap == "Not-Associated") or (ap == ""): if self.debugOn: print(" -%s," % sta_name, end="") else: if ip == "0.0.0.0": if self.debugOn: print(" %s (0.0.0.0)" % sta_name, end="") else: connected_stations[sta_name] = sta_url data = { "shelf": 1, "resource": self.resource, "port": "ALL", "probe_flags": 1 } self.json_post("/cli-json/nc_show_ports", data, suppress_related_commands_=True) # make a copy of the connected stations for test records for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) station_info = self.json_get(sta_url) # + "?fields=port,ip,ap") self.resulting_stations[sta_url] = station_info ap = station_info["interface"]["ap"] ip = station_info["interface"]["ip"] if (ap != "") and (ap != "Not-Associated"): print(" %s +AP %s, " % (sta_name, ap), end="") if self.dut_bssid != "": if self.dut_bssid.lower() == ap.lower(): self._pass(sta_name + " connected to BSSID: " + ap) # self.test_results.append("PASSED: ) # print("PASSED: Connected to BSSID: "+ap) else: self._fail( "%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap)) else: self._fail(sta_name + " did not connect to AP") return False if ip == "0.0.0.0": self._fail("%s did not get an ip. Ending test" % sta_name) else: self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip)) if self.passes() == False: if self.cleanup_on_exit: print("Cleaning up...") self.remove_stations() return False # create endpoints and cxs # Create UDP endpoints self.cx_names = {} for sta_name in self.station_names: self.cx_names["testUDP-" + sta_name] = { "a": "testUDP-%s-A" % sta_name, "b": "testUDP-%s-B" % sta_name } data = { "alias": "testUDP-%s-A" % sta_name, "shelf": 1, "resource": self.resource, "port": sta_name, "type": "lf_udp", "ip_port": "-1", "min_rate": 1000000 } self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True) data = { "name": "testUDP-%s-A" % sta_name, "flag": "UseAutoNAT", "val": 1 } self.json_post("/cli-json/set_endp_flag", data, suppress_related_commands_=True) data = { "alias": "testUDP-%s-B" % sta_name, "shelf": 1, "resource": self.upstream_resource, "port": self.upstream_port, "type": "lf_udp", "ip_port": "-1", "min_rate": 1000000 } self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True) data = { "name": "testUDP-%s-B" % sta_name, "flag": "UseAutoNAT", "val": 1 } self.json_post("/cli-json/set_endp_flag", data, suppress_related_commands_=True) # Create CX data = { "alias": "testUDP-%s" % sta_name, "test_mgr": "default_tm", "tx_endp": "testUDP-%s-A" % sta_name, "rx_endp": "testUDP-%s-B" % sta_name, } self.json_post("/cli-json/add_cx", data, suppress_related_commands_=True) data = { "test_mgr": "default_tm", "cx_name": "testUDP-%s" % sta_name, "milliseconds": 1000 } self.json_post("/cli-json/set_cx_report_timer", data, suppress_related_commands_=True) # Create TCP endpoints self.cx_names["testTCP-" + sta_name] = { "a": "testUDP-%s-A" % sta_name, "b": "testUDP-%s-B" % sta_name } data = { "alias": "testTCP-%s-A" % sta_name, "shelf": 1, "resource": self.resource, "port": sta_name, "type": "lf_tcp", "ip_port": "0", "min_rate": 1000000 } self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True) data = { "alias": "testTCP-%s-B" % sta_name, "shelf": 1, "resource": self.upstream_resource, "port": self.upstream_port, "type": "lf_tcp", "ip_port": "-1", "min_rate": 1000000 } self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True) # Create CX data = { "alias": "testTCP-%s" % sta_name, "test_mgr": "default_tm", "tx_endp": "testTCP-%s-A" % sta_name, "rx_endp": "testTCP-%s-B" % sta_name, } self.json_post("/cli-json/add_cx", data) data = { "test_mgr": "default_tm", "cx_name": "testTCP-%s" % sta_name, "milliseconds": 1000 } self.json_post("/cli-json/set_cx_report_timer", data, suppress_related_commands_=True) return True
def setup(self): self.clear_test_results() self.check_connect() upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) if upstream_json is None: self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) return False if upstream_json['interface']['ip'] == "0.0.0.0": if self.debug: pprint.pprint(upstream_json) self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) return False # remove old stations if self.clean_all_sta: print("Removing all stations on resource.") self.localrealm.remove_all_stations(self.resource) else: print("Removing old stations to be created by this test.") for sta_name in self.station_names: sta_url = self.get_station_url(sta_name) response = self.json_get(sta_url) 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.lfclient_url, self.station_names) # Create stations and turn dhcp on self.station_profile = self.localrealm.new_station_profile() if self.dut_security == WPA2: 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_security(security_type="open", ssid=self.dut_ssid, passwd="[BLANK]") elif self.dut_security == WPA: self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd) elif self.dut_security == WEP: self.station_profile.use_security(security_type="wep", ssid=self.dut_ssid, passwd=self.dut_passwd) self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) print("Adding new stations ", end="") 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() self.l3_udp_profile.side_a_min_bps = 128000 self.l3_udp_profile.side_b_min_bps = 128000 self.l3_udp_profile.side_a_min_pdu = 1200 self.l3_udp_profile.side_b_min_pdu = 1500 self.l3_udp_profile.report_timer = 1000 self.l3_udp_profile.name_prefix = "udp" port_list = list( self.localrealm.find_ports_like("%s+" % self.sta_prefix)) if (port_list is None) or (len(port_list) < 1): raise ValueError("Unable to find ports named '%s'+" % self.sta_prefix) self.l3_udp_profile.create(endp_type="lf_udp", side_a=port_list, side_b="%d.%s" % (self.resource, self.upstream_port), suppress_related_commands=True) # Create TCP endpoints self.l3_tcp_profile = self.localrealm.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.localrealm.find_ports_like("%s+" % self.sta_prefix)), side_b="%d.%s" % (self.resource, self.upstream_port), suppress_related_commands=True)
def run(self): print( "See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test" ) eth1IP = super().json_get("/port/1/1/eth1") if eth1IP['interface']['ip'] == "0.0.0.0": print("Warning: Eth1 lacks ip address") exit(1) # Create stations and turn dhcp on print("Creating station and turning on dhcp") response = super().json_get("/" + staNameUri) if response is not None: if response["interface"] is not None: print("removing old station") removePort(1, staName, mgrURL) waitUntilPortsDisappear(mgrURL, [staName]) time.sleep(1) url = "cli-json/add_sta" data = { "shelf": 1, "resource": 1, "radio": "wiphy0", "sta_name": staName, "ssid": "jedway-wpa2-x2048-4-4", "key": "jedway-wpa2-x2048-4-4", "mode": 0, "mac": "xx:xx:xx:xx:*:xx", "flags": (0x400 + 0x20000 + 0x1000000000) # create admin down } super().json_post(url, data, suppress_related_commands_=suppress_related) wait_until_ports_appear(mgrURL, [staName], True) time.sleep(8) reqURL = "cli-json/set_port" data = { "shelf": 1, "resource": 1, "port": staName, "current_flags": (0x1 + 0x80000000), "interest": (0x2 + 0x4000 + 0x800000) # current, dhcp, down, } super().json_post(reqURL, data, suppress_related_commands_=suppress_related) time.sleep(0.5) super().json_post("cli-json/set_port", portUpRequest(1, staName)) reqURL = "cli-json/nc_show_ports" data = {"shelf": 1, "resource": 1, "port": staName, "probe_flags": 1} super().json_post(reqURL, data, suppress_related_commands_=suppress_related) time.sleep(0.5) waitUntilPortsAdminUp(1, mgrURL, [staName]) duration = 0 maxTime = 300 ip = "0.0.0.0" while (ip == "0.0.0.0") and (duration < maxTime): station_info = super().json_get("/" + staNameUri + "?fields=port,ip") LFUtils.debug_printer.pprint(station_info) if (station_info is not None) and ("interface" in station_info) and ( "ip" in station_info["interface"]): ip = station_info["interface"]["ip"] if ip == "0.0.0.0": duration += 4 time.sleep(4) else: break if duration >= maxTime: print(staName + " failed to get an ip. Ending test") print("Cleaning up...") removePort(1, staName, mgrURL) sys.exit(1) print("Creating endpoints and cross connects") #==============| ENDPOINT CREATION |================= # create l4 endpoint url = "/cli-json/add_l4_endp" data = { "alias": "l4Test", "shelf": 1, "resource": 1, "port": staName, "type": "l4_generic", "timeout": 1000, "url_rate": 600, "url": "dl http://localhost/ /dev/null", "proxy_port": "NA" } super().json_post(url, data, suppress_related_commands_=suppress_related) data = {"endpoint": "all"} super().json_post("/cli-json/nc_show_endpoints", data, suppress_related_commands_=suppress_related) time.sleep(5) # create fileio endpoint url = "/cli-json/add_file_endp" data = { "alias": "fioTest", "shelf": 1, "resource": 1, "port": staName, "type": "fe_nfs", "directory": "/mnt/fe-test" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(1) data = {"endpoint": "all"} super().json_post("/cli-json/nc_show_endpoints", data) time.sleep(1) # create generic endpoints genl = GenericCx(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port) genl.createGenEndp("genTest1", 1, 1, staName, "gen_generic") genl.createGenEndp("genTest2", 1, 1, staName, "gen_generic") genl.setFlags("genTest1", "ClearPortOnStart", 1) genl.setFlags("genTest2", "ClearPortOnStart", 1) genl.setFlags("genTest2", "Unmanaged", 1) genl.setCmd("genTest1", "lfping -i 0.1 -I %s 10.40.0.1" % staName) time.sleep(.05) data = {"endpoint": "all"} super().json_post("/cli-json/nc_show_endpoints", data, suppress_related_commands_=suppress_related) # create redirects for wanlink url = "/cli-json/add_rdd" data = { "shelf": 1, "resource": 1, "port": "rdd0", "peer_ifname": "rdd1" } super().json_post(url, data, suppress_related_commands_=suppress_related) url = "/cli-json/add_rdd" data = { "shelf": 1, "resource": 1, "port": "rdd1", "peer_ifname": "rdd0" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) # reset redirect ports url = "/cli-json/reset_port" data = {"shelf": 1, "resource": 1, "port": "rdd0"} super().json_post(url, data, suppress_related_commands_=suppress_related) url = "/cli-json/reset_port" data = {"shelf": 1, "resource": 1, "port": "rdd1"} super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) # create wanlink endpoints url = "/cli-json/add_wl_endp" data = { "alias": "wlan0", "shelf": 1, "resource": 1, "port": "rdd0", "latency": 20, "max_rate": 1544000 } super().json_post(url, data, suppress_related_commands_=suppress_related) url = "/cli-json/add_wl_endp" data = { "alias": "wlan1", "shelf": 1, "resource": 1, "port": "rdd1", "latency": 30, "max_rate": 1544000 } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) data = {"endpoint": "all"} super().json_post("/cli-json/nc_show_endpoints", data, suppress_related_commands_=suppress_related) time.sleep(10) #==============| CX CREATION |=================== # create cx for tcp and udp cmd = ( "./lf_firemod.pl --action create_cx --cx_name testTCP --use_ports %s,eth1 --use_speeds 360000," "150000 --endp_type tcp > ~/Documents/connectTestLogs/connectTestLatest.log" % staName) execWrap(cmd) cmd = ( "./lf_firemod.pl --action create_cx --cx_name testUDP --use_ports %s,eth1 --use_speeds 360000," "150000 --endp_type udp >> ~/Documents/connectTestLogs/connectTestLatest.log" % staName) execWrap(cmd) time.sleep(.05) # create cx for l4_endp url = "/cli-json/add_cx" data = { "alias": "CX_l4Test", "test_mgr": "default_tm", "tx_endp": "l4Test", "rx_endp": "NA" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) # create fileio cx url = "/cli-json/add_cx" data = { "alias": "CX_fioTest", "test_mgr": "default_tm", "tx_endp": "fioTest", "rx_endp": "NA" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) # create generic cx url = "/cli-json/add_cx" data = { "alias": "CX_genTest1", "test_mgr": "default_tm", "tx_endp": "genTest1", "rx_endp": "genTest2" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.05) # create wanlink cx url = "/cli-json/add_cx" data = { "alias": "CX_wlan0", "test_mgr": "default_tm", "tx_endp": "wlan0", "rx_endp": "wlan1" } super().json_post(url, data, suppress_related_commands_=suppress_related) time.sleep(.5) data = {"endpoint": "all"} super().json_post("/cli-json/nc_show_endpoints", data, suppress_related_commands_=suppress_related) cxNames = [ "testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlan0" ] # get data before running traffic try: get_info = {} sleep(5) get_info['testTCPA'] = super().json_get( "/endp/testTCP-A?fields=tx+bytes,rx+bytes") get_info['testTCPB'] = super().json_get( "/endp/testTCP-B?fields=tx+bytes,rx+bytes") get_info['testUDPA'] = super().json_get( "/endp/testUDP-A?fields=tx+bytes,rx+bytes") get_info['testUDPB'] = super().json_get( "/endp/testUDP-B?fields=tx+bytes,rx+bytes") get_info['l4Test'] = super().json_get( "/layer4/l4Test?fields=bytes-rd") get_info['genTest1'] = super().json_get( "/generic/genTest1?fields=last+results") get_info['wlan0'] = super().json_get("/wl_ep/wlan0") get_info['wlan1'] = super().json_get("/wl_ep/wlan1") for name in get_info: #print("==================\n"+name+"\n====================") if 'endpoint' not in get_info[name]: print(get_info[name]) raise ValueError("%s missing endpoint value" % name) testTCPATX = get_info['testTCPA']['endpoint']['tx bytes'] testTCPARX = get_info['testTCPA']['endpoint']['rx bytes'] testTCPBTX = get_info['testTCPB']['endpoint']['tx bytes'] testTCPBRX = get_info['testTCPB']['endpoint']['rx bytes'] testUDPATX = get_info['testUDPA']['endpoint']['tx bytes'] testUDPARX = get_info['testUDPA']['endpoint']['rx bytes'] testUDPBTX = get_info['testUDPB']['endpoint']['tx bytes'] testUDPBRX = get_info['testUDPB']['endpoint']['rx bytes'] l4TestBR = get_info['l4Test']['endpoint']['bytes-rd'] genTest1LR = get_info['genTest1']['endpoint']['last results'] wlan0TXB = get_info['wlan0']['endpoint']['tx bytes'] wlan0RXP = get_info['wlan0']['endpoint']['rx pkts'] wlan1TXB = get_info['wlan1']['endpoint']['tx bytes'] wlan1RXP = get_info['wlan1']['endpoint']['rx pkts'] except Exception as e: print("Something went wrong") print(e) print("Cleaning up...") time.sleep(15) LFUtils.removePort(1, staName, mgrURL) endpNames = [ "testTCP-A", "testTCP-B", "testUDP-A", "testUDP-B", "l4Test", "fioTest", "genTest1", "genTest2", "wlan0", "wlan1" ] removeCX(mgrURL, cxNames) removeEndps(mgrURL, endpNames) traceback.print_stack() sys.exit(1) # start cx traffic print("\nStarting CX Traffic") for name in range(len(cxNames)): cmd = ( "./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm %s RUNNING\" >> /tmp/connectTest.log" % (cxNames[name])) execWrap(cmd) # print("Sleeping for 5 seconds") time.sleep(5) # show tx and rx bytes for ports os.system( "echo eth1 >> ~/Documents/connectTestLogs/connectTestLatest.log") cmd = ( "./lf_portmod.pl --quiet 1 --manager localhost --port_name eth1 --show_port \"Txb,Rxb\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo %s >> ~/Documents/connectTestLogs/connectTestLatest.log" % staName) cmd = ( "./lf_portmod.pl --quiet 1 --manager localhost --port_name %s --show_port \"Txb,Rxb\" >> ~/Documents/connectTestLogs/connectTestLatest.log" % staName) execWrap(cmd) # show tx and rx for endpoints PERL os.system( "echo TestTCP-A >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name testTCP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo TestTCP-B >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name testTCP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo TestUDP-A >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name testUDP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo TestUDP-B >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name testUDP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo l4Test >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name l4Test --endp_vals Bytes-Read-Total >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo fioTest >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name fioTest --endp_vals \"Bytes Written,Bytes Read\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo genTest1 >> ~/Documents/connectTestLogs/connectTestLatest.log" ) cmd = ( "./lf_firemod.pl --action show_endp --endp_name genTest1 >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo wlan0 >> ~/Documents/connectTestLogs/connectTestLatest.log") cmd = ( "./lf_firemod.pl --action show_endp --endp_name wlan0 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) os.system( "echo wlan1 >> ~/Documents/connectTestLogs/connectTestLatest.log") cmd = ( "./lf_firemod.pl --action show_endp --endp_name wlan1 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> ~/Documents/connectTestLogs/connectTestLatest.log" ) execWrap(cmd) # stop cx traffic print("Stopping CX Traffic") for name in range(len(cxNames)): cmd = ( "./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm %s STOPPED\" >> /tmp/connectTest.log" % (cxNames[name])) execWrap(cmd) # print("Sleeping for 15 seconds") time.sleep(15) # get data for endpoints JSON print("Collecting Data") try: ptestTCPA = super().json_get( "endp/testTCP-A?fields=tx+bytes,rx+bytes") ptestTCPATX = ptestTCPA['endpoint']['tx bytes'] ptestTCPARX = ptestTCPA['endpoint']['rx bytes'] ptestTCPB = super().json_get( "/endp/testTCP-B?fields=tx+bytes,rx+bytes") ptestTCPBTX = ptestTCPB['endpoint']['tx bytes'] ptestTCPBRX = ptestTCPB['endpoint']['rx bytes'] ptestUDPA = super().json_get( "/endp/testUDP-A?fields=tx+bytes,rx+bytes") ptestUDPATX = ptestUDPA['endpoint']['tx bytes'] ptestUDPARX = ptestUDPA['endpoint']['rx bytes'] ptestUDPB = super().json_get( "/endp/testUDP-B?fields=tx+bytes,rx+bytes") ptestUDPBTX = ptestUDPB['endpoint']['tx bytes'] ptestUDPBRX = ptestUDPB['endpoint']['rx bytes'] pl4Test = super().json_get("/layer4/l4Test?fields=bytes-rd") pl4TestBR = pl4Test['endpoint']['bytes-rd'] pgenTest1 = super().json_get( "/generic/genTest1?fields=last+results") pgenTest1LR = pgenTest1['endpoint']['last results'] pwlan0 = super().json_get("/wl_ep/wlan0") pwlan0TXB = pwlan0['endpoint']['tx bytes'] pwlan0RXP = pwlan0['endpoint']['rx pkts'] pwlan1 = super().json_get("/wl_ep/wlan1") pwlan1TXB = pwlan1['endpoint']['tx bytes'] pwlan1RXP = pwlan1['endpoint']['rx pkts'] except Exception as e: print("Something went wrong") print(e) print("Cleaning up...") time.sleep(15) reqURL = "/cli-json/rm_vlan" data = {"shelf": 1, "resource": 1, "port": staName} super().json_post(reqURL, data, suppress_related_commands_=suppress_related) endpNames = [ "testTCP-A", "testTCP-B", "testUDP-A", "testUDP-B", "l4Test", "fioTest", "genTest1", "genTest2", "wlan0", "wlan1" ] removeCX(mgrURL, cxNames) removeEndps(mgrURL, endpNames) sys.exit(1) # print("Sleeping for 5 seconds") time.sleep(5) print("\n") self.CompareVals("testTCP-A TX", testTCPATX, ptestTCPATX) self.CompareVals("testTCP-A RX", testTCPARX, ptestTCPARX) self.CompareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX) self.CompareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX) self.CompareVals("testUDP-A TX", testUDPATX, ptestUDPATX) self.CompareVals("testUDP-A RX", testUDPARX, ptestUDPARX) self.CompareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX) self.CompareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX) self.CompareVals("l4Test Bytes Read", l4TestBR, pl4TestBR) self.CompareVals("genTest1 Last Results", genTest1LR, pgenTest1LR) self.CompareVals("wlan0 TX Bytes", wlan0TXB, pwlan0TXB) self.CompareVals("wlan0 RX Pkts", wlan0RXP, pwlan0RXP) self.CompareVals("wlan1 TX Bytes", wlan1TXB, pwlan1TXB) self.CompareVals("wlan1 RX Pkts", wlan1RXP, pwlan1RXP) print("\n") # remove all endpoints and cxs print("Cleaning up...") LFUtils.removePort(1, staName, mgrURL) endpNames = [ "testTCP-A", "testTCP-B", "testUDP-A", "testUDP-B", "l4Test", "fioTest", "genTest1", "genTest2", "wlan0", "wlan1" ] removeCX(mgrURL, cxNames) removeEndps(mgrURL, endpNames)