Skip to content

Add scope into JSON patch of existing GCU testcases for Multi ASIC.#14098

Merged
qiluo-msft merged 11 commits intosonic-net:masterfrom
xincunli-sonic:xincun/fix-multiasic-gcu-test
Nov 14, 2024
Merged

Add scope into JSON patch of existing GCU testcases for Multi ASIC.#14098
qiluo-msft merged 11 commits intosonic-net:masterfrom
xincunli-sonic:xincun/fix-multiasic-gcu-test

Conversation

@xincunli-sonic
Copy link
Contributor

@xincunli-sonic xincunli-sonic commented Aug 13, 2024

Description of PR

Summary:
Improve existing GCU test cases for multi asic.

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?

In multi asic, by default, there is no namespace when we do replace or remove operation, which will fail due to the path is incomplete.

How did you do it?

When testcase is running, the apply-patch wrapper in test code will inject the localhost namespace into payload.

How did you verify/test it?

Any platform specific information?

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

Documentation

@xincunli-sonic
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@wen587 wen587 left a comment

Choose a reason for hiding this comment

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

lgtm

@qiluo-msft
Copy link
Contributor

def apply_patch(duthost, json_data, dest_file):

why not just fix json_data directly? keep the code here generic.


Refers to: tests/generic_config_updater/gu_utils.py:37 in dfe4379. [](commit_id = dfe4379, deletion_comment = False)

@xincunli-sonic
Copy link
Contributor Author

def apply_patch(duthost, json_data, dest_file):

IIUC, both way will be working in this test path, but fix json data may cause many current and future efforts, in this wrapper's change, the caller will not need care it is multiasic or not when preparing data.


In reply to: 2313842978


Refers to: tests/generic_config_updater/gu_utils.py:37 in dfe4379. [](commit_id = dfe4379, deletion_comment = False)

@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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/generic_config_updater/gu_utils.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped

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>

@xincunli-sonic
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xincunli-sonic
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft
Copy link
Contributor

Please resolve conflict.

@qiluo-msft
Copy link
Contributor

def apply_patch(duthost, json_data, dest_file):

Offline discussed, suggest change each test file. The abstraction level at JsonPatch is not proper.


In reply to: 2314344959


Refers to: tests/generic_config_updater/gu_utils.py:37 in dfe4379. [](commit_id = dfe4379, deletion_comment = False)

@xincunli-sonic
Copy link
Contributor Author

/AzurePipelines run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 14098 in repo sonic-net/sonic-mgmt

@xincunli-sonic
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/gu_utils.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/gu_utils.py:25:1: E302 expected 2 blank lines, found 1

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

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>

@xincunli-sonic
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xincunli-sonic xincunli-sonic changed the title Add inject namespace for test case. Add scope into JSON patch of existing GCU testcases for Multi ASIC. Nov 14, 2024
@qiluo-msft qiluo-msft merged commit 0c934e3 into sonic-net:master Nov 14, 2024
sreejithsreekumaran pushed a commit to sreejithsreekumaran/sonic-mgmt that referenced this pull request Nov 15, 2024
…onic-net#14098)

### Description of PR

Summary:
Improve existing GCU test cases for multi asic.


### Approach
#### What is the motivation for this PR?

In multi asic, by default, there is no namespace when we do replace or remove operation, which will fail due to the path is incomplete.

#### How did you do it?

When testcase is running, the apply-patch wrapper in test code will inject the localhost namespace into payload.
yutongzhang-microsoft pushed a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Nov 21, 2024
…onic-net#14098)

### Description of PR

Summary:
Improve existing GCU test cases for multi asic.


### Approach
#### What is the motivation for this PR?

In multi asic, by default, there is no namespace when we do replace or remove operation, which will fail due to the path is incomplete.

#### How did you do it?

When testcase is running, the apply-patch wrapper in test code will inject the localhost namespace into payload.
qiluo-msft pushed a commit that referenced this pull request Jan 27, 2025
…16065)

Description of PR
For GCU test suites, configuration changes applied via patches sometimes target a specific ASIC namespace or apply globally to the card (localhost), depending on the feature functionality.

With the recent merged PR #14098, configuration changes are now applied to both localhost and all ASIC namespaces for all multi-ASIC platforms by default, which is incorrect.

Examples:

Configuration paths like /BGP_NEIGHBOR/ should apply only to the ASIC namespace.
Paths like /SYSLOG_SERVER/ should apply only to the localhost namespace.
This PR addresses the issue by introducing a missing flag for "asic_specific" configurations. It adapts the calls appropriately in each test suite based on the targeted configuration scope (ASIC namespace or localhost).

Approach
How did you verify/test it?
Ran vs-kvm tests.

Attaching sample results for test_portchannel.py and test_eth_interface.py:
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
…onic-net#16065)

Description of PR
For GCU test suites, configuration changes applied via patches sometimes target a specific ASIC namespace or apply globally to the card (localhost), depending on the feature functionality.

With the recent merged PR sonic-net#14098, configuration changes are now applied to both localhost and all ASIC namespaces for all multi-ASIC platforms by default, which is incorrect.

Examples:

Configuration paths like /BGP_NEIGHBOR/ should apply only to the ASIC namespace.
Paths like /SYSLOG_SERVER/ should apply only to the localhost namespace.
This PR addresses the issue by introducing a missing flag for "asic_specific" configurations. It adapts the calls appropriately in each test suite based on the targeted configuration scope (ASIC namespace or localhost).

Approach
How did you verify/test it?
Ran vs-kvm tests.

Attaching sample results for test_portchannel.py and test_eth_interface.py:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants