Skip to content

Fix test execution on Bookworm#3041

Merged
yxieca merged 2 commits intosonic-net:bookwormfrom
saiarcot895:bookworm
Nov 17, 2023
Merged

Fix test execution on Bookworm#3041
yxieca merged 2 commits intosonic-net:bookwormfrom
saiarcot895:bookworm

Conversation

@saiarcot895
Copy link
Copy Markdown
Contributor

What I did

Running tests with python3 -m pytest instead of python setup.py test causes some breakages on Bookworm. Some of this has to do with what module searc paths get added, while others appear to be related to changes in the mock module between Python 3.9 and Python 3.11.

Fix this and make sure it works on both Bullseye and Bookworm.

How I did it

Fix mock.patch entries so that the correct object reference gets patched, and remove duplicate test functions in TestMuxcable.

How to verify it

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

Running tests with `python3 -m pytest` instead of `python setup.py test`
causes some breakages on Bookworm. Some of this has to do with what
module searc paths get added, while others appear to be related to
changes in the `mock` module between Python 3.9 and Python 3.11.

Fix this and make sure it works on both Bullseye and Bookworm.
@saiarcot895
Copy link
Copy Markdown
Contributor Author

saiarcot895 commented Nov 15, 2023

For tests/muxcable_test.py specifically: number of tests executed went from 96 to 97 (which is exepcted, as one test for JSON output had the same name as a different test case, test_show_muxcable_hwmode_muxdirection_port_active, and has been renamed in this PR so that it is executed).

The test_mclag_add_mclag_member_to_nonexisting_domain test case passes
when run on Bullseye, but fails on Bookworm. This is because some test
cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may
persist for other test cases as well, and if test cases happen to run in
a different order, then it may unexpectedly fail.

For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by
setting the value there.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@yxieca yxieca merged commit 7eb11c7 into sonic-net:bookworm Nov 17, 2023
saiarcot895 added a commit to saiarcot895/sonic-utilities that referenced this pull request Nov 19, 2023
* Fix test execution on Bookworm

Running tests with `python3 -m pytest` instead of `python setup.py test`
causes some breakages on Bookworm. Some of this has to do with what
module searc paths get added, while others appear to be related to
changes in the `mock` module between Python 3.9 and Python 3.11.

Fix this and make sure it works on both Bullseye and Bookworm.

* Fix mclag_test.py having different results for some test cases

The test_mclag_add_mclag_member_to_nonexisting_domain test case passes
when run on Bullseye, but fails on Bookworm. This is because some test
cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may
persist for other test cases as well, and if test cases happen to run in
a different order, then it may unexpectedly fail.

For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by
setting the value there.

* Add check_output parameter to the setup function due to the patch

Since there is a patched function specified as an attribute, newer
versions of mock expect that the object can be passed in as a parameter
to the function. However, the `setup` functions didn't accept it as a
parameter.

Modify the `setup` functions to accept a parameter for this object.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>

---------

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
lguohan pushed a commit that referenced this pull request Nov 22, 2023
* Fix test execution on Bookworm

Running tests with `python3 -m pytest` instead of `python setup.py test`
causes some breakages on Bookworm. Some of this has to do with what
module searc paths get added, while others appear to be related to
changes in the `mock` module between Python 3.9 and Python 3.11.

Fix this and make sure it works on both Bullseye and Bookworm.

* Fix mclag_test.py having different results for some test cases

The test_mclag_add_mclag_member_to_nonexisting_domain test case passes
when run on Bullseye, but fails on Bookworm. This is because some test
cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may
persist for other test cases as well, and if test cases happen to run in
a different order, then it may unexpectedly fail.

For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by
setting the value there.

* Add check_output parameter to the setup function due to the patch

Since there is a patched function specified as an attribute, newer
versions of mock expect that the object can be passed in as a parameter
to the function. However, the `setup` functions didn't accept it as a
parameter.

Modify the `setup` functions to accept a parameter for this object.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>

---------

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
nmoray pushed a commit to nmoray/sonic-utilities that referenced this pull request Jun 25, 2025
* Fix test execution on Bookworm

Running tests with `python3 -m pytest` instead of `python setup.py test`
causes some breakages on Bookworm. Some of this has to do with what
module searc paths get added, while others appear to be related to
changes in the `mock` module between Python 3.9 and Python 3.11.

Fix this and make sure it works on both Bullseye and Bookworm.

* Fix mclag_test.py having different results for some test cases

The test_mclag_add_mclag_member_to_nonexisting_domain test case passes
when run on Bullseye, but fails on Bookworm. This is because some test
cases modify the value of `mclag.ADHOC_VALIDATION`, but this value may
persist for other test cases as well, and if test cases happen to run in
a different order, then it may unexpectedly fail.

For now, fix `test_mclag_add_mclag_member_to_nonexisting_domain` by
setting the value there.

* Add check_output parameter to the setup function due to the patch

Since there is a patched function specified as an attribute, newer
versions of mock expect that the object can be passed in as a parameter
to the function. However, the `setup` functions didn't accept it as a
parameter.

Modify the `setup` functions to accept a parameter for this object.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>

---------

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
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.

3 participants