Skip to content

Commit

Permalink
Always run postboot_setup in runRebootTest (sonic-net#14347)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
In event of an exception in runRebootTest, postboot_setup may not run.

How did you do it?
Move the call to the finally block to ensure it is always run.

How did you verify/test it?
Verified running test_upgrade_path on Arista device.
  • Loading branch information
andywongarista authored Oct 1, 2024
1 parent c49a013 commit 691d790
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,14 @@ def runRebootTest(self):
if self.duthost.num_asics() == 1 and not check_bgp_router_id(self.duthost, self.mgFacts):
test_results[test_case_name].append("Failed to verify BGP router identifier is Loopback0 on %s" %
self.duthost.hostname)
if self.postboot_setup:
self.postboot_setup()
except Exception:
traceback_msg = traceback.format_exc()
err_msg = "Exception caught while running advanced-reboot test on ptf: \n{}".format(traceback_msg)
logger.error(err_msg)
test_results[test_case_name].append(err_msg)
finally:
if self.postboot_setup:
self.postboot_setup()
# capture the test logs, and print all of them in case of failure, or a summary in case of success
log_dir = self.__fetchTestLogs(rebootOper)
self.print_test_logs_summary(log_dir)
Expand Down

0 comments on commit 691d790

Please sign in to comment.