Skip to content

Converting legacy platform tests for a T2 chassis, adding validation of values to tests, and refactor test_sfp into smaller tests#2965

Merged
yxieca merged 8 commits intosonic-net:masterfrom
sanmalho-git:platform
Feb 26, 2021
Merged

Converting legacy platform tests for a T2 chassis, adding validation of values to tests, and refactor test_sfp into smaller tests#2965
yxieca merged 8 commits intosonic-net:masterfrom
sanmalho-git:platform

Conversation

@sanmalho-git
Copy link
Copy Markdown
Contributor

@sanmalho-git sanmalho-git commented Feb 9, 2021

Description of PR

Summary:
Fixes # (issue)

Type of change

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

Approach

What is the motivation for this PR?

Need to run the legacy platform tests against a T2 chassis. However, some of the tests would run only on supervisor card, while others would run only on frontend nodes (linecards).

So, need to convert these tests to use the enum_* fixtures for dut selection, rather than rand_one_dut_hostname.

Also, we need to add some validation of the commands based on some variables that are defined in the inventory file - similar to the new PMON API validation.

How did you do it?

The following modifications are made to some of the legacy platform tests:

  • conftest.py:

    • Some of the platform tests run only on a supervisor card for a chassis. So, needed to change rand_one_dut_hostname to enum_dut_supervisor_hostname. However, in a multi-dut testbed that has no supervisor card (like DualTor), we would raise an exception that no supervisor card is present. Instead, we will now just return the first dut in the testbed.
    • Modified generate_params_supervisor_hostname function for this behavior.
  • test_xcvr_info_in_db.py:

    • Use enum_rand_one_per_hwsku_frontend_hostname to run test against frontend node instead of rand_one_dut_hostname that could give us a supervisor card.
  • test_sfp:

    • Broke into 3 smaller test for the 3 modules being tested
      • sfpshow
      • sfputil
      • show interface transceiver
    • These tests were added as a directory 'sfp' under platform_tests
    • In these tests:
      • Use enum_rand_one_per_hwsku_frontend_hostname to run test against frontend node instead of rand_one_dut_hostname
      • Added validation of 'sfpshow presence' and 'sfpshow eeprom'.
  • test_show_platform.py:

    • Use enum_rand_one_per_hwsku_frontend_hostname to run tests against frontend node instead of rand_one_dut_hostname
    • test_show_platform_summary:
      • Added validation of fields in 'show platform summary' based on values in the inventory if defined.
        • hwsku - based on 'hwsku' variable in the inventory
        • platform - based on 'sonic_hw_platform' variable in the inventory
        • asic - based on 'asic_type' variable in the inventory
        • asic count - based on 'num_asics' variable in the inventory
    • test_show_syseeprom:
      • Validate values against 'syseeprom_info' dictionary if defined in the inventory
    • test_show_platform_psustatus:
      • Validate that atleast one of the PSU's shows status as OK.
    • test_show_platform_fan:
      • Validate that atleast one of the fans shows status as OK.

How did you verify/test it?

Validated the modified tests against a chassis and also a pizza box.

Any platform specific information?

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

Documentation

@sanmalho-git sanmalho-git requested review from a team and jleveque as code owners February 9, 2021 23:51
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Feb 10, 2021

This pull request introduces 2 alerts when merging 16e71b816b8d56f01dc0c05046bbeaa125829d73 into 451d052 - view on LGTM.com

new alerts:

  • 1 for Testing equality to None
  • 1 for Except block handles 'BaseException'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should expect the syseeprom_info field to be present in the inventory file to prevent skipping this test and potentially missing an issue. Maybe we should assert here and fail the test if not present?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was trying to keep it backward compatible. With your proposed change, it will enforce everybody to add syseeprom_info for all their devices into the inventory file. Is that what we want to do.

Copy link
Copy Markdown
Contributor

@jleveque jleveque Feb 12, 2021

Choose a reason for hiding this comment

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

Yes, that's what I'm inferring. In order to have a full, comprehensive test, syseeprom_info data should be added to the inventory file. I think the test should fail if there's nothing to test against. We are currently in the process of improving test coverage, so I think this assumption in fine moving forward. Thank you for considering backward compatibility here, but when it comes to testing, we need to set some ground rules.

Also, the platform API tests are designed to fail if the expected data is not found.

Copy link
Copy Markdown
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.

I think it might be best to split tests/platform_tests/test_sfp.py into two files:

  • tests/platform_tests/test_sfputil.py
  • tests/platform_tests/test_sfpshow.py

Thoughts?

@sanmalho-git
Copy link
Copy Markdown
Contributor Author

how about splitting each show command into its own test in the same test_sfp.py

@jleveque
Copy link
Copy Markdown
Contributor

how about splitting each show command into its own test in the same test_sfp.py

I think it makes things cleaner to have one file dedicated to testing one utility.

The show platform ... subcommands will be tested in test_show_platform.py, sfputil subcommands will be tested in test_sfputil.py and sfpshow commands will be tested in test_sfpshow. It will help isolate the tests and also keep the file sizes down.

…on of values to some tests

The following modifications are made to some of the legacy platform tests:
- conftest.py:
    - Some of the platform tests run only on a supervisor card for a chassis.
      So, needed to change rand_one_dut_hostname to enum_dut_supervisor_hostname.
      However, in a multi-dut testbed that has no supervisor card (like DualTor),
      we would raise an exception that no supervisor card is present. Instead,
      we will now just return the first dut in the testbed.
    - Modified generate_params_supervisor_hostname function for this behavior.
- test_xcvr_info_in_db.py:
    - Use enum_rand_one_per_hwsku_frontend_hostname to run test against frontend
      node instead of rand_one_dut_hostname that could give us a supervisor card.

- test_sfp:
    - Use enum_rand_one_per_hwsku_frontend_hostname to run test against frontend
      node instead of rand_one_dut_hostname
    - Some of the new platforms don't support sfputils. So, added a check based
      on the presence of file /usr/share/sonic/device/<platform>/plugins/spfutil.py"
      If the file is not present, then we assume that sfputils is not supported.
      In this case, we don't do sfputils related steps in test_check_sfp_status_and_configure_sfp test.
      and skip test_check_sfp_low_power_mode test.

- test_show_platform.py:
    - Use enum_rand_one_per_hwsku_frontend_hostname to run tests against frontend
      node instead of rand_one_dut_hostname
    - test_show_platform_summary:
       - Added validation of fields in 'show platform summary' based on values in the inventory if defined.
          - hwsku - based on 'hwsku' variable in the inventory
          - platform - based on 'sonic_hw_platform' variable in the inventory
          - asic - based on 'asic_type' variable in the inventory
          - asic count - based on 'num_asics' variable in the inventory
    - test_show_syseeprom:
       - Validate values against 'syseeprom_info' dictionary if defined in the inventory
    - test_show_platform_psustatus:
       - Validate that atleast one of the PSU's shows status as OK.
    - test_show_platform_fan:
       - Validate that atleast one of the fans shows status as OK.
test_sfp.py:
- removed check for spfutils not supported
test_show_platform.py:
- Removed extra spaces as per review comments
Broke up test_sfp into 3 tests for the 3 different modules being tested
- sfpshow - test_sfpshow.py
- sfputil - test_sfputil.py
- show interface transciever - test_show_intf_xvrc.py

The files were added into 'sfp' directory under platform tests to allow for reuse of utilities
and fixtures.

Removed original test_sfp.py from platform_tests directory.
@sanmalho-git sanmalho-git changed the title Converting legacy platform tests for a T2 chassis and adding validation of values to some tests Converting legacy platform tests for a T2 chassis, adding validation of values to tests, and refactor test_sfp into smaller tests Feb 18, 2021
@sanmalho-git
Copy link
Copy Markdown
Contributor Author

@jleveque Have refactored test_sfp into smaller tests under platform_tests/sfp. Please re-review.

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Feb 19, 2021

This pull request introduces 1 alert when merging b722eb6 into 856c106 - view on LGTM.com

new alerts:

  • 1 for Testing equality to None

Copy link
Copy Markdown
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 fix LGTM alert.

@sanmalho-git
Copy link
Copy Markdown
Contributor Author

Done

@yxieca yxieca merged commit cdf78e3 into sonic-net:master Feb 26, 2021
@sanmalho-git sanmalho-git deleted the platform branch April 28, 2021 17:43
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.

3 participants