Skip to content

fixed py3 QoS Watermark tests#6742

Closed
antonptashnik wants to merge 1 commit intosonic-net:masterfrom
antonptashnik:fix-py3-qos-tests
Closed

fixed py3 QoS Watermark tests#6742
antonptashnik wants to merge 1 commit intosonic-net:masterfrom
antonptashnik:fix-py3-qos-tests

Conversation

@antonptashnik
Copy link
Contributor

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:

"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?

Documentation

@azure-pipelines
Copy link

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:

  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>

@antonptashnik
Copy link
Contributor Author

closing as the issue is addressed by #6786

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.

1 participant