Skip to content

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

Merged
jleveque merged 6 commits intosonic-net:masterfrom
stephenxs:pr2-reboot-cause
Sep 20, 2019
Merged

[tests/platform/test_reboot.py] add testcases for reboot cause#1079
jleveque merged 6 commits intosonic-net:masterfrom
stephenxs:pr2-reboot-cause

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

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
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
* [201811][swss][utilities] advance sub module head

Submodule src/sonic-swss fcd091c..9585be4:
  > [teamsyncd]: Check if LAG exists before removing (sonic-net#1069)
  > [mirrororch]: Toggle the mirror session when moving between VLAN/non-VLAN (sonic-net#1078)

Submodule src/sonic-utilities 7bb6ffb..2d721de:
  > [show] Properly replace port name with alias in command output (sonic-net#664)
  > [neighbor_advertiser] hand pick partial change from sonic-net#525 (sonic-net#689)
  > Revert "Revert "Fixed config Asym PFC CLI. (sonic-net#632)" (sonic-net#652)"

Signed-off-by: Ying Xie <[email protected]>

* address compile issue

Submodule src/sonic-swss 9585be4..2529d79:
  > [mirrororch]: Address compiler switch issue (sonic-net#1079)

Signed-off-by: Ying Xie <[email protected]>
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