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

[platform] Implement platform phase 1 cases #915

Merged
merged 4 commits into from
Jun 23, 2019
Merged

[platform] Implement platform phase 1 cases #915

merged 4 commits into from
Jun 23, 2019

Conversation

wangxin
Copy link
Collaborator

@wangxin wangxin commented May 16, 2019

Description of PR

Summary:
Fixes # (issue)

Implement the SONiC platform phase 1 test cases using the pytest-ansible framework.

The SONiC platform test cases are documented here:
https://github.com/Azure/SONiC/blob/master/doc/pmon/sonic_platform_test_plan.md

Test cases implemented in phase 1:

Test Case Script Common for all vendors?
Case 1.1 Check platform information tests/platform/test_platform_info.py Yes
Case 1.3 Check SFP status and configure SFP tests/platform/test_sfp.py Yes
Case 1.4 Check xcvrd information in DB tests/platform/test_xcvr_info_in_db.py Yes
Case 2.1 Ensure that the hw-management service is running properly tests/platform/mellanox/test_hw_management_service.py No
Case 2.2 Check SFP using ethtool tests/platform/mellanox/test_check_sfp_using_ethtool.py No
Case 2.3 Check SYSFS tests/platform/mellanox/test_check_sysfs.py No
Case 2.4 Verify that /var/run/hw-management is mapped to docker pmon tests/platform/mellanox/check_sysfs.py No

Please note that only the scripts for common test cases were included in this PR.

root@75978c06de6f:~/code/sonic-mgmt/tests# py.test --inventory ../ansible/inventory --host-pattern mtbc-sonic-03-2700 --module-path ../ansible/library/ --testbed mtbc-sonic-03-2700-t1 --testbed_file ../ansible/testbed.csv platform/test_* -ra -vvvvv
========================================================================================================= test session starts ==========================================================================================================platform linux2 -- Python 2.7.12, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python
cachedir: .pytest_cache
ansible: 2.0.0.2
rootdir: /root/code/sonic-mgmt/tests, inifile: setup.cfg
plugins: ansible-2.0.2
collected 6 items                                                                                                                                                                                                                      

platform/test_platform_info.py::test_show_platform_summary PASSED                                                                                                                                                                [ 16%]
platform/test_platform_info.py::test_show_platform_psustatus PASSED                                                                                                                                                              [ 33%]
platform/test_platform_info.py::test_turn_on_off_psu_and_check_psustatus PASSED                                                                                                                                                  [ 50%]
platform/test_platform_info.py::test_show_platform_syseeprom PASSED                                                                                                                                                              [ 66%]
platform/test_sfp.py::test_check_sfp_status_and_configure_sfp PASSED                                                                                                                                                             [ 83%]
platform/test_xcvr_info_in_db.py::test_xcvr_info_in_db PASSED                                                                                                                                                                    [100%]

=========================================================================================================== warnings summary ===========================================================================================================platform/test_platform_info.py::test_turn_on_off_psu_and_check_psustatus
  /usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py:129: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
    algorithm=hashes.SHA1(),

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================================================================ 6 passed, 1 warnings in 337.47 seconds ================================================================================================

Type of change

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

Approach

How did you do it?

Implement the SONiC platform phase 1 test cases using the pytest-ansible framework and follow the design of PR #802

How did you verify/test it?

Tested on the mellanox platform

Any platform specific information?

This PR does not include platform specific test cases.

Supported testbed topology if it's a new test case?

All current test topologies are supported:
[t0, t0-16, t0-56, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64]

Documentation

The SONiC platform test plan:
https://github.com/Azure/SONiC/blob/master/doc/pmon/sonic_platform_test_plan.md

@wangxin
Copy link
Collaborator Author

wangxin commented May 20, 2019

@jleveque Could you please help review this PR?

Changes:
* Add mellanox_psu_controller.py which has Mellanox implementation of PSU controller.
* Increase the delay between reset SFP and checking SFP presence for SFP to be fully recovered.
* Improve the checking of PSU status.
* Correct spelling errors.

Signed-off-by: Xin Wang <[email protected]>
@wangxin
Copy link
Collaborator Author

wangxin commented May 28, 2019

@jleveque Any more comments or concerns?

@lguohan lguohan requested a review from neethajohn May 28, 2019 16:59
Copy link
Contributor

@neethajohn neethajohn left a comment

Choose a reason for hiding this comment

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

Looks good to me

hostname = testbed['dut']
ans_host = ansible_host(ansible_adhoc, hostname)

logging.info("Check output of 'show platform summary'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general I suggest that commands name as well as expected error/OK message will be defined once (as a constant) and will be used by both log info as well as he command / message to use.
it is simpler in term changes might be introduced later on and code change will be done only once

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, updated in the new commit.

return res


def test_check_sfp_status_and_configure_sfp(localhost, ansible_adhoc, testbed):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If i am not mistaken we also have low power mode option under sfputil. Should we add it as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. Added SFP low power mode testing in the new commit.

* Replace inline command strings with predefined variables
* Add test case for testing SFP low power mode

Signed-off-by: Xin Wang <[email protected]>
@wangxin
Copy link
Collaborator Author

wangxin commented Jun 14, 2019

@lguohan @liat-grozovik Any more comments?

The order of information output by command "show platform syseeprom"
is not guranteed. This commit improve the method of comparing the
content output by syseeprom plugin and the show command to avoid
the failure caused by inconsistent output order.

Signed-off-by: Xin Wang <[email protected]>
@wangxin
Copy link
Collaborator Author

wangxin commented Jun 22, 2019

Added a new commit fixing an issue of comparing syseeprom output from "show platform syseeprom" and platform plugin.

@liat-grozovik liat-grozovik merged commit 8eb8f22 into sonic-net:master Jun 23, 2019
@wangxin wangxin deleted the platform-pytest-pr branch September 26, 2019 12:36
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