sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

Add inject namespace for test case.

Open xincunli-sonic opened this issue 1 year ago • 37 comments
trafficstars

Description of PR

Summary: Fixes # (issue)

Type of change

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

Back port request

  • [ ] 202012
  • [ ] 202205
  • [ ] 202305
  • [ ] 202311
  • [x] 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 avatar Aug 13 '24 19:08 xincunli-sonic

/azpw run

xincunli-sonic avatar Aug 15 '24 17:08 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Aug 15 '24 17:08 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Aug 15 '24 17:08 azure-pipelines[bot]

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 = dfe437989a7563fea09d34d4cf9072296a53d03e, deletion_comment = False)

qiluo-msft avatar Aug 28 '24 00:08 qiluo-msft

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 = dfe437989a7563fea09d34d4cf9072296a53d03e, deletion_comment = False)

xincunli-sonic avatar Aug 28 '24 05:08 xincunli-sonic

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>

mssonicbld avatar Sep 10 '24 16:09 mssonicbld

/azpw run

xincunli-sonic avatar Sep 11 '24 00:09 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Sep 11 '24 00:09 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Sep 11 '24 00:09 azure-pipelines[bot]

/azpw run

xincunli-sonic avatar Sep 12 '24 17:09 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Sep 12 '24 17:09 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Sep 12 '24 17:09 azure-pipelines[bot]

Please resolve conflict.

qiluo-msft avatar Sep 16 '24 20:09 qiluo-msft

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 = dfe437989a7563fea09d34d4cf9072296a53d03e, deletion_comment = False)

qiluo-msft avatar Sep 16 '24 20:09 qiluo-msft

/AzurePipelines run

xincunli-sonic avatar Oct 17 '24 16:10 xincunli-sonic

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

azure-pipelines[bot] avatar Oct 17 '24 16:10 azure-pipelines[bot]

/azpw run

xincunli-sonic avatar Oct 17 '24 16:10 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Oct 17 '24 16:10 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Oct 17 '24 16:10 azure-pipelines[bot]

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>

mssonicbld avatar Oct 17 '24 16:10 mssonicbld

/azpw run

xincunli-sonic avatar Oct 17 '24 16:10 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Oct 17 '24 16:10 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Oct 17 '24 16:10 azure-pipelines[bot]

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

mssonicbld avatar Oct 17 '24 16:10 mssonicbld

/azpw run

xincunli-sonic avatar Oct 17 '24 17:10 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Oct 17 '24 17:10 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Oct 17 '24 17:10 azure-pipelines[bot]

/azpw run

xincunli-sonic avatar Oct 18 '24 00:10 xincunli-sonic

/AzurePipelines run

mssonicbld avatar Oct 18 '24 00:10 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Oct 18 '24 00:10 azure-pipelines[bot]