added json format for ucentral cfg for allure attach

Signed-off-by: shivam <shivam.thakur@candelatech.com>
This commit is contained in:
shivam
2022-09-08 17:53:00 +05:30
parent 1bb50711ff
commit bbd96ae900
2 changed files with 19 additions and 5 deletions

View File

@@ -160,9 +160,17 @@ class APLIBS:
try:
data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
logging.info("Latest config is : " + str(data))
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(latest_uuid),
body=str(json.dumps(data, indent=2)),
attachment_type=allure.attachment_type.JSON)
except Exception as e:
data = output
logging.error("error in converting the output to json" + output)
try_again = True
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(latest_uuid),
body=str(data),
attachment_type=allure.attachment_type.JSON)
return latest_json
def get_active_config(self, idx=0, print_log=True, attach_allure=False):
@@ -181,12 +189,18 @@ class APLIBS:
try:
data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
logging.info("Active config is : " + str(data))
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(active_uuid),
body=str(json.dumps(data, indent=2)),
attachment_type=allure.attachment_type.JSON)
except Exception as e:
data = ""
data = output
logging.error("error in converting the output to json" + output)
try_again = True
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(active_uuid),
body=str(data),
attachment_type=allure.attachment_type.JSON)
print(data)
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(active_uuid), body=str(data), attachment_type=allure.attachment_type.JSON)
return active_json
def get_iwinfo(self, idx=0, print_log=True, attach_allure=True):

View File

@@ -290,7 +290,7 @@ class tip_2x:
logging.info("uuid_after_apply: " + str(uuid_after_apply))
self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=True)
pytest.fail("Config sent from Gateway is not received by AP")
self.dut_library_object.get_latest_config_recieved(idx=i, print_log=True, attach_allure=True)
self.dut_library_object.get_latest_config_recieved(idx=i, print_log=True, attach_allure=False)
r_data = self.dut_library_object.ubus_call_ucentral_status(idx=i, print_log=False, attach_allure=False)
latest_uuid = r_data["latest"]
@@ -314,7 +314,7 @@ class tip_2x:
logging.info("uuid_after_apply: " + str(uuid_after_apply))
self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=True)
pytest.fail("Config sent from Gateway is Received by AP, But not Applied by AP")
self.dut_library_object.get_active_config(idx=i, print_log=True, attach_allure=True)
self.dut_library_object.get_active_config(idx=i, print_log=True, attach_allure=False)
logging.info("Config is Properly Applied on AP, Waiting for 30 Seconds for All interfaces to come up")
# wait time interfaces to come up
@@ -547,7 +547,7 @@ class tip_2x:
self.dut_library_object.setup_serial_environment(idx=idx)
self.dut_library_object.verify_certificates(idx=idx)
ret_val = self.dut_library_object.ubus_call_ucentral_status(idx=idx, attach_allure=False)
wifi_status = self.dut_library_object.get_wifi_status(idx=idx, attach_allure=True)
wifi_status = self.dut_library_object.get_wifi_status(idx=idx, attach_allure=False)
allure.attach(name="wifi_status_before_apply: ", body=str(wifi_status))
if not ret_val["connected"] or ret_val["connected"] is None:
# TODO: check the connectivity (if it is not connected, then check the lanforge wan port and bring it