mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 10:48:02 +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 |     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 |     Deprecated | ||||||
|     :param resource_id: |     :param resource_id: | ||||||
| @@ -369,12 +369,30 @@ def waitUntilPortsAppear(resource_id=1, base_url="http://localhost:8080", port_l | |||||||
|     :param debug: |     :param debug: | ||||||
|     :return: |     :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 base_url: | ||||||
|     :param port_list: |     :param port_list: | ||||||
|     :param debug: |     :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): |     while len(found_stations) < len(port_list): | ||||||
|         found_stations = [] |         found_stations = [] | ||||||
|         for port_name in port_list: |         for port_eid in port_list: | ||||||
|             sleep(1) |  | ||||||
|  |             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) |             uri = "%s/%s/%s" % (port_url, resource_id, port_name) | ||||||
|             lf_r = LFRequest.LFRequest(base_url, uri) |             lf_r = LFRequest.LFRequest(base_url, uri) | ||||||
|             json_response = lf_r.getAsJson(debug_=False) |             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) |                 found_stations.append(port_name) | ||||||
|             else: |             else: | ||||||
|                 lf_r = LFRequest.LFRequest(base_url, ncshow_url) |                 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() |                 lf_r.formPost() | ||||||
|     sleep(2) |         if (len(found_stations) < len(port_list)): | ||||||
|  |             sleep(2) | ||||||
|  |  | ||||||
|     if debug: |     if debug: | ||||||
|         print("These stations appeared: " + ", ".join(found_stations)) |         print("These stations appeared: " + ", ".join(found_stations)) | ||||||
|     return |     return | ||||||
|   | |||||||
							
								
								
									
										390
									
								
								py-json/realm.py
									
									
									
									
									
								
							
							
						
						
									
										390
									
								
								py-json/realm.py
									
									
									
									
									
								
							| @@ -127,6 +127,22 @@ class Realm(LFCliBase): | |||||||
|                                         port_list=sta_list, |                                         port_list=sta_list, | ||||||
|                                         debug=debug_) |                                         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): |     def channel_freq(self, channel_=0): | ||||||
|         return self.chan_to_freq[channel_] |         return self.chan_to_freq[channel_] | ||||||
|  |  | ||||||
| @@ -303,68 +319,47 @@ class Realm(LFCliBase): | |||||||
|         return matched_map |         return matched_map | ||||||
|  |  | ||||||
|     def name_to_eid(self, eid): |     def name_to_eid(self, eid): | ||||||
|         info = [] |         return LFUtils.name_to_eid(eid) | ||||||
|         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) |  | ||||||
|  |  | ||||||
|         info = eid.split('.') |     def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): | ||||||
|         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 |  | ||||||
|         print("Waiting for ips...") |         print("Waiting for ips...") | ||||||
|  |         print(station_list) | ||||||
|  |  | ||||||
|         if (station_list is None) or (len(station_list) < 1): |         if (station_list is None) or (len(station_list) < 1): | ||||||
|             raise ValueError("wait_for_ip: expects non-empty list of ports") |             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'])): |         wait_more = True | ||||||
|             for k, v in response['interfaces'][x].items(): |         while wait_more and timeout_sec != 0: | ||||||
|                 if "wlan" not in v['alias'] and v['port type'] == "WIFI-STA" \ |             wait_more = False | ||||||
|                         or v['port type'] == "Ethernet": |  | ||||||
|                     num_ports += 1 |  | ||||||
|         if ipv6: |  | ||||||
|             num_ports -= 1  # Prevents eth0 from being counted, preventing infinite loop |  | ||||||
|  |  | ||||||
|         while num_ips != num_ports and timeout_sec != 0: |             for sta_eid in station_list: | ||||||
|             num_ips = 0 |                 print("sta-eid: %s"%(sta_eid)) | ||||||
|             response = super().json_get("/port/1/%s/%s?fields=alias,ip,port+type,ipv6+address" % |                 eid = self.name_to_eid(sta_eid) | ||||||
|                                         (resource, ",".join(station_list))) |  | ||||||
|             if (response is None) or ("interfaces" not in response): |  | ||||||
|                 print("station_list: incomplete response:") |  | ||||||
|                 pprint(response) |  | ||||||
|                 exit(1) |  | ||||||
|  |  | ||||||
|             if not ipv6: |                 response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % | ||||||
|                 for x in range(len(response['interfaces'])): |                                             (eid[0], eid[1], eid[2])) | ||||||
|                     for k, v in response['interfaces'][x].items(): |                 if (response is None) or ("interface" not in response): | ||||||
|                         if "wlan" not in v['alias'] and v['port type'] == "WIFI-STA" or v['port type'] == "Ethernet": |                     print("station_list: incomplete response:") | ||||||
|                             if v['ip'] != '0.0.0.0': |                     pprint(response) | ||||||
|                                 num_ips += 1 |  | ||||||
|  |                     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) |                 time.sleep(1) | ||||||
|                 timeout_sec -= 1 |                 timeout_sec -= 1 | ||||||
|             if ipv6: |  | ||||||
|                 for x in range(len(response['interfaces'])): |             return not wait_more | ||||||
|                     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 |  | ||||||
|  |  | ||||||
|     def parse_time(self, time_string): |     def parse_time(self, time_string): | ||||||
|         if isinstance(time_string, str): |         if isinstance(time_string, str): | ||||||
| @@ -521,51 +516,13 @@ class MULTICASTProfile(LFCliBase): | |||||||
|     def refresh_mc(self): |     def refresh_mc(self): | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     def admin_up_mc_tx(self, resource, side_mc_tx): |     def start_mc(self, suppress_related_commands=None, debug_ = False): | ||||||
|         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): |  | ||||||
|         if self.debug: |         if self.debug: | ||||||
|             debug_=True |             debug_=True | ||||||
|  |  | ||||||
|         for port_name in side_rx: |         for endp_name in self.get_mc_names(): | ||||||
|             side_rx_info = self.local_realm.name_to_eid(port_name) |  | ||||||
|             side_rx_resource = side_rx_info[2] |  | ||||||
|             side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) |  | ||||||
|  |  | ||||||
|             json_data = { |             json_data = { | ||||||
|                             "endp_name":side_rx_resource |                 "endp_name":endp_name | ||||||
|             } |             } | ||||||
|             url = "cli-json/start_endp" |             url = "cli-json/start_endp" | ||||||
|             self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) |             self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) | ||||||
| @@ -573,26 +530,45 @@ class MULTICASTProfile(LFCliBase): | |||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     def stop_mc(self): |     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: |         if self.debug: | ||||||
|             debug_=True |             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 = [] |         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 |         #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 = { |         json_data = { | ||||||
|                         'alias':endp_name, |                         'alias':side_tx_name, | ||||||
|                         'shelf':1, |                         'shelf':side_tx_shelf, | ||||||
|                         'resource':1, |                         'resource':side_tx_resource, | ||||||
|                         'port':side_tx, |                         'port':side_tx_port, | ||||||
|                         'type':'mc_udp', |                         'type':endp_type, | ||||||
|                         'ip_port':-1, |                         'ip_port':-1, | ||||||
|                         'is_rate_bursty': |                         'is_rate_bursty': | ||||||
|                         'NO','min_rate':4000000, |                         '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 |         #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No  # critical | ||||||
|         json_data = { |         json_data = { | ||||||
|                         'name':endp_name, |                         'name':side_tx_name, | ||||||
|                         'ttl':32,'mcast_group':'224.9.9.9', |                         'ttl':32, | ||||||
|  |                         'mcast_group':'224.9.9.9', | ||||||
|                         'mcast_dest_port':9999, |                         'mcast_dest_port':9999, | ||||||
|                         'rcv_mcast':'No' |                         'rcv_mcast':'No' | ||||||
|                     } |                     } | ||||||
| @@ -621,25 +598,28 @@ class MULTICASTProfile(LFCliBase): | |||||||
|         url = "cli-json/set_mc_endp" |         url = "cli-json/set_mc_endp" | ||||||
|         self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) |         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: |         if self.debug: | ||||||
|             debug_=True |             debug_=True | ||||||
|  |  | ||||||
|         for port_name in side_rx: |         for port_name in side_rx: | ||||||
|             side_rx_info = self.local_realm.name_to_eid(port_name) |             side_rx_info = self.local_realm.name_to_eid(port_name) | ||||||
|             side_rx_shelf = side_rx_info[1] |             side_rx_shelf = side_rx_info[0] | ||||||
|             side_rx_resource = side_rx_info[2] |             side_rx_resource = side_rx_info[1] | ||||||
|             side_rx_name = "%s%s"%(self.name_prefix, side_rx_info[2]) |             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 |             # 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 = { |             json_data = { | ||||||
|                             'alias':side_rx_resource, |                             'alias':side_rx_name, | ||||||
|                             'shelf':side_rx_shelf, |                             'shelf':side_rx_shelf, | ||||||
|                             'resource':1, |                             'resource':side_rx_resource, | ||||||
|                             'port':side_rx_resource, |                             'port':side_rx_port, | ||||||
|                             'type':'mc_udp', |                             'type':endp_type, | ||||||
|                             'ip_port':9999, |                             'ip_port':9999, | ||||||
|                             'is_rate_bursty': |                             'is_rate_bursty':'NO', | ||||||
|                             'NO','min_rate':0, |                             'min_rate':0, | ||||||
|                             'max_rate':0, |                             'max_rate':0, | ||||||
|                             'is_pkt_sz_random':'NO', |                             'is_pkt_sz_random':'NO', | ||||||
|                             'min_pkt':1472, |                             '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) |             self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) | ||||||
|  |  | ||||||
|             json_data = { |             json_data = { | ||||||
|                             'name':side_rx_resource, |                             'name':side_rx_name, | ||||||
|                             'ttl':32, |                             'ttl':32, | ||||||
|                             'mcast_group':'224.9.9.9', |                             'mcast_group':'224.9.9.9', | ||||||
|                             'mcast_dest_port':9999, |                             'mcast_dest_port':9999, | ||||||
| @@ -664,6 +644,8 @@ class MULTICASTProfile(LFCliBase): | |||||||
|             url = "cli-json/set_mc_endp" |             url = "cli-json/set_mc_endp" | ||||||
|             self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) |             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): |     def to_string(self): | ||||||
|         pprint.pprint(self) |         pprint.pprint(self) | ||||||
| @@ -708,6 +690,7 @@ class L3CXProfile(LFCliBase): | |||||||
|         self.side_b_max_bps = side_b_max_bps |         self.side_b_max_bps = side_b_max_bps | ||||||
|         self.report_timer = report_timer_ |         self.report_timer = report_timer_ | ||||||
|         self.created_cx = {} |         self.created_cx = {} | ||||||
|  |         self.created_endp = {} | ||||||
|         self.name_prefix = name_prefix_ |         self.name_prefix = name_prefix_ | ||||||
|         self.number_template = number_template_ |         self.number_template = number_template_ | ||||||
|  |  | ||||||
| @@ -725,6 +708,7 @@ class L3CXProfile(LFCliBase): | |||||||
|     def start_cx(self): |     def start_cx(self): | ||||||
|         print("Starting CXs...") |         print("Starting CXs...") | ||||||
|         for cx_name in self.created_cx.keys(): |         for cx_name in self.created_cx.keys(): | ||||||
|  |             print("cx-name: %s"%(cx_name)) | ||||||
|             self.json_post("/cli-json/set_cx_state", { |             self.json_post("/cli-json/set_cx_state", { | ||||||
|                 "test_mgr": "default_tm", |                 "test_mgr": "default_tm", | ||||||
|                 "cx_name": cx_name, |                 "cx_name": cx_name, | ||||||
| @@ -780,7 +764,6 @@ class L3CXProfile(LFCliBase): | |||||||
|             side_b_info = self.local_realm.name_to_eid(side_b) |             side_b_info = self.local_realm.name_to_eid(side_b) | ||||||
|             side_b_shelf = side_b_info[0] |             side_b_shelf = side_b_info[0] | ||||||
|             side_b_resource = side_b_info[1] |             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: |             for port_name in side_a: | ||||||
|                 if port_name.find('.') < 0: |                 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_info = self.local_realm.name_to_eid(port_name) | ||||||
|                 side_a_shelf = side_a_info[0] |                 side_a_shelf = side_a_info[0] | ||||||
|                 side_a_resource = side_a_info[1] |                 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) |                 endp_a_name = cx_name + "-A"; | ||||||
|                 self.created_cx[ cx_name ] = [side_a_name + "-A", side_a_name + "-B"] |                 endp_b_name = cx_name + "-B"; | ||||||
|  |                 self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] | ||||||
|  |                 self.created_endp[endp_a_name] = endp_a_name; | ||||||
|  |                 self.created_endp[endp_b_name] = endp_b_name; | ||||||
|                 endp_side_a = { |                 endp_side_a = { | ||||||
|                     "alias": side_a_name + "-A", |                     "alias": endp_a_name, | ||||||
|                     "shelf": 1, |                     "shelf": side_a_shelf, | ||||||
|                     "resource": side_a_resource, |                     "resource": side_a_resource, | ||||||
|                     "port": side_a_info[2], |                     "port": side_a_info[2], | ||||||
|                     "type": endp_type, |                     "type": endp_type, | ||||||
| @@ -806,8 +792,8 @@ class L3CXProfile(LFCliBase): | |||||||
|                     "ip_port": -1 |                     "ip_port": -1 | ||||||
|                 } |                 } | ||||||
|                 endp_side_b = { |                 endp_side_b = { | ||||||
|                     "alias": side_a_name + "-B", |                     "alias": endp_b_name, | ||||||
|                     "shelf": 1, |                     "shelf": side_b_shelf, | ||||||
|                     "resource": side_b_resource, |                     "resource": side_b_resource, | ||||||
|                     "port": side_b_info[2], |                     "port": side_b_info[2], | ||||||
|                     "type": endp_type, |                     "type": endp_type, | ||||||
| @@ -826,7 +812,7 @@ class L3CXProfile(LFCliBase): | |||||||
|  |  | ||||||
|                 url = "cli-json/set_endp_flag" |                 url = "cli-json/set_endp_flag" | ||||||
|                 data = { |                 data = { | ||||||
|                     "name": side_a_name + "-A", |                     "name": endp_a_name, | ||||||
|                     "flag": "autohelper", |                     "flag": "autohelper", | ||||||
|                     "val": 1 |                     "val": 1 | ||||||
|                 } |                 } | ||||||
| @@ -834,7 +820,7 @@ class L3CXProfile(LFCliBase): | |||||||
|  |  | ||||||
|                 url = "cli-json/set_endp_flag" |                 url = "cli-json/set_endp_flag" | ||||||
|                 data = { |                 data = { | ||||||
|                     "name": side_a_name + "-B", |                     "name": endp_b_name, | ||||||
|                     "flag": "autohelper", |                     "flag": "autohelper", | ||||||
|                     "val": 1 |                     "val": 1 | ||||||
|                 } |                 } | ||||||
| @@ -844,8 +830,8 @@ class L3CXProfile(LFCliBase): | |||||||
|                 data = { |                 data = { | ||||||
|                     "alias": cx_name, |                     "alias": cx_name, | ||||||
|                     "test_mgr": "default_tm", |                     "test_mgr": "default_tm", | ||||||
|                     "tx_endp": side_a_name + "-A", |                     "tx_endp": endp_a_name, | ||||||
|                     "rx_endp": side_a_name + "-B" |                     "rx_endp": endp_b_name, | ||||||
|                 } |                 } | ||||||
|                 #pprint(data) |                 #pprint(data) | ||||||
|                 cx_post_data.append(data) |                 cx_post_data.append(data) | ||||||
| @@ -868,11 +854,15 @@ class L3CXProfile(LFCliBase): | |||||||
|                 side_b_resource = side_b_info[1] |                 side_b_resource = side_b_info[1] | ||||||
|                 side_b_name = side_b_info[2] |                 side_b_name = side_b_info[2] | ||||||
|  |  | ||||||
|                 cx_name = "%s%s" % (self.name_prefix, port_name) |                 cx_name = "%s%s-%i" % (self.name_prefix, port_name, len(self.created_cx)) | ||||||
|                 self.created_cx[ cx_name ] = [side_a_name + "-A", side_a_name + "-B"] |                 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 = { |                 endp_side_a = { | ||||||
|                     "alias": side_b_name + "-A", |                     "alias": endp_a_name, | ||||||
|                     "shelf": 1, |                     "shelf": side_a_shelf, | ||||||
|                     "resource": side_a_resource, |                     "resource": side_a_resource, | ||||||
|                     "port": side_a_info[2], |                     "port": side_a_info[2], | ||||||
|                     "type": endp_type, |                     "type": endp_type, | ||||||
| @@ -883,8 +873,8 @@ class L3CXProfile(LFCliBase): | |||||||
|                     "ip_port": -1 |                     "ip_port": -1 | ||||||
|                 } |                 } | ||||||
|                 endp_side_b = { |                 endp_side_b = { | ||||||
|                     "alias": side_b_name + "-B", |                     "alias": endp_b_name, | ||||||
|                     "shelf": 1, |                     "shelf": side_b_shelf, | ||||||
|                     "resource": side_b_resource, |                     "resource": side_b_resource, | ||||||
|                     "port": side_b_info[2], |                     "port": side_b_info[2], | ||||||
|                     "type": endp_type, |                     "type": endp_type, | ||||||
| @@ -903,7 +893,7 @@ class L3CXProfile(LFCliBase): | |||||||
|  |  | ||||||
|                 url = "cli-json/set_endp_flag" |                 url = "cli-json/set_endp_flag" | ||||||
|                 data = { |                 data = { | ||||||
|                     "name": side_b_name + "-A", |                     "name": endp_a_name, | ||||||
|                     "flag": "autohelper", |                     "flag": "autohelper", | ||||||
|                     "val": 1 |                     "val": 1 | ||||||
|                 } |                 } | ||||||
| @@ -911,7 +901,7 @@ class L3CXProfile(LFCliBase): | |||||||
|  |  | ||||||
|                 url = "cli-json/set_endp_flag" |                 url = "cli-json/set_endp_flag" | ||||||
|                 data = { |                 data = { | ||||||
|                     "name": side_b_name + "-B", |                     "name": enb, | ||||||
|                     "flag": "autohelper", |                     "flag": "autohelper", | ||||||
|                     "val": 1 |                     "val": 1 | ||||||
|                 } |                 } | ||||||
| @@ -920,8 +910,8 @@ class L3CXProfile(LFCliBase): | |||||||
|                 data = { |                 data = { | ||||||
|                     "alias": cx_name, |                     "alias": cx_name, | ||||||
|                     "test_mgr": "default_tm", |                     "test_mgr": "default_tm", | ||||||
|                     "tx_endp": side_b_name + "-A", |                     "tx_endp": endp_a_name, | ||||||
|                     "rx_endp": side_b_name + "-B" |                     "rx_endp": endp_b_name, | ||||||
|                 } |                 } | ||||||
|                 cx_post_data.append(data) |                 cx_post_data.append(data) | ||||||
|                 timer_post_data.append({ |                 timer_post_data.append({ | ||||||
| @@ -953,6 +943,7 @@ class L4CXProfile(LFCliBase): | |||||||
|         self.requests_per_ten = 600 |         self.requests_per_ten = 600 | ||||||
|         self.local_realm = local_realm |         self.local_realm = local_realm | ||||||
|         self.created_cx = {} |         self.created_cx = {} | ||||||
|  |         self.created_endp = [] | ||||||
|  |  | ||||||
|     def check_errors(self, debug=False): |     def check_errors(self, debug=False): | ||||||
|         fields_list = ["!conn", "acc.+denied", "bad-proto", "bad-url", "other-err", "total-err", "rslv-p", "rslv-h", |         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      = ["wpa2_enable", "80211u_enable", "create_admin_down"] | ||||||
|         self.desired_add_sta_flags_mask = ["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.number_template = number_template_ | ||||||
|         self.station_names = [] |         self.station_names = []  # eids | ||||||
|         self.add_sta_data = { |         self.add_sta_data = { | ||||||
|             "shelf": 1, |             "shelf": 1, | ||||||
|             "resource": 1, |             "resource": 1, | ||||||
| @@ -1771,63 +1762,60 @@ class StationProfile: | |||||||
|             json_response = set_port_r.jsonPost(self.debug) |             json_response = set_port_r.jsonPost(self.debug) | ||||||
|             time.sleep(0.03) |             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") |         print("Cleaning up stations") | ||||||
|  |  | ||||||
|         req_url = "/cli-json/rm_vlan" |         req_url = "/cli-json/rm_vlan" | ||||||
|         data = { |         data = { | ||||||
|             "shelf": 1, |             "shelf": 1, | ||||||
|             "resource": resource, |             "resource": 1, | ||||||
|             "port": None |             "port": None | ||||||
|         } |         } | ||||||
|         if (desired_stations is not None): |         if (desired_stations is None): | ||||||
|             if len(desired_stations) < 1: |             return | ||||||
|                 print("No stations requested for cleanup, returning.") |         if len(desired_stations) < 1: | ||||||
|                 return |  | ||||||
|             names = ','.join(desired_stations) |  | ||||||
|             current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) |  | ||||||
|             if current_stations is None: |  | ||||||
|                 return |  | ||||||
|             if "interfaces" in current_stations: |  | ||||||
|                 for station in current_stations['interfaces']: |  | ||||||
|                     for eid,info in station.items(): |  | ||||||
|                         data["port"] = info["alias"] |  | ||||||
|                         self.local_realm.json_post(req_url, data, debug_=self.debug) |  | ||||||
|                         time.sleep(delay) |  | ||||||
|  |  | ||||||
|             if "interface" in current_stations: |  | ||||||
|                 data["port"] = current_stations["interface"]["alias"] |  | ||||||
|                 self.local_realm.json_post(req_url, data, debug_=self.debug) |  | ||||||
|  |  | ||||||
|             return |             return | ||||||
|  |  | ||||||
|         names = ','.join(self.station_names) |         del_count = len(desired_stations) | ||||||
|         current_stations = self.local_realm.json_get("/port/1/%s/%s?fields=alias" % (resource, names)) |  | ||||||
|         if current_stations is None or current_stations['interfaces'] is None: |  | ||||||
|             print("No stations to clean up") |  | ||||||
|             return |  | ||||||
|  |  | ||||||
|         if "interfaces" in current_stations: |         # First, request remove on the list. | ||||||
|             for station in current_stations['interfaces']: |         for port_eid in desired_stations: | ||||||
|                 for eid,info in station.items(): |             eid = self.name_to_eid(port_eid) | ||||||
|                     data["port"] = info["alias"] |             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) |                     self.local_realm.json_post(req_url, data, debug_=self.debug) | ||||||
|                     time.sleep(delay) |                     time.sleep(delay) | ||||||
|  |             if not found_one: | ||||||
|         if "interface" in current_stations: |                 return | ||||||
|             data["port"] = current_stations["interface"]["alias"] |             count = count + 1 | ||||||
|             self.local_realm.json_post(req_url, data, debug_=self.debug) |             time.sleep(1) | ||||||
|  |  | ||||||
|  |  | ||||||
|     # Checks for errors in initialization values and creates specified number of stations using init parameters |     # 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): |     def create(self, radio, num_stations=0, sta_names_=None, dry_run=False, up_=None, debug=False, suppress_related_commands_=True, sleep_time=2): | ||||||
|         # try: |         radio_eid = self.local_realm.name_to_eid(radio) | ||||||
|         #     resource = resource_radio[0: resource_radio.index(".")] |         radio_shelf = radio_eid[0] | ||||||
|         #     name = resource_radio[resource_radio.index(".") + 1:] |         radio_resource = radio_eid[1] | ||||||
|         #     if name.index(".") >= 0: |         radio_port = radio_eid[2] | ||||||
|         #         radio_name = name[name.index(".")+1 : ] |  | ||||||
|         #     print("Building %s on radio %s.%s" % (num_stations, resource, radio_name)) |  | ||||||
|         # except ValueError as e: |  | ||||||
|         #     print(e) |  | ||||||
|  |  | ||||||
|         if self.use_ht160: |         if self.use_ht160: | ||||||
|             self.desired_add_sta_flags.append("ht160_enable") |             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 |         # 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"]      = 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["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, |         self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, | ||||||
|                                                                    set_port.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, |         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 |         # re-use inside a loop, reducing the number of object creations | ||||||
|         add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") |         add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") | ||||||
|         set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") |         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_cli"] = "yes" | ||||||
|             self.add_sta_data["suppress_preexec_method"] = 1 |             self.add_sta_data["suppress_preexec_method"] = 1 | ||||||
|             self.set_port_data["suppress_preexec_cli"] = "yes" |             self.set_port_data["suppress_preexec_cli"] = "yes" | ||||||
| @@ -1875,10 +1864,15 @@ class StationProfile: | |||||||
|         num = 0 |         num = 0 | ||||||
|         #pprint(self.station_names) |         #pprint(self.station_names) | ||||||
|         #exit(1) |         #exit(1) | ||||||
|         for name in self.station_names: |         for name in my_sta_names: | ||||||
|             self.set_port_data["port"] = name |             self.set_port_data["port"] = name | ||||||
|             num += 1 |             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.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) |             add_sta_r.addPostData(self.add_sta_data) | ||||||
|             if debug: |             if debug: | ||||||
|                 print("- 381 - %s- - - - - - - - - - - - - - - - - - " % name) |                 print("- 381 - %s- - - - - - - - - - - - - - - - - - " % name) | ||||||
| @@ -1892,12 +1886,12 @@ class StationProfile: | |||||||
|  |  | ||||||
|             json_response = add_sta_r.jsonPost(debug) |             json_response = add_sta_r.jsonPost(debug) | ||||||
|             # time.sleep(0.03) |             # time.sleep(0.03) | ||||||
|             time.sleep(2) |             time.sleep(sleep_time) | ||||||
|             set_port_r.addPostData(self.set_port_data) |             set_port_r.addPostData(self.set_port_data) | ||||||
|             json_response = set_port_r.jsonPost(debug) |             json_response = set_port_r.jsonPost(debug) | ||||||
|             time.sleep(0.03) |             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 |         # and set ports up | ||||||
|         if dry_run: |         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 | import datetime | ||||||
|  |  | ||||||
| class L3VariableTimeLongevity(LFCliBase): | class L3VariableTimeLongevity(LFCliBase): | ||||||
|     def __init__(self, host, port, endp_type, is_multicast, side_b, radios, radio_name_list, number_of_stations_per_radio_list, |     def __init__(self, host, port, endp_types, side_b, radios, radio_name_list, number_of_stations_per_radio_list, | ||||||
|                  ssid_list, ssid_password_list, security, station_lists, name_prefix, resource=1, |                  ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, | ||||||
|                  side_a_min_rate=56000, side_a_max_rate=0, |                  side_a_min_rate=56000, side_a_max_rate=0, | ||||||
|                  side_b_min_rate=56000, side_b_max_rate=0, |                  side_b_min_rate=56000, side_b_max_rate=0, | ||||||
|                  number_template="00", test_duration="256s", |                  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) |         super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) | ||||||
|         self.host = host |         self.host = host | ||||||
|         self.port = port |         self.port = port | ||||||
|         self.endp_type = endp_type |         self.endp_types = endp_types.split() | ||||||
|         self.is_multicast = is_multicast |  | ||||||
|         self.side_b = side_b |         self.side_b = side_b | ||||||
|         self.ssid_list = ssid_list |         self.ssid_list = ssid_list | ||||||
|         self.ssid_password_list = ssid_password_list |         self.ssid_password_list = ssid_password_list | ||||||
|         self.station_lists = station_lists        |         self.station_lists = station_lists        | ||||||
|         self.security = security |         self.ssid_security_list = ssid_security_list | ||||||
|         self.number_template = number_template |         self.number_template = number_template | ||||||
|         self.resource = resource |  | ||||||
|         self.name_prefix = name_prefix |         self.name_prefix = name_prefix | ||||||
|         self.test_duration = test_duration |         self.test_duration = test_duration | ||||||
|         self.cx_stations_lists = station_lists |  | ||||||
|         self.radios = radios # from the command line |         self.radios = radios # from the command line | ||||||
|         self.radio_list = radio_name_list |         self.radio_list = radio_name_list | ||||||
|         self.number_of_stations_per_radio_list =  number_of_stations_per_radio_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.lfclient_url = self.lfclient_url | ||||||
|             self.station_profile.ssid = ssid_list[index] |             self.station_profile.ssid = ssid_list[index] | ||||||
|             self.station_profile.ssid_pass = ssid_password_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.number_template = self.number_template | ||||||
|             self.station_profile.mode = 0 |             self.station_profile.mode = 0 | ||||||
|             self.station_profiles.append(self.station_profile) |             self.station_profiles.append(self.station_profile) | ||||||
|             index += 1 |             index += 1 | ||||||
|          |          | ||||||
|         if is_multicast: |         self.multicast_profile.host = self.host | ||||||
|             self.multicast_profile.host = self.host |         self.cx_profile.host = self.host | ||||||
|             self.cx_profile.host = self.host |         self.cx_profile.port = self.port | ||||||
|             self.cx_profile.port = self.port |         self.cx_profile.name_prefix = self.name_prefix | ||||||
|             self.cx_profile.name_prefix = self.name_prefix |         self.cx_profile.side_a_min_bps = side_a_min_rate | ||||||
|             self.cx_profile.side_a_min_bps = 0 |         self.cx_profile.side_a_max_bps = side_a_max_rate | ||||||
|             self.cx_profile.side_a_max_bps = 0 |         self.cx_profile.side_b_min_bps = side_b_min_rate | ||||||
|             self.cx_profile.side_b_min_bps = side_b_min_rate |         self.cx_profile.side_b_max_bps = side_b_max_rate | ||||||
|             self.cx_profile.side_b_max_bps = side_b_max_rate |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         else: |  | ||||||
|             self.cx_profile.host = self.host |  | ||||||
|             self.cx_profile.port = self.port |  | ||||||
|             self.cx_profile.name_prefix = self.name_prefix |  | ||||||
|             self.cx_profile.side_a_min_bps = side_a_min_rate |  | ||||||
|             self.cx_profile.side_a_max_bps = side_a_max_rate |  | ||||||
|             self.cx_profile.side_b_min_bps = side_b_min_rate |  | ||||||
|             self.cx_profile.side_b_max_bps = side_b_max_rate |  | ||||||
|  |  | ||||||
|     def __get_rx_values(self): |     def __get_rx_values(self): | ||||||
|         cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) |         endp_list = self.json_get("endp?fields=name,rx+bytes", debug_=True) | ||||||
|         cx_rx_map = {} |         endp_rx_map = {} | ||||||
|         for cx_name in cx_list['endpoint']: |         our_endps = {} | ||||||
|             if cx_name != 'uri' and cx_name != 'handler': |         for e in self.multicast_profile.get_mc_names(): | ||||||
|                 for item, value in cx_name.items(): |             our_endps[e] = e; | ||||||
|                     for value_name, value_rx in value.items(): |         for e in self.cx_profile.created_endp.keys(): | ||||||
|                       if value_name == 'rx bytes': |             our_endps[e] = e; | ||||||
|                         cx_rx_map[item] = value_rx |         for endp_name in endp_list['endpoint']: | ||||||
|         return cx_rx_map |             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): |     def __compare_vals(self, old_list, new_list): | ||||||
|         passes = 0 |         passes = 0 | ||||||
| @@ -98,9 +90,14 @@ class L3VariableTimeLongevity(LFCliBase): | |||||||
|         if len(old_list) == len(new_list): |         if len(old_list) == len(new_list): | ||||||
|             for item, value in old_list.items(): |             for item, value in old_list.items(): | ||||||
|                 expected_passes += 1 |                 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 |                     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: |             if passes == expected_passes: | ||||||
|                 return True |                 return True | ||||||
| @@ -111,50 +108,32 @@ class L3VariableTimeLongevity(LFCliBase): | |||||||
|  |  | ||||||
|     def start(self, print_pass=False, print_fail=False): |     def start(self, print_pass=False, print_fail=False): | ||||||
|         print("Bringing up stations") |         print("Bringing up stations") | ||||||
|         up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.side_b) |         up_request = self.local_realm.admin_up(self.side_b) | ||||||
|         self.local_realm.json_post("/cli-json/set_port", up_request) |  | ||||||
|         for station_profile in self.station_profiles: |         for station_profile in self.station_profiles: | ||||||
|             print("Bringing up station {}".format(station_profile)) |             for sta in station_profile.station_names: | ||||||
|             station_profile.admin_up(self.resource) |                 print("Bringing up station %s"%(sta)) | ||||||
|  |                 up_request = self.local_realm.admin_up(sta) | ||||||
|         if self.is_multicast: |  | ||||||
|             self.multicast_profile.admin_up_mc_tx(self.resource, self.side_b) |  | ||||||
|          |  | ||||||
|  |  | ||||||
|         temp_stations_list = [] |         temp_stations_list = [] | ||||||
|         for station_list in self.station_lists:      |         temp_stations_list.append(self.side_b) | ||||||
|             temp_station_list = station_list.copy() |         for station_profile in self.station_profiles: | ||||||
|             temp_stations_list.append(temp_station_list) |             temp_stations_list.extend(station_profile.station_names.copy()) | ||||||
|             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_station_list = [] |         if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): | ||||||
|         if self.is_multicast: |             print("ip's aquired") | ||||||
|             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) |  | ||||||
|                  |  | ||||||
|         else: |         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() |         cur_time = datetime.datetime.now() | ||||||
|         old_rx_values = self.__get_rx_values() |         old_rx_values = self.__get_rx_values() | ||||||
|         filtered_old_rx_values = [] |  | ||||||
|         if self.is_multicast: |  | ||||||
|             for rx_value in old_rx_values: |  | ||||||
|                 for station in self.station_lists: |  | ||||||
|                     if rx_value in station: |  | ||||||
|                         filtered_old_rx_values += rx_value |  | ||||||
|         else: |  | ||||||
|             filtered_old_rx_values = old_rx_values |  | ||||||
|  |  | ||||||
|         end_time = self.local_realm.parse_time(self.test_duration) + cur_time |         end_time = self.local_realm.parse_time(self.test_duration) + cur_time | ||||||
|  |  | ||||||
|  |         print("Monitoring throughput for duration: %s"%(self.test_duration)) | ||||||
|  |  | ||||||
|         passes = 0 |         passes = 0 | ||||||
|         expected_passes = 0 |         expected_passes = 0 | ||||||
|         while cur_time < end_time: |         while cur_time < end_time: | ||||||
| @@ -164,17 +143,9 @@ class L3VariableTimeLongevity(LFCliBase): | |||||||
|                 time.sleep(1) |                 time.sleep(1) | ||||||
|              |              | ||||||
|             new_rx_values = self.__get_rx_values() |             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 |             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 |                 passes += 1 | ||||||
|             else: |             else: | ||||||
|                 self._fail("FAIL: Not all stations increased traffic", print_fail) |                 self._fail("FAIL: Not all stations increased traffic", print_fail) | ||||||
| @@ -187,96 +158,59 @@ class L3VariableTimeLongevity(LFCliBase): | |||||||
|  |  | ||||||
|     def stop(self): |     def stop(self): | ||||||
|         self.cx_profile.stop_cx() |         self.cx_profile.stop_cx() | ||||||
|  |         self.multicast_profile.stop_mc() | ||||||
|         for station_list in self.station_lists: |         for station_list in self.station_lists: | ||||||
|             for station_name in station_list: |             for station_name in station_list: | ||||||
|                 data = LFUtils.portDownRequest(1, station_name) |                 self.local_realm.admin_down(station_name) | ||||||
|                 url = "cli-json/set_port" |  | ||||||
|                 self.json_post(url, data) |  | ||||||
|  |  | ||||||
|     def cleanup(self, resource): |     def cleanup(self): | ||||||
|         resource = 1 |         self.cx_profile.cleanup() | ||||||
|         data = { |         self.multicast_profile.cleanup() | ||||||
|                     "name":"BLANK", |         for station_profile in self.station_profiles: | ||||||
|                     "action":"overwrite" |             station_profile.cleanup() | ||||||
|         } |  | ||||||
|         url = "cli-json/load" |  | ||||||
|         self.json_post(url, data) |  | ||||||
|         #remove_all_endpoints = True |  | ||||||
|         #self.local_realm.remove_all_cxs(remove_all_endpoints) |  | ||||||
|         #self.local_realm.remove_all_stations(resource) |  | ||||||
|          |  | ||||||
|                                          |                                          | ||||||
|     def build(self): |     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  |         index = 0  | ||||||
|         for station_profile in self.station_profiles: |         for station_profile in self.station_profiles: | ||||||
|             station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) |             station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) | ||||||
|             station_profile.set_number_template(station_profile.number_template) |             station_profile.set_number_template(station_profile.number_template) | ||||||
|             print("Creating stations") |             print("Creating stations") | ||||||
|             temp_station_list = [] |  | ||||||
|  |  | ||||||
|             index = 0  |             index = 0 | ||||||
|             for station_list in self.station_lists:  |             for station_list in self.station_lists:  | ||||||
|                 for station in range(len(station_list)): |                 station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=True, sleep_time=0) | ||||||
|                     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 ) |  | ||||||
|                 index += 1 |                 index += 1 | ||||||
|             if self.is_multicast: |  | ||||||
|                 self.multicast_profile.create_mc_tx(self.side_b) |             for etype in self.endp_types: | ||||||
|                 self.multicast_profile.create_mc_rx(side_rx=temp_station_list) |                 if etype == "mc_udp" or etype == "mc_udp6": | ||||||
|             else: |                     self.multicast_profile.create_mc_tx(etype, self.side_b, etype) | ||||||
|                 self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5) |                     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") |         self._pass("PASS: Stations build finished") | ||||||
|  |  | ||||||
| def valid_endp_type(endp_type): | def valid_endp_types(endp_type): | ||||||
|     valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] |     etypes = endp_type.split() | ||||||
|     if str(endp_type) in valid_endp_type: |     for endp_type in etypes: | ||||||
|         return endp_type |         valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] | ||||||
|     else: |         if not (str(endp_type) in valid_endp_type): | ||||||
|         print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6')     |             print('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) | ||||||
|         exit(1) |             exit(1) | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|     lfjson_host = "localhost" |     lfjson_host = "localhost" | ||||||
|     lfjson_port = 8080 |     lfjson_port = 8080 | ||||||
|  |     endp_types = "lf_udp" | ||||||
|  |  | ||||||
|     parser = argparse.ArgumentParser( |     parser = argparse.ArgumentParser( | ||||||
|         prog='test_l3_longevity.py', |         prog='test_l3_longevity.py', | ||||||
| @@ -287,8 +221,7 @@ def main(): | |||||||
|             1. Polling interval for checking traffic is fixed at 1 minute |             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 |             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 |             3. The tx/rx rates are fixed at 256000 bits per second | ||||||
|             4. Security is fixed at WPA2 |             4. Maximum stations per radio is 64 | ||||||
|             5. Maximum stations per radio is 64 |  | ||||||
|             ''', |             ''', | ||||||
|          |          | ||||||
|         description='''\ |         description='''\ | ||||||
| @@ -302,10 +235,10 @@ Basic Idea: create stations, create traffic between upstream port and stations, | |||||||
|  |  | ||||||
|             Scripts are executed from: ./lanforge/py-scripts   |             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: | 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: | 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> |                  --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 |             5. Radio #2 wiphy1 has 64 stations, ssid = candelaTech-wpa2-x2048-5-3, ssid password = candelaTech-wpa2-x2048-5-3 | ||||||
|  |  | ||||||
|             Command:  |             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('-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', |     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_type) |                         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') |     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 = parser.add_argument_group('required arguments') | ||||||
|     requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('<wiphyX>', '<number last station>','<ssid>','<ssid password>'), |     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> ',required=True) |                          help ='--radio  <number_of_wiphy> <number of last station> <ssid>  <ssid password> <security>', required=True) | ||||||
|     args = parser.parse_args() |     args = parser.parse_args() | ||||||
|  |  | ||||||
|     if args.test_duration: |     if args.test_duration: | ||||||
|         test_duration = args.test_duration |         test_duration = args.test_duration | ||||||
|  |  | ||||||
|     if args.endp_type: |     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: |     if args.upstream_port: | ||||||
|         side_b = 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: |     if args.radio: | ||||||
|         radios = args.radio |         radios = args.radio | ||||||
|      |      | ||||||
|     is_multicast = False |  | ||||||
|  |  | ||||||
|     radio_offset = 0 |     radio_offset = 0 | ||||||
|     number_of_stations_offset = 1 |     number_of_stations_offset = 1 | ||||||
|     ssid_offset = 2 |     ssid_offset = 2 | ||||||
|     ssid_password_offset = 3 |     ssid_password_offset = 3 | ||||||
|  |     ssid_security_offset = 4 | ||||||
|  |  | ||||||
|     MAX_NUMBER_OF_STATIONS = 64 |     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 = [] |     number_of_stations_per_radio_list = [] | ||||||
|     ssid_list = [] |     ssid_list = [] | ||||||
|     ssid_password_list = [] |     ssid_password_list = [] | ||||||
|  |     ssid_security_list = [] | ||||||
|  |  | ||||||
|     if endp_type in ['mc_udp','mc_udp6']: |  | ||||||
|         is_multicast = True |  | ||||||
|  |  | ||||||
|     index = 0 |  | ||||||
|     for radio in radios: |     for radio in radios: | ||||||
|         radio_name = radio[radio_offset] |         radio_name = radio[radio_offset] | ||||||
|         radio_name_list.append(radio_name) |         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) |         number_of_stations_per_radio_list.append(number_of_stations_per_radio) | ||||||
|         ssid = radio[ssid_offset] |         ssid = radio[ssid_offset] | ||||||
|         ssid_list.append(ssid) |         ssid_list.append(ssid) | ||||||
|         ssid_password = radio[ssid_password_offset] |         if (len(radio) >= (ssid_password_offset - 1)): | ||||||
|         ssid_password_list.append(ssid_password) |             ssid_password_list.append(radio[ssid_password_offset]) | ||||||
|         index += 1 |             ssid_security_list.append(radio[ssid_security_offset]) | ||||||
|  |         else: | ||||||
|  |             ssid_password_list.append("NA") | ||||||
|  |             ssid_security_list.append("open") | ||||||
|  |  | ||||||
|     index = 0 |     index = 0 | ||||||
|     station_lists = [] |     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_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) |         station_lists.append(station_list) | ||||||
|         index += 1 |         index += 1 | ||||||
|  |  | ||||||
|     ip_var_test = L3VariableTimeLongevity(lfjson_host,  |     ip_var_test = L3VariableTimeLongevity(lfjson_host,  | ||||||
|                                    lfjson_port,  |                                    lfjson_port,  | ||||||
|                                    number_template="00",  |                                    number_template="00",  | ||||||
|                                    station_lists= station_lists, |                                    station_lists= station_lists, | ||||||
|                                    name_prefix="var_time", |                                    name_prefix="LT-", | ||||||
|                                    endp_type=endp_type, |                                    endp_types=endp_types, | ||||||
|                                    is_multicast=is_multicast, |  | ||||||
|                                    side_b=side_b, |                                    side_b=side_b, | ||||||
|                                    radios=radios, |                                    radios=radios, | ||||||
|                                    radio_name_list=radio_name_list, |                                    radio_name_list=radio_name_list, | ||||||
|                                    number_of_stations_per_radio_list=number_of_stations_per_radio_list, |                                    number_of_stations_per_radio_list=number_of_stations_per_radio_list, | ||||||
|                                    ssid_list=ssid_list, |                                    ssid_list=ssid_list, | ||||||
|                                    ssid_password_list=ssid_password_list, |                                    ssid_password_list=ssid_password_list, | ||||||
|                                    resource=1, |                                    ssid_security_list=ssid_security_list, test_duration=test_duration, | ||||||
|                                    security="wpa2", test_duration=test_duration, |  | ||||||
|                                    side_a_min_rate=256000, side_b_min_rate=256000) |                                    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() |     ip_var_test.build() | ||||||
|     if not ip_var_test.passes(): |     if not ip_var_test.passes(): | ||||||
|  |         print("build step failed.") | ||||||
|         print(ip_var_test.get_fail_message()) |         print(ip_var_test.get_fail_message()) | ||||||
|         exit(1)  |         exit(1)  | ||||||
|     ip_var_test.start(False, False) |     ip_var_test.start(False, False) | ||||||
|     ip_var_test.stop() |     ip_var_test.stop() | ||||||
|     if not ip_var_test.passes(): |     if not ip_var_test.passes(): | ||||||
|  |         print("stop test failed") | ||||||
|         print(ip_var_test.get_fail_message()) |         print(ip_var_test.get_fail_message()) | ||||||
|         exit(1)  |         exit(1)  | ||||||
|  |  | ||||||
|  |     print("Pausing 30 seconds after run for manual inspection before we clean up.") | ||||||
|     time.sleep(30) |     time.sleep(30) | ||||||
|     ip_var_test.cleanup(station_list) |     ip_var_test.cleanup() | ||||||
|     if ip_var_test.passes(): |     if ip_var_test.passes(): | ||||||
|         print("Full test passed, all connections increased rx bytes") |         print("Full test passed, all connections increased rx bytes") | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     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