Skip to content

Commit

Permalink
Added pretty print in the reboot logs and device statistics (#1006)
Browse files Browse the repository at this point in the history
* Added Pretty-Print allure attachment for device statistics and reboot logs

Signed-off-by: jitendracandela <[email protected]>

* Added return code in pytest exit

Signed-off-by: jitendracandela <[email protected]>

* Modified pytest exit msg for the crash

Signed-off-by: jitendracandela <[email protected]>

* Added try and except for crash logs logic

Signed-off-by: jitendracandela <[email protected]>

* Modified pytest exit code

Signed-off-by: jitendracandela <[email protected]>

* Removed return code from pytest exit

Signed-off-by: jitendracandela <[email protected]>

---------

Signed-off-by: jitendracandela <[email protected]>
  • Loading branch information
jitendracandela authored and anil-tegala committed Dec 3, 2024
1 parent 781a395 commit 82dbb0b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,22 +521,25 @@ def collect_logs():
query_ = f"?startDate={start_time}&endDate={end_time}"
resp = get_target_object.controller_library_object.get_device_statistics_teardown(device_name, query=query_)
if resp.status_code == 200:
allure.attach(body=str(resp.json()), name="device_statistics_per_test_case")
allure.attach(body=json.dumps(resp.json(), indent=4), name="device_statistics_per_test_case\n",
attachment_type=allure.attachment_type.JSON)
else:
logging.info("resp.status_code:- " + str(resp.status_code))
# Check reboot logs
query_ = f"?logType=2&startDate={start_time}&endDate={end_time}"
resp = get_target_object.controller_library_object.get_device_reboot_logs(device_name, query=query_)
if resp.status_code == 200:
allure.attach(body=str(resp.json()), name="device_reboot_logs_per_test_case")
allure.attach(body=json.dumps(resp.json(), indent=4), name="device_reboot_logs_per_test_case\n",
attachment_type=allure.attachment_type.JSON)
response = resp.json()
# crash log validation
if response["values"]:
resp = get_target_object.controller_library_object.get_device_reboot_logs(device_name,
query="?logType=2")
allure.attach(body=str(resp.json()), name="all_device_reboot_logs")
logging.info("Reboot detected on AP side")
pytest.exit("Reboot detected on AP side")
allure.attach(body=json.dumps(resp.json(), indent=4), name="all_device_reboot_logs\n",
attachment_type=allure.attachment_type.JSON)
logging.info("AP crashed during the test")
pytest.exit("AP crashed during the test")
else:
logging.info("resp.status_code:- " + str(resp.status_code))

Expand Down

0 comments on commit 82dbb0b

Please sign in to comment.