Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest with randomly via tox #28

Merged
merged 5 commits into from
Sep 15, 2023

Conversation

synarete
Copy link
Collaborator

Use tox to run pytest. Use pytest-randomly to have better control on random seed upon re-run due to test failure.

Shachar Sharon added 3 commits September 12, 2023 11:59
When running python interpreter directly, it may create __pycache__
sub-directories. Ignore those.

Signed-off-by: Shachar Sharon <ssharon@ibm.com>
Have top-level 'conftest.py' for pytest's fixtures [1], to allow sharing
fixtures across multiple files. Begin with an empty file and content as
needed.

[1] https://docs.pytest.org/en/7.4.x/reference/fixtures.html

Signed-off-by: Shachar Sharon <ssharon@ibm.com>
Use tox to run pytests with all its dependencies. In particular
configure tox to run pytest using pytest-randomly[1] to have better
control on random seed and allow reproducing tests seed.

Signed-off-by: Shachar Sharon <ssharon@ibm.com>
Copy link
Collaborator

@phlogistonjohn phlogistonjohn left a comment

Choose a reason for hiding this comment

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

LGTM generally, I'm just not entirely sure why "pytest" and "sanity" are separate envs, since there appears to be overlap between them. I approve, but would like to add a comment/documentation on what each env is meant to accomplish.

@synarete
Copy link
Collaborator Author

LGTM generally, I'm just not entirely sure why "pytest" and "sanity" are separate envs, since there appears to be overlap between them. I approve, but would like to add a comment/documentation on what each env is meant to accomplish.

It preserves the current existing logic in top-level Makefile (I did not want to do such cleanup in this PR).

@phlogistonjohn
Copy link
Collaborator

OK, thanks. I overlooked that was already the case. My general suggestion to document these different cases still stands, but not for this PR. :-)

Prefer tox with all its glory over raw shell command. Use top-level
Makefile as an easy wrapper over tox. Assuming tox is already installed
on local-host/local-user.

Signed-off-by: Shachar Sharon <ssharon@ibm.com>
@spuiuk
Copy link
Collaborator

spuiuk commented Sep 14, 2023

retest this please

@spuiuk
Copy link
Collaborator

spuiuk commented Sep 14, 2023

@synarete , we may need to install tox on the test system in sit-environment before we can commit this change.

From the console output of the test failure.

STDERR:

/bin/sh: tox: command not found
make: *** [Makefile:15: test] Error 127


MSG:

non-zero return code

@synarete
Copy link
Collaborator Author

@synarete , we may need to install tox on the test system in sit-environment before we can commit this change.

From the console output of the test failure.

STDERR:

/bin/sh: tox: command not found
make: *** [Makefile:15: test] Error 127


MSG:

non-zero return code

Indeed. For CentOS8 this is not an option due to old Python version. For CentOPS9-stream it should be fine. Do you think we should install it a rpm package on host or per user with python -m pip install --user tox?

@spuiuk
Copy link
Collaborator

spuiuk commented Sep 15, 2023

/retest all

Copy link
Collaborator

@spuiuk spuiuk left a comment

Choose a reason for hiding this comment

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

ACK - but one caveat. We introduce conftest.py but it is never populated. Should we hold on introducing the file until we actually want to add some pytest conf?

@spuiuk
Copy link
Collaborator

spuiuk commented Sep 15, 2023

testcases/mount/test_mount.py::test_mount[192.168.123.11-gluster-vol-disperse] FAILED [ 87%]
testcases/mount/test_mount.py::test_mount[192.168.123.10-gluster-vol-disperse] FAILED [ 92%]
..

>       return strfunc(str(pathobj), *args)
E       OSError: [Errno 9] Bad file descriptor: '/tmp/11864/mnt_0/mount_test/test_io_consistency/0'

/usr/lib64/python3.6/pathlib.py:387: OSError

This is a known issue and not affected by the changes here.

The only difference is that the order in which the tests were run has changed. This is expected as part of the pytest-randomly use.

@spuiuk
Copy link
Collaborator

spuiuk commented Sep 15, 2023

/retest all

@spuiuk spuiuk merged commit d8f14a1 into samba-in-kubernetes:main Sep 15, 2023
4 checks passed
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.

4 participants