Skip to content

Commit 63f841e

Browse files
bhargavi-ctbhargavi-ct
andauthored
Wifi 14747 (#1058)
* Update the path to check the controller URL Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com> * Update test_access_points_connectivity for better error handling Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com> --------- Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com> Co-authored-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>
1 parent 33e3459 commit 63f841e

2 files changed

Lines changed: 46 additions & 7 deletions

File tree

libs/tip_2x/ap_lib.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,31 @@ def check_connectivity(self, idx=0, print_log=True, attach_allure=True):
107107
pytest.fail("up0v0 interface is failed to have connectivity!!!")
108108

109109
def get_uci_show(self, param="ucentral", idx=0, print_log=True, attach_allure=True):
110-
output = self.run_generic_command(cmd="uci show " + param, idx=idx,
111-
print_log=print_log,
112-
attach_allure=attach_allure,
113-
expected_attachment_type=allure.attachment_type.TEXT)
114-
110+
command = "uci show " + param
111+
if "server" in param:
112+
output = self.run_generic_command(cmd=command, idx=idx,
113+
print_log=print_log,
114+
attach_allure=attach_allure,
115+
expected_attachment_type=allure.attachment_type.TEXT)
116+
ret_val = str(output).split("=")[1]
117+
if "cicd.lab.wlan.tip.build" in ret_val:
118+
logging.info(f"we are fetching server url with the command: {command}")
119+
else:
120+
command = "cat /etc/ucentral/gateway.json"
121+
logging.info(f"we are fetching server url with the command: {command}")
122+
output = self.run_generic_command(cmd=command, idx=idx,
123+
print_log=print_log,
124+
attach_allure=attach_allure,
125+
expected_attachment_type=allure.attachment_type.TEXT)
126+
else:
127+
logging.info(f"command:{command}")
128+
output = self.run_generic_command(cmd=command, idx=idx,
129+
print_log=print_log,
130+
attach_allure=attach_allure,
131+
expected_attachment_type=allure.attachment_type.TEXT)
115132
return output
116133

134+
117135
def restart_ucentral_service(self, idx=0, print_log=True, attach_allure=True):
118136
output = self.run_generic_command(cmd="/etc/init.d/ucentral restart", idx=idx,
119137
print_log=print_log,

tests/test_connectivity.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,29 @@ def test_access_points_connectivity(self, get_target_object, get_testbed_details
182182
uci_data = []
183183
for i in range(0, len(get_target_object.device_under_tests_info)):
184184
ret_val = get_target_object.get_dut_library_object().get_uci_show(idx=i, param="ucentral.config.server")
185-
ret_val = str(ret_val).split("=")[1]
186-
uci_data.append(ret_val)
185+
186+
logging.info(f"ret_val from get_uci_show:{ret_val}")
187+
if "ucentral.config.server" in ret_val:
188+
ret_val = str(ret_val).split("=")[1]
189+
uci_data.append(ret_val)
190+
else:
191+
ret_val_dict = json.loads(ret_val)
192+
if not ret_val_dict.get("valid") or "server" not in ret_val_dict:
193+
logging.warning(
194+
"First attempt to fetch 'server' from gateway.json failed. Retrying in 5 seconds...")
195+
time.sleep(5)
196+
# Retry
197+
ret_val = get_target_object.get_dut_library_object().get_uci_show(idx=i,
198+
param="ucentral.config.server")
199+
ret_val_dict = json.loads(ret_val)
200+
201+
if not ret_val_dict.get("valid") or "server" not in ret_val_dict:
202+
logging.error("Invalid or missing 'server' after retry. Exiting test.")
203+
pytest.exit("No valid 'server' value found in gateway.json after retry")
204+
205+
uci_data.append(ret_val_dict["server"])
206+
207+
logging.info(f"uci_data::{uci_data}")
187208
gw_host = get_target_object.controller_library_object.gw_host.hostname
188209
expected_host = True
189210
for j in uci_data:

0 commit comments

Comments
 (0)