lf_interop_ping.py : Added Real + Virtual and pinging devices / ip's from a particular ip provided(--sta_port)#64
lf_interop_ping.py : Added Real + Virtual and pinging devices / ip's from a particular ip provided(--sta_port)#64manoj9088 wants to merge 2 commits into
Conversation
…-clients_type -> Real Clients, Virtual Stations, Existing Virtual Stations, Real + Virtual Stations" Signed-off-by: Manoj9088 <manoj.kolluru@candelatech.com>
… clients type Real, Virtual, Existing Station List, Real + Virtual, Real + Existing Station and Added functionality of Pinging different ips from one ip(--sta_port) VERIFIED CLI: 1.python3 lf_interop_ping.py --mgr 192.168.207.78 --ping_interval 5 --ping_duration 1 --expected_passfail_value 5 --clients_type both --target 8.8.8.8 --num_sta 5 --ssid NETGEAR_5G_wpa2 --passwd Password@123 --security wpa2 --radio 1.1.wiphy1 --use_default_config 2.python3 lf_interop_ping.py --mgr 192.168.207.78 --ping_interval 5 --ping_duration 1 --expected_passfail_value 5 --clients_type real --sta_to_res --sta_port 1.1.eth1 --use_default_config --res_ip 192.168.204.84 --device_list 1.4,1.15 Signed-off-by: Manoj9088 <manoj.kolluru@candelatech.com>
| if use_existing_sta_list: | ||
| logger.info(f"Using existing stations provided in --existing_sta_list: {existing_sta_list}") | ||
| lis = existing_sta_list.split(',') if existing_sta_list else [] | ||
| logger.info(lis) | ||
| valid_stations = [] | ||
| for station in lis: | ||
| logger.info(f"Verifying station {station} from the provided --existing_sta_list") | ||
| station = station.strip() | ||
| rv = station.split('.') | ||
| response = self.json_get(f"/port/{rv[0]}/{rv[1]}/{rv[2]}") | ||
|
|
||
| try: | ||
| if (response['interface'] | ||
| and response['interface']['ip'] != "0.0.0.0" | ||
| and str(response['interface']['down']).lower() == "false" | ||
| and str(response['interface']['phantom']).lower() == "false" | ||
| and response['interface']['parent dev'] != ""): | ||
|
|
||
| logger.info(f"Station {station} exists and will be used for the test") | ||
| valid_stations.append(station) | ||
| else: | ||
| logger.info(f"Station {station} is not up and running") | ||
|
|
||
| except Exception: | ||
| logger.warning(f"Station {station} does not exist") | ||
|
|
||
| lis = valid_stations | ||
| if lis == []: | ||
| if not self.real: | ||
| logger.info("No valid stations found in the provided --existing_sta_list, exiting the test") | ||
| exit(1) | ||
| else: | ||
| logger.info("no valid stations so proceding with the real clients only") | ||
| self.virtual = False | ||
| self.sta_list = lis | ||
| logger.info(f"final station list {self.sta_list}") | ||
| self.use_existing_sta_list = use_existing_sta_list |
There was a problem hiding this comment.
Add this is to seperate class function . try to keep __init__ and main() clean.
| self.wait_time = wait_time | ||
|
|
||
| self.last_written_seq = {} | ||
| # self.last_Result_per_Station = {} |
There was a problem hiding this comment.
remove unecccesary comments
| def monitor_virtual(self, result_data, ports_data, ping_stats, rtts, rtts_list): | ||
| if isinstance(result_data, dict): | ||
| for station in self.sta_list: |
There was a problem hiding this comment.
Add docstring comment to the function describing it's functionality.
| temp_last_results = result_data['last results'].split('\n')[0: len(result_data['last results']) - 1] | ||
| drop_count = 0 # let dropped = 0 initially | ||
| dropped_packets = [] | ||
| # sample result - 64 bytes from 192.168.1.61: icmp_seq=28 time=3.66 ms *** drop: 0 (0, 0.000) rx: 28 fail: 0 bytes: 1792 min/avg/max: 2.160/3.422/5.190 |
There was a problem hiding this comment.
in line comments are looking good! it really helps for tracing the code.
| self.result_json[station]['rtts'] = {} | ||
| self.result_json[station]['rtts'] = rtts[station] | ||
| self.result_json[station]['remarks'] = self.generate_remarks(self.result_json[station]) | ||
| # self.result_json[station]['dropped_packets'] = dropped_packets |
There was a problem hiding this comment.
remove unnecessary comment
| # Sets the result json for real stations and also populates ping_stats and rtts which are used for generating remarks and graphs respectively | ||
| def monitor_real(self, result_data, Devices, ping_stats, rtts, rtts_list): | ||
| devices = self.real_sta_list |
There was a problem hiding this comment.
Add docstring comment!
| self.result_json[station]['rtts'] = rtts[station] | ||
| self.result_json[station]['remarks'] = self.generate_remarks(self.result_json[station]) | ||
|
|
||
| # logger.info(f"current device data {current_device_data} for station {station}") |
There was a problem hiding this comment.
remove all unnecessary comments.
| def generate_real_time_csv(self): | ||
| csv_dir = "csv_reports" | ||
|
|
There was a problem hiding this comment.
add docstring comment
| def get_safe_last_result(self, last_results): | ||
| if not last_results or last_results.strip() == "": | ||
| return "" |
There was a problem hiding this comment.
Add docstring comment
| except Exception: | ||
| pass |
There was a problem hiding this comment.
Instead of passing the exception . log some error.
| @@ -426,9 +1083,13 @@ def change_port_to_ip(self, upstream_port): | |||
| upstream_port = target_port_ip | |||
| except Exception: | |||
| logging.warning(f'The upstream port is not an ethernet port. Proceeding with the given upstream_port {upstream_port}.') | |||
| logging.info(f"Upstream port IP {upstream_port}") | |||
| if skip_info_logs: | |||
| return "" | |||
| if not skip_info_logs: | |||
| logging.info(f"Upstream port IP {upstream_port}") | |||
| else: | |||
| logging.info(f"Upstream port IP {upstream_port}") | |||
| if not skip_info_logs: | |||
| logging.info(f"Upstream port IP {upstream_port}") | |||
There was a problem hiding this comment.
I guess these changes should come in sta_to_res commit
| # When expected_passfail_val is provided, for pass/fail criteria, the same value will be used for all clients | ||
| else: | ||
| self.test_input_list = [self.expected_passfail_val for val in range(len(self.device_names))] | ||
| lis = self.res_ip_list if self.sta_to_res else self.sta_list |
| if self.sta_to_res: | ||
| self.packets_sent.append(int(device_data['sent'])) | ||
| self.packets_received.append(int(device_data['recv'])) | ||
| self.packets_dropped.append(int(device_data['dropped'])) | ||
|
|
||
| # print("device",device) | ||
| # device_key = device.split('-')[0] | ||
| print(self.cx_dev_map) | ||
| print(self.cx_ip_map) | ||
| if device in self.cx_dev_map and self.cx_dev_map[device] != "": | ||
| device_name = "{}/{}".format(self.cx_dev_map[device], self.cx_ip_map[device]) | ||
| else: | ||
| try: | ||
| device_name = self.cx_ip_map[device] | ||
| except Exception: | ||
| device_name = device | ||
| self.device_names.append(device_name) # endpoint key only | ||
| self.report_names.append(device_name) |
There was a problem hiding this comment.
move to 2nd commit. since sta_to_res changes are there in 2nd commit
| optional.add_argument('--clients_type', | ||
| type=str, | ||
| help='specify the client type example: real or virtual or both', | ||
| default="") |
There was a problem hiding this comment.
add option of --client_type
| ping.stop_generic() | ||
| timestamp = (timedelta(minutes=int(ping.duration)) + ping.start_time).strftime("%d/%m/%Y %H:%M:%S") | ||
| csv_dir = "csv_reports" | ||
| print(f"ping.result_json: \n \n{ping.result_json}") |
| # logger.info(ping.result_json) | ||
|
|
||
| # station post cleanup | ||
| ping.cleanup() | ||
|
|
||
| # if args.sta_to_res: | ||
| # ping.generate_generic_report() |
No description provided.