From 63f841ec43c4c57ff436c2173d1229a01ef17c7a Mon Sep 17 00:00:00 2001 From: bhargavi-ct Date: Wed, 9 Jul 2025 12:47:06 +0530 Subject: [PATCH] Wifi 14747 (#1058) * Update the path to check the controller URL Signed-off-by: bhargavi-ct * Update test_access_points_connectivity for better error handling Signed-off-by: bhargavi-ct --------- Signed-off-by: bhargavi-ct Co-authored-by: bhargavi-ct --- libs/tip_2x/ap_lib.py | 28 +++++++++++++++++++++++----- tests/test_connectivity.py | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/libs/tip_2x/ap_lib.py b/libs/tip_2x/ap_lib.py index af049116d..851aa03e8 100644 --- a/libs/tip_2x/ap_lib.py +++ b/libs/tip_2x/ap_lib.py @@ -107,13 +107,31 @@ class APLIBS: pytest.fail("up0v0 interface is failed to have connectivity!!!") def get_uci_show(self, param="ucentral", idx=0, print_log=True, attach_allure=True): - output = self.run_generic_command(cmd="uci show " + param, idx=idx, - print_log=print_log, - attach_allure=attach_allure, - expected_attachment_type=allure.attachment_type.TEXT) - + command = "uci show " + param + if "server" in param: + output = self.run_generic_command(cmd=command, idx=idx, + print_log=print_log, + attach_allure=attach_allure, + expected_attachment_type=allure.attachment_type.TEXT) + ret_val = str(output).split("=")[1] + if "cicd.lab.wlan.tip.build" in ret_val: + logging.info(f"we are fetching server url with the command: {command}") + else: + command = "cat /etc/ucentral/gateway.json" + logging.info(f"we are fetching server url with the command: {command}") + output = self.run_generic_command(cmd=command, idx=idx, + print_log=print_log, + attach_allure=attach_allure, + expected_attachment_type=allure.attachment_type.TEXT) + else: + logging.info(f"command:{command}") + output = self.run_generic_command(cmd=command, idx=idx, + print_log=print_log, + attach_allure=attach_allure, + expected_attachment_type=allure.attachment_type.TEXT) return output + def restart_ucentral_service(self, idx=0, print_log=True, attach_allure=True): output = self.run_generic_command(cmd="/etc/init.d/ucentral restart", idx=idx, print_log=print_log, diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py index 0f110ccda..3eada5970 100644 --- a/tests/test_connectivity.py +++ b/tests/test_connectivity.py @@ -182,8 +182,29 @@ class TestResources(object): uci_data = [] for i in range(0, len(get_target_object.device_under_tests_info)): ret_val = get_target_object.get_dut_library_object().get_uci_show(idx=i, param="ucentral.config.server") - ret_val = str(ret_val).split("=")[1] - uci_data.append(ret_val) + + logging.info(f"ret_val from get_uci_show:{ret_val}") + if "ucentral.config.server" in ret_val: + ret_val = str(ret_val).split("=")[1] + uci_data.append(ret_val) + else: + ret_val_dict = json.loads(ret_val) + if not ret_val_dict.get("valid") or "server" not in ret_val_dict: + logging.warning( + "First attempt to fetch 'server' from gateway.json failed. Retrying in 5 seconds...") + time.sleep(5) + # Retry + ret_val = get_target_object.get_dut_library_object().get_uci_show(idx=i, + param="ucentral.config.server") + ret_val_dict = json.loads(ret_val) + + if not ret_val_dict.get("valid") or "server" not in ret_val_dict: + logging.error("Invalid or missing 'server' after retry. Exiting test.") + pytest.exit("No valid 'server' value found in gateway.json after retry") + + uci_data.append(ret_val_dict["server"]) + + logging.info(f"uci_data::{uci_data}") gw_host = get_target_object.controller_library_object.gw_host.hostname expected_host = True for j in uci_data: