Skip to content

Commit

Permalink
Replace the @slowTest decorator with the slow_test pytest marker
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed Dec 31, 2020
1 parent 727ae63 commit ae36b15
Show file tree
Hide file tree
Showing 34 changed files with 110 additions and 214 deletions.
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,14 @@ def pytest_configure(config):
config.addinivalue_line(
"markers", "requires_sshd_server: Mark test that require an SSH server running"
)
config.addinivalue_line(
"markers",
"slow_test: Mark test as being slow. These tests are skipped by default unless `--run-slow` is passed",
)
# Make sure the test suite "knows" this is a pytest test run
RUNTIME_VARS.PYTEST_SESSION = True

# "Flag" the slotTest decorator if we're skipping slow tests or not
# "Flag" the slowTest decorator if we're skipping slow tests or not
os.environ["SLOW_TESTS"] = str(config.getoption("--run-slow"))


Expand Down Expand Up @@ -464,7 +468,9 @@ def pytest_runtest_setup(item):
item._skipped_by_mark = True
pytest.skip(PRE_PYTEST_SKIP_REASON)

if saltfactories.utils.compat.has_unittest_attr(item, "__slow_test__"):
if saltfactories.utils.compat.has_unittest_attr(
item, "__slow_test__"
) or item.get_closest_marker("slow_test"):
if item.config.getoption("--run-slow") is False:
item._skipped_by_mark = True
pytest.skip("Slow tests are disabled!")
Expand Down
3 changes: 1 addition & 2 deletions tests/pytests/functional/pillar/test_gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import salt.pillar
import salt.utils.stringutils
from saltfactories.utils.processes import ProcessResult
from tests.support.helpers import slowTest

pytestmark = [
pytest.mark.windows_whitelisted,
Expand Down Expand Up @@ -271,7 +270,7 @@ def test_decrypt_pillar_default_renderer(salt_master, grains):
assert ret == GPG_PILLAR_DECRYPTED


@slowTest
@pytest.mark.slow_test
def test_decrypt_pillar_alternate_delimiter(salt_master, grains):
"""
Test recursive decryption of secrets:vault using a pipe instead of a
Expand Down
26 changes: 1 addition & 25 deletions tests/pytests/integration/cli/test_matcher.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
import salt.defaults.exitcodes
from tests.support.helpers import slowTest

pytestmark = [
pytest.mark.slow_test,
pytest.mark.windows_whitelisted,
]

Expand Down Expand Up @@ -76,7 +76,6 @@ def pillar_tree(base_env_pillar_tree_root_dir, salt_minion, salt_sub_minion, sal
assert ret.json[salt_sub_minion.id] is True


@slowTest
def test_list(salt_cli, salt_minion, salt_sub_minion):
"""
test salt -L matcher
Expand All @@ -94,7 +93,6 @@ def test_list(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_compound_min_with_grain(salt_cli, salt_minion, salt_sub_minion):
"""
test salt compound matcher
Expand All @@ -105,39 +103,34 @@ def test_compound_min_with_grain(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id not in ret.json


@slowTest
def test_compound_and_not_grain(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("-C", "test.ping", minion_tgt="min* and not G@test_grain:foo")
assert ret.exitcode == 0
assert salt_minion.id in ret.json
assert salt_sub_minion.id not in ret.json


@slowTest
def test_compound_not_grain(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("-C", "test.ping", minion_tgt="min* not G@test_grain:foo")
assert ret.exitcode == 0
assert salt_minion.id in ret.json
assert salt_sub_minion.id not in ret.json


@slowTest
def test_compound_pcre_grain_and_grain(salt_cli, salt_minion, salt_sub_minion):
match = "P@test_grain:^cheese$ and * and G@test_grain:cheese"
ret = salt_cli.run("-C", "test.ping", minion_tgt=match)
assert salt_minion.id in ret.json
assert salt_sub_minion.id not in ret.json


@slowTest
def test_compound_list_and_pcre_minion(salt_cli, salt_minion, salt_sub_minion):
match = "L@{} and E@.*".format(salt_sub_minion.id)
ret = salt_cli.run("-C", "test.ping", minion_tgt=match)
assert salt_sub_minion.id in ret.json
assert salt_minion.id not in ret.json


@slowTest
def test_compound_not_sub_minion(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run(
"-C", "test.ping", minion_tgt="not {}".format(salt_sub_minion.id)
Expand All @@ -147,7 +140,6 @@ def test_compound_not_sub_minion(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id not in ret.json


@slowTest
def test_compound_all_and_not_grains(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run(
"-C", "test.ping", minion_tgt="* and ( not G@test_grain:cheese )"
Expand All @@ -157,23 +149,20 @@ def test_compound_all_and_not_grains(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_compound_grain_regex(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("-C", "test.ping", minion_tgt="G%@planets%merc*")
assert ret.exitcode == 0
assert salt_minion.id in ret.json
assert salt_sub_minion.id not in ret.json


@slowTest
def test_coumpound_pcre_grain_regex(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("-C", "test.ping", minion_tgt="P%@planets%^(mercury|saturn)$")
assert ret.exitcode == 0
assert salt_minion.id in ret.json
assert salt_sub_minion.id in ret.json


@slowTest
def test_compound_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
# FYI, This test was previously being skipped because it was unreliable
ret = salt_cli.run("-C", "test.ping", minion_tgt="I%@companions%three%sarah*")
Expand All @@ -182,7 +171,6 @@ def test_compound_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
assert salt_sub_minion.id in ret.json


@slowTest
def test_compound_pillar_pcre(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
# FYI, This test was previously being skipped because it was unreliable
ret = salt_cli.run("-C", "test.ping", minion_tgt="J%@knights%^(Lancelot|Galahad)$")
Expand Down Expand Up @@ -210,7 +198,6 @@ def test_compound_nodegroup(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id not in ret.json


@slowTest
def test_nodegroup(salt_cli, salt_minion, salt_sub_minion):
"""
test salt nodegroup matcher
Expand Down Expand Up @@ -242,7 +229,6 @@ def test_nodegroup(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_nodegroup_list(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("-N", "test.ping", minion_tgt="list_group")
assert ret.exitcode == 0
Expand All @@ -265,7 +251,6 @@ def test_nodegroup_list(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id not in ret.json


@slowTest
def test_glob(salt_cli, salt_minion, salt_sub_minion):
"""
test salt glob matcher
Expand All @@ -281,7 +266,6 @@ def test_glob(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_regex(salt_cli, salt_minion, salt_sub_minion):
"""
test salt regex matcher
Expand All @@ -296,7 +280,6 @@ def test_regex(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_grain(salt_cli, salt_master, salt_minion, salt_sub_minion):
"""
test salt grain matcher
Expand Down Expand Up @@ -364,7 +347,6 @@ def test_grain(salt_cli, salt_master, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_regrain(salt_cli, salt_minion, salt_sub_minion):
"""
test salt grain matcher
Expand All @@ -379,7 +361,6 @@ def test_regrain(salt_cli, salt_minion, salt_sub_minion):
assert salt_minion.id not in ret.json


@slowTest
def test_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
"""
test pillar matcher
Expand Down Expand Up @@ -413,7 +394,6 @@ def test_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
assert salt_sub_minion.id in ret.json


@slowTest
def test_repillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
"""
test salt pillar PCRE matcher
Expand All @@ -430,7 +410,6 @@ def test_repillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
assert salt_sub_minion.id in ret.json


@slowTest
def test_ipcidr(salt_cli, salt_minion, salt_sub_minion):
ret = salt_cli.run("network.subnets", minion_tgt=salt_minion.id)
assert ret.exitcode == 0
Expand All @@ -445,7 +424,6 @@ def test_ipcidr(salt_cli, salt_minion, salt_sub_minion):
assert salt_sub_minion.id in ret.json


@slowTest
def test_static(salt_cli, salt_minion, salt_sub_minion):
"""
test salt static call
Expand All @@ -456,7 +434,6 @@ def test_static(salt_cli, salt_minion, salt_sub_minion):
assert salt_minion.id in ret.stdout


@slowTest
def test_salt_documentation(salt_cli, salt_minion):
"""
Test to see if we're supporting --doc
Expand All @@ -466,7 +443,6 @@ def test_salt_documentation(salt_cli, salt_minion):
assert "test.ping" in ret.json


@slowTest
def test_salt_documentation_too_many_arguments(salt_cli, salt_minion):
"""
Test to see if passing additional arguments shows an error
Expand Down
11 changes: 4 additions & 7 deletions tests/pytests/integration/cli/test_salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
import pytest
import salt.defaults.exitcodes
import salt.utils.path
from tests.support.helpers import slowTest

log = logging.getLogger(__name__)

pytestmark = pytest.mark.windows_whitelisted
pytestmark = [
pytest.mark.slow_test,
pytest.mark.windows_whitelisted,
]


@slowTest
def test_context_retcode_salt(salt_cli, salt_minion):
"""
Test that a nonzero retcode set in the context dunder will cause the
Expand All @@ -36,7 +37,6 @@ def test_context_retcode_salt(salt_cli, salt_minion):
assert ret.exitcode == salt.defaults.exitcodes.EX_GENERIC, ret


@slowTest
def test_salt_error(salt_cli, salt_minion):
"""
Test that we return the expected retcode when a minion function raises
Expand Down Expand Up @@ -86,7 +86,6 @@ def test_salt_error(salt_cli, salt_minion):
assert ret.exitcode == salt.defaults.exitcodes.EX_GENERIC, ret


@slowTest
def test_missing_minion(salt_cli, salt_master, salt_minion):
"""
Test that a minion which doesn't respond results in a nonzeo exit code
Expand All @@ -113,7 +112,6 @@ def test_missing_minion(salt_cli, salt_master, salt_minion):
)


@slowTest
def test_exit_status_unknown_argument(salt_cli):
"""
Ensure correct exit status when an unknown argument is passed to salt CLI.
Expand All @@ -126,7 +124,6 @@ def test_exit_status_unknown_argument(salt_cli):
assert "no such option: --unknown-argument" in ret.stderr


@slowTest
def test_exit_status_correct_usage(salt_cli, salt_minion):
"""
Ensure correct exit status when salt CLI starts correctly.
Expand Down
5 changes: 1 addition & 4 deletions tests/pytests/integration/cli/test_salt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import pytest
import salt.utils.platform
import salt.utils.pycrypto
from tests.support.helpers import slowTest

log = logging.getLogger(__name__)

pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_not_root,
pytest.mark.destructive_test,
pytest.mark.skip_on_windows,
Expand Down Expand Up @@ -74,7 +74,6 @@ def saltadm_account(sminion, saltops_group):
sminion.functions.user.delete(USERB, remove=True)


@slowTest
def test_pam_auth_valid_user(salt_minion, salt_cli, saltdev_account):
"""
test that pam auth mechanism works with a valid user
Expand All @@ -94,7 +93,6 @@ def test_pam_auth_valid_user(salt_minion, salt_cli, saltdev_account):
assert ret.json is True


@slowTest
def test_pam_auth_invalid_user(salt_minion, salt_cli, saltdev_account):
"""
test pam auth mechanism errors for an invalid user
Expand All @@ -112,7 +110,6 @@ def test_pam_auth_invalid_user(salt_minion, salt_cli, saltdev_account):
assert ret.stdout == "Authentication error occurred."


@slowTest
def test_pam_auth_valid_group(salt_minion, salt_cli, saltadm_account):
"""
test that pam auth mechanism works for a valid group
Expand Down
Loading

0 comments on commit ae36b15

Please sign in to comment.