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

NAS-127251 / 24.10 / Add pytest markers for more intelligent runs #13041

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anodos325
Copy link
Contributor

@anodos325 anodos325 commented Jan 30, 2024

This commit adds basic framework for setting custom markers in our API tests. They can either be set globally for the module via
pytestmark = pytest.mark.smb

and multiple for module
pytestmark = [pytest.mark.fs, pytest.mark.slow]

or via test-specific decorator
@pytest.mark.smb

Long-running tests (more than a couple of minutes) should be marked as slow so that they can be skipped in incremental builds.

New markers can be added to the pytest.ini file. If someone feels particularly ambitious they can enhance in the future by adding a parser to assign markers based on test file names.

This commit adds basic framework for setting custom markers
in our API tests. They can either be set globally for the
module via
`pytestmark = pytest.mark.smb`

and multiple for module
`pytestmark = [pytest.mark.fs, pytest.mark.slow]`

or via test-specific decorator
`@pytest.mark.smb`

Long-running tests (more than a couple of minutes) should be
marked as `slow` so that they can be skipped in incremental
builds.
@anodos325 anodos325 removed the WIP label Feb 6, 2024
@anodos325 anodos325 requested a review from a team February 6, 2024 22:07
@bugclerk bugclerk changed the title Add pytest markers for more intelligent runs NAS-127251 / 24.10 / Add pytest markers for more intelligent runs Feb 6, 2024
@bugclerk
Copy link
Contributor

bugclerk commented Feb 6, 2024

@@ -37,6 +37,7 @@
--interface <interface> - The interface that TrueNAS is run one

Optional option
--markers "smb or nfs" - Markers to run
Copy link
Contributor

Choose a reason for hiding this comment

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

Not easy to indicate the format. Maybe
--markers "<markers to run>" - Quoted list separated by 'or', e.g. "smb or nfs". See pytest.ini for list of markers.

@mgrimesix
Copy link
Contributor

What would the runtest option look like if I wanted to run 'nfs' and tests without 'slow' markings only?

@@ -2,6 +2,8 @@

from middlewared.test.integration.assets.roles import common_checks

pytestmark = [pytest.mark.vm, pytest.mark.slow]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this slow?

@themylogin
Copy link
Contributor

Can we fail the whole test suite if some test file does not have any of the markers?

@@ -123,6 +126,8 @@
callargs.append('-s')
elif output == '--tests':
tests.extend(arg.split(','))
elif output == '--markers':
markers.extend(['-m', f'base or {arg}'])
Copy link
Contributor

Choose a reason for hiding this comment

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

If arg can be a logic expression shouldn't we enclose it in parenthesis?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants