-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests/platform/test_reboot.py] add testcases for reboot cause #1079
Conversation
tests/platform/test_reboot.py
Outdated
assert m is not None, "got reboot-cause %s after rebooted by %s" % (reboot_cause_got, reboot_cause_expected) | ||
|
||
|
||
def reboot_and_check(localhost, dut, interfaces, reboot_type="cold", reboot_helper=None, reboot_argu=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Parameter passing should use pre-defined constant:
reboot_type=REBOOT_TYPE_COLD
- Suggest to use a better name
reboot_kwargs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/platform/test_reboot.py
Outdated
|
||
reboot_ctrl_element = reboot_ctrl_dict.get(reboot_type) | ||
if reboot_ctrl_element is None: | ||
assert False, "Unknown reboot type %s" % reboot_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above 3 lines of code can be simplified in a more pythonic way:
assert reboot_type in REBOOT_TYPES.keys(), "Unknown reboot type %s" % reboot_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/platform/test_reboot.py
Outdated
assert False, "Unknown reboot type %s" % reboot_type | ||
|
||
reboot_timeout = reboot_ctrl_element[REBOOT_TIMEOUT] | ||
reboot_cause = reboot_ctrl_element[REBOOT_CAUSE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use a simplified REBOOT_TYPES dict, then the above two lines should be like below:
reboot_timeout = REBOOT_TYPES[reboot_type]["timeout"]
reboot_cause = REBOOT_TYPES[reboot_type]["cause"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/platform/test_reboot.py
Outdated
process.terminate() | ||
logging.error("reboot result %s" % str(queue.get())) | ||
assert False, "DUT did not go down" | ||
reboot_cmd = reboot_ctrl_element[REBOOT_COMMAND] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reboot_cmd = REBOOT_TYPES[reboot_type]["command"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/platform/test_reboot.py
Outdated
return request.param | ||
|
||
|
||
def _power_off_reboot_helper(args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function expects a dictionary argument, it usually a better practice to name the argument like kwargs
.
tests/platform/test_reboot.py
Outdated
|
||
delay_time_list = [15, 5] | ||
poweroff_reboot_argu = {} | ||
poweroff_reboot_argu["dut"] = ans_host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to use a better variable name poweroff_reboot_kwargs
.
tests/platform/test_reboot.py
Outdated
ans_host = testbed_devices["dut"] | ||
localhost = testbed_devices["localhost"] | ||
|
||
watchdog_reboot_command = "python -c \"import sonic_platform.platform as P; P.Platform().get_chassis().get_watchdog().arm(5); exit()\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This watchdog_reboot_command
variable is unnecessary here. It's already in the REBOOT_TYPES dict.
tests/platform/test_reboot.py
Outdated
watchdog_reboot_argu = {} | ||
watchdog_reboot_argu["dut"] = ans_host | ||
watchdog_reboot_argu["cause"] = "Watchdog" | ||
watchdog_reboot_argu["command"] = watchdog_reboot_command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This watchdog_reboot_argu
variable is not used. Why define it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve confilcts.
Fixed.
|
Description of PR
Summary:
add testcases for reboot cause
Type of change
Approach
How did you do it?
How did you do it?
add hardware reboot testcases to reboot test
add reboot-cause checking after each reboot.
How did you verify/test it?
run test on every testbed
Any platform specific information?
Supported testbed topology if it's a new test case?
all topo
Documentation
[sonic_platform_test_plan.md]add reboot cause test #451