You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
QoS SAI tests were recently migrated to Python 3. Tests have several math expressions to calculate the number of packets to send. Watermark tests worked on py2 but started to fail on py3 with the output below:
"Traceback (most recent call last):",
E " File \"saitests/py3/sai_qos_tests.py\", line 2968, in runTest",
E " pkts_inc=(total_shared / cell_occupancy) >> 2",
E "TypeError: unsupported operand type(s) for >>: 'float' and 'int'"
The reason is different behavior for operator "/" in py2 and py3, refer for more info here, section 3. In py3 it produces float result for int division that's not expected causing test interruption. Fixed
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?
Recover QoS Watermark tests after migration to Python 3
How did you do it?
Modified the test code to work as it worked for Python 2
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.
For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!
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/saitests/py3/sai_qos_tests.py:8:1: F401 'ptf.dataplane' imported but unused tests/saitests/py3/sai_qos_tests.py:21:1: F401 'switch.sai_port_list' imported but unused tests/saitests/py3/sai_qos_tests.py:38:1: F401 'switch_sai_thrift.sai_headers.SAI_PORT_ATTR_PKT_TX_ENABLE' imported but unused tests/saitests/py3/sai_qos_tests.py:208:10: E114 indentation is not a multiple of 4 (comment) tests/saitests/py3/sai_qos_tests.py:208:10: E117 over-indented (comment) tests/saitests/py3/sai_qos_tests.py:318:41: E127 continuation line over-indented for visual indent tests/saitests/py3/sai_qos_tests.py:319:41: E127 continuation line over-indented for visual indent tests/saitests/py3/sai_qos_tests.py:320:41: E127 continuation line over-indented for visual indent tests/saitests/py3/sai_qos_tests.py:321:41: E127 continuation line over-indented for visual indent tests/saitests/py3/sai_qos_tests.py:322:41: E127 continuation line over-indented for visual indent tests/saitests/py3/sai_qos_tests.py:323:41: E127 continuation line over-indented for visual indent ... [truncated extra lines, please run pre-commit locally to view full check results]
To run the pre-commit checks locally, you can follow below steps:
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.
Ensure that the pre-commit package is installed:
sudo pip install pre-commit
Go to repository root folder
Install the pre-commit hooks:
pre-commit install
Use pre-commit to check staged file:
pre-commit
Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary: fixed py3 QoS Watermark tests
Fixes # (issue)
QoS SAI tests were recently migrated to Python 3. Tests have several math expressions to calculate the number of packets to send. Watermark tests worked on py2 but started to fail on py3 with the output below:
The reason is different behavior for operator "/" in py2 and py3, refer for more info here, section 3. In py3 it produces
floatresult for int division that's not expected causing test interruption. FixedType of change
Back port request
Approach
What is the motivation for this PR?
Recover QoS Watermark tests after migration to Python 3
How did you do it?
Modified the test code to work as it worked for Python 2
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation