Skip to content

GCU adding Multi-ASIC support in existing test code base#14070

Closed
okaravasi wants to merge 8 commits intosonic-net:masterfrom
okaravasi:master-gcu_t2_support
Closed

GCU adding Multi-ASIC support in existing test code base#14070
okaravasi wants to merge 8 commits intosonic-net:masterfrom
okaravasi:master-gcu_t2_support

Conversation

@okaravasi
Copy link
Contributor

@okaravasi okaravasi commented Aug 10, 2024

Description of PR

Summary:

This PR adds Multi-ASIC support for generic config updater (GCU) existing suites.

Fixes # (issue)

Type of change

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

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

Approach

What is the motivation for this PR?

To add Multi-ASIC test support for GCU suites.

How did you do it?

DUT Host Selection
With T2 topology support added, the fixture used for DUT host selection has been updated. Some test suites are designed to run on any type of DUT host, while others are specific to frontend DUT hosts.

To accommodate this:

The following fixture replacements were made where frontend DUT hosts are required:

  • rand_selected_dut → rand_selected_front_end_dut
  • rand_one_dut_hostname → rand_one_dut_front_end_hostname
    Suite autouse fixtures were also updated to work transparently for both frontend-only and general DUT host suites. A new fixture , anmed "selected_dut_hostname", was created for use across setup/teardown fixtures:
@pytest.fixture(scope="module")
def selected_dut_hostname(request, rand_one_dut_hostname):
    """Fixture that returns either `rand_one_dut_hostname` or `rand_one_dut_front_end_hostname`
    depending on availability."""
    if "rand_one_dut_front_end_hostname" in request.fixturenames:
        logger.info("Running on frontend DUT host")
        return request.getfixturevalue("rand_one_dut_front_end_hostname")
    else:
        logger.info("Running on any type of DUT host")
        return rand_one_dut_hostname

Random Selection of ASIC Namespace
For multi-ASIC platform testing, new fixtures were created to select an ASIC randomly from the DUT host’s available namespaces, returning a tuple with the ASIC namespace and ID:

  • rand_asic_namespace
  • rand_front_end_asic_namespace

Test Case Updates
In each suite, support was added as follows:

  1. Namespace Variable Addition:
  • A JSON namespace variable is added to all paths at the beginning, constructed based on the return value of rand_asic_namespace or rand_front_end_asic_namespace.
  • For single-ASIC platforms, this variable is empty.
  • For multi-ASIC platforms, the variable might be /localhost, /asic0, etc.
  1. Path Changes:
  • For configuration changes specific to an ASIC, json_namespace is:
    • Empty ('') for single-ASIC platforms.
    • '/asicX' (e.g., /asic0) for multi-ASIC platforms.
  • For global (non-ASIC-specific) configuration changes, json_namespace is:
    • Empty ('') for single-ASIC platforms.
    • '/localhost' for multi-ASIC platforms.
      These changes ensure no modifications are needed for existing single-ASIC platform tests.
  1. Command Enhancements:
  • sonic-db-cli and CLI commands were enhanced with a namespace_prefix where applicable.
  • For ASIC-specific CLI commands, namespace_prefix is:
    • Empty ('') for single-ASIC platforms.
    • '-n asicX' (e.g., -n asic0) for multi-ASIC platforms.
  • For global (non-ASIC-specific) CLI commands, namespace_prefix is always empty.

How did you verify/test it?

Ran the full test scope of the updated suites and verified that they pass.
Ran on vs-kvm-t0. Ran on physical device t2.

Any platform specific information?

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

Documentation

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/generic_config_updater/test_lo_interface.py:82:121: E501 line too long (167 > 120 characters)

flake8...............................................(no files to check)Skipped
check conditional mark sort..............................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/gu_utils.py:42:18: E225 missing whitespace around operator

flake8...............................................(no files to check)Skipped
check conditional mark sort..............................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@arlakshm
Copy link
Contributor

arlakshm commented Oct 8, 2024

@okaravasi Thanks for the making this change. The PR is too big, it is modifying multiple tests. Can you please breakdown the changes in multiple smaller PR( maybe 1 PR per test). This will help in review and the changes can be merged faster

@okaravasi
Copy link
Contributor Author

okaravasi commented Oct 10, 2024

@okaravasi Thanks for the making this change. The PR is too big, it is modifying multiple tests. Can you please breakdown the changes in multiple smaller PR( maybe 1 PR per test). This will help in review and the changes can be merged faster

@arlakshm Sure, I am on it. I will keep the common changes under this PR and create separate PRs for each test suite. I will link the PRs when done. Thanks.

@okaravasi
Copy link
Contributor Author

This PR has been splitted to separate Test PRs. Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants