mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	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<greearb@candelatech.com>
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
							
								
								
									
										390
									
								
								py-json/realm.py
									
									
									
									
									
								
							
							
						
						
									
										390
									
								
								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: | ||||
|   | ||||
							
								
								
									
										0
									
								
								py-scripts/__init__.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/__init__.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/cicd_TipIntegration.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/cicd_TipIntegration.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/cicd_testrail.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/cicd_testrail.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/cicd_testrailAndInfraSetup.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/cicd_testrailAndInfraSetup.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/test_l3_WAN_LAN.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/test_l3_WAN_LAN.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										295
									
								
								py-scripts/test_l3_longevity.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										295
									
								
								py-scripts/test_l3_longevity.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -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 <duration> --endp_type <traffic type> --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> | ||||
| python .\\test_l3_longevity.py --test_duration <duration> --endp_type <traffic types> --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> | ||||
|  | ||||
| Note:   multiple --radio switches may be entered up to the number of radios available: | ||||
|                  --radio <radio 0> <stations> <ssid> <ssid password>  --radio <radio 01> <number of last station> <ssid> <ssid password> | ||||
| @@ -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 <hostname for where LANforge GUI is running>',default='localhost') | ||||
|     parser.add_argument('-d','--test_duration', help='--test_duration <how long to run>  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 <type of traffic> 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 <types of traffic> 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 <cross connect 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=('<wiphyX>', '<number last station>','<ssid>','<ssid password>'), | ||||
|                          help ='--radio  <number_of_wiphy> <number of last station> <ssid>  <ssid password> ',required=True) | ||||
|     requiredNamed.add_argument('-r', '--radio', action='append', nargs=5, metavar=('<wiphyX>', '<number last station>', '<ssid>', '<ssid password>', 'security'), | ||||
|                          help ='--radio  <number_of_wiphy> <number of last station> <ssid>  <ssid password> <security>', 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() | ||||
|   | ||||
							
								
								
									
										0
									
								
								py-scripts/test_l3_unicast_traffic_gen.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/test_l3_unicast_traffic_gen.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/test_open_connection.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/test_open_connection.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								py-scripts/test_wanlink.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								py-scripts/test_wanlink.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
		Reference in New Issue
	
	Block a user
	 Ben Greear
					Ben Greear