Skip to content
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

Merged
merged 6 commits into from
Sep 20, 2019
Merged

[tests/platform/test_reboot.py] add testcases for reboot cause #1079

merged 6 commits into from
Sep 20, 2019

Conversation

stephenxs
Copy link
Contributor

@stephenxs stephenxs commented Aug 23, 2019

Description of PR

Summary:
add testcases for reboot cause

Type of change

  • [] Bug fix
  • [] Testbed and Framework(new/improvement)
  • Test case(improvement)

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

@stephenxs stephenxs marked this pull request as ready for review August 26, 2019 05:50
tests/platform/test_reboot.py Outdated Show resolved Hide resolved
tests/platform/test_reboot.py Outdated Show resolved Hide resolved
tests/platform/test_reboot.py Show resolved Hide resolved
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):
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


reboot_ctrl_element = reboot_ctrl_dict.get(reboot_type)
if reboot_ctrl_element is None:
assert False, "Unknown reboot type %s" % reboot_type
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

assert False, "Unknown reboot type %s" % reboot_type

reboot_timeout = reboot_ctrl_element[REBOOT_TIMEOUT]
reboot_cause = reboot_ctrl_element[REBOOT_CAUSE]
Copy link
Collaborator

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"]

Copy link
Contributor Author

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 Show resolved Hide resolved
process.terminate()
logging.error("reboot result %s" % str(queue.get()))
assert False, "DUT did not go down"
reboot_cmd = reboot_ctrl_element[REBOOT_COMMAND]
Copy link
Collaborator

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"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return request.param


def _power_off_reboot_helper(args):
Copy link
Collaborator

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.


delay_time_list = [15, 5]
poweroff_reboot_argu = {}
poweroff_reboot_argu["dut"] = ans_host
Copy link
Collaborator

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.

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()\""
Copy link
Collaborator

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.

watchdog_reboot_argu = {}
watchdog_reboot_argu["dut"] = ans_host
watchdog_reboot_argu["cause"] = "Watchdog"
watchdog_reboot_argu["command"] = watchdog_reboot_command
Copy link
Collaborator

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?

Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve confilcts.

@stephenxs
Copy link
Contributor Author

stephenxs commented Sep 20, 2019 via email

@jleveque jleveque merged commit a3f2458 into sonic-net:master Sep 20, 2019
@stephenxs stephenxs deleted the pr2-reboot-cause branch September 25, 2019 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants