Skip to content

[copp tables] validate copp tables during in/cross-branch upgrades#8446

Merged
liat-grozovik merged 1 commit intosonic-net:masterfrom
AntonHryshchuk:upgrade_copp_test
Jul 14, 2023
Merged

[copp tables] validate copp tables during in/cross-branch upgrades#8446
liat-grozovik merged 1 commit intosonic-net:masterfrom
AntonHryshchuk:upgrade_copp_test

Conversation

@AntonHryshchuk
Copy link
Contributor

Description of PR

Summary: Update the test test_upgrade_path.py to support validation of the copp tables after in/cross-branch upgrades.
Added validation after upgrade, to compare copp tables with copp_cfg.json file.
Fixes #8085

Type of change

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

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

Add validation of copp tables after improvement of fast-reboot

How did you do it?

Added validation of copp tables after upgrade

How did you verify/test it?

executed test test_upgrade_path with base_image=201911, target_image=202205, upgrade_type=fast

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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/upgrade_path/upgrade_helpers.py:154:22: W605 invalid escape sequence 's'

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
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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/upgrade_path/upgrade_helpers.py:154:22: W605 invalid escape sequence 's'

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>

Copy link
Contributor

@arfeigin arfeigin left a comment

Choose a reason for hiding this comment

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

LGTM

@arfeigin arfeigin requested a review from vaibhavhd May 30, 2023 13:27
@arfeigin
Copy link
Contributor

Hi @vaibhavhd , please review the test changes.

@liat-grozovik
Copy link
Collaborator

@vaibhavhd would you like to review and provide your feedback?

@liat-grozovik
Copy link
Collaborator

@vaibhavhd kindly reminder to review.

def check_copp_config(duthost):
logging.info("Comparing CoPP configuration from copp_cfg.json to COPP_TABLE")
copp_tables = json.loads(duthost.shell("sonic-db-dump -n APPL_DB -k COPP_TABLE* -y")["stdout"])
copp_cfg = json.loads(duthost.shell("cat /etc/sonic/copp_cfg.json")["stdout"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a check for existence of config prior to this step?

copp_cfg_formatted = get_copp_cfg_formatted_dict(copp_cfg, feature_status)
pytest_assert(copp_tables_formatted == copp_cfg_formatted,
"There is a difference between CoPP config and CoPP tables. CoPP config: {}\nCoPP tables:"
" {}".format(copp_tables_formatted, copp_cfg_formatted))
Copy link
Contributor

Choose a reason for hiding this comment

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

The print sequence is reverted.

Copy link
Contributor

@vaibhavhd vaibhavhd left a comment

Choose a reason for hiding this comment

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

Non blocking comments added

@mssonicbld
Copy link
Collaborator

@AntonHryshchuk PR conflicts with 202205 branch

AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
…onic-net#8446)

- What is the motivation for this PR?
Add validation of copp tables after improvement of fast-reboot

- How did you do it?
Added validation of copp tables after upgrade

- How did you verify/test it?
executed test test_upgrade_path with base_image=201911, target_image=202205, upgrade_type=fast
Signed-off-by: AntonHryshchuk <[email protected]>
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.

[testgap] validate preserving copp tables work during in/cross-branch upgrades

6 participants