Skip to content

Commit ae36b15

Browse files
committed
Replace the @slowTest decorator with the slow_test pytest marker
1 parent 727ae63 commit ae36b15

34 files changed

+110
-214
lines changed

tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,14 @@ def pytest_configure(config):
242242
config.addinivalue_line(
243243
"markers", "requires_sshd_server: Mark test that require an SSH server running"
244244
)
245+
config.addinivalue_line(
246+
"markers",
247+
"slow_test: Mark test as being slow. These tests are skipped by default unless `--run-slow` is passed",
248+
)
245249
# Make sure the test suite "knows" this is a pytest test run
246250
RUNTIME_VARS.PYTEST_SESSION = True
247251

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

251255

@@ -464,7 +468,9 @@ def pytest_runtest_setup(item):
464468
item._skipped_by_mark = True
465469
pytest.skip(PRE_PYTEST_SKIP_REASON)
466470

467-
if saltfactories.utils.compat.has_unittest_attr(item, "__slow_test__"):
471+
if saltfactories.utils.compat.has_unittest_attr(
472+
item, "__slow_test__"
473+
) or item.get_closest_marker("slow_test"):
468474
if item.config.getoption("--run-slow") is False:
469475
item._skipped_by_mark = True
470476
pytest.skip("Slow tests are disabled!")

tests/pytests/functional/pillar/test_gpg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import salt.pillar
99
import salt.utils.stringutils
1010
from saltfactories.utils.processes import ProcessResult
11-
from tests.support.helpers import slowTest
1211

1312
pytestmark = [
1413
pytest.mark.windows_whitelisted,
@@ -271,7 +270,7 @@ def test_decrypt_pillar_default_renderer(salt_master, grains):
271270
assert ret == GPG_PILLAR_DECRYPTED
272271

273272

274-
@slowTest
273+
@pytest.mark.slow_test
275274
def test_decrypt_pillar_alternate_delimiter(salt_master, grains):
276275
"""
277276
Test recursive decryption of secrets:vault using a pipe instead of a

tests/pytests/integration/cli/test_matcher.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22
import salt.defaults.exitcodes
3-
from tests.support.helpers import slowTest
43

54
pytestmark = [
5+
pytest.mark.slow_test,
66
pytest.mark.windows_whitelisted,
77
]
88

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

7878

79-
@slowTest
8079
def test_list(salt_cli, salt_minion, salt_sub_minion):
8180
"""
8281
test salt -L matcher
@@ -94,7 +93,6 @@ def test_list(salt_cli, salt_minion, salt_sub_minion):
9493
assert salt_sub_minion.id in ret.json
9594

9695

97-
@slowTest
9896
def test_compound_min_with_grain(salt_cli, salt_minion, salt_sub_minion):
9997
"""
10098
test salt compound matcher
@@ -105,39 +103,34 @@ def test_compound_min_with_grain(salt_cli, salt_minion, salt_sub_minion):
105103
assert salt_sub_minion.id not in ret.json
106104

107105

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

115112

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

123119

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

131126

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

139133

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

149142

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

159151

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

167158

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

175165

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

184173

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

212200

213-
@slowTest
214201
def test_nodegroup(salt_cli, salt_minion, salt_sub_minion):
215202
"""
216203
test salt nodegroup matcher
@@ -242,7 +229,6 @@ def test_nodegroup(salt_cli, salt_minion, salt_sub_minion):
242229
assert salt_sub_minion.id in ret.json
243230

244231

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

267253

268-
@slowTest
269254
def test_glob(salt_cli, salt_minion, salt_sub_minion):
270255
"""
271256
test salt glob matcher
@@ -281,7 +266,6 @@ def test_glob(salt_cli, salt_minion, salt_sub_minion):
281266
assert salt_sub_minion.id in ret.json
282267

283268

284-
@slowTest
285269
def test_regex(salt_cli, salt_minion, salt_sub_minion):
286270
"""
287271
test salt regex matcher
@@ -296,7 +280,6 @@ def test_regex(salt_cli, salt_minion, salt_sub_minion):
296280
assert salt_sub_minion.id in ret.json
297281

298282

299-
@slowTest
300283
def test_grain(salt_cli, salt_master, salt_minion, salt_sub_minion):
301284
"""
302285
test salt grain matcher
@@ -364,7 +347,6 @@ def test_grain(salt_cli, salt_master, salt_minion, salt_sub_minion):
364347
assert salt_sub_minion.id in ret.json
365348

366349

367-
@slowTest
368350
def test_regrain(salt_cli, salt_minion, salt_sub_minion):
369351
"""
370352
test salt grain matcher
@@ -379,7 +361,6 @@ def test_regrain(salt_cli, salt_minion, salt_sub_minion):
379361
assert salt_minion.id not in ret.json
380362

381363

382-
@slowTest
383364
def test_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
384365
"""
385366
test pillar matcher
@@ -413,7 +394,6 @@ def test_pillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
413394
assert salt_sub_minion.id in ret.json
414395

415396

416-
@slowTest
417397
def test_repillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
418398
"""
419399
test salt pillar PCRE matcher
@@ -430,7 +410,6 @@ def test_repillar(salt_cli, salt_minion, salt_sub_minion, pillar_tree):
430410
assert salt_sub_minion.id in ret.json
431411

432412

433-
@slowTest
434413
def test_ipcidr(salt_cli, salt_minion, salt_sub_minion):
435414
ret = salt_cli.run("network.subnets", minion_tgt=salt_minion.id)
436415
assert ret.exitcode == 0
@@ -445,7 +424,6 @@ def test_ipcidr(salt_cli, salt_minion, salt_sub_minion):
445424
assert salt_sub_minion.id in ret.json
446425

447426

448-
@slowTest
449427
def test_static(salt_cli, salt_minion, salt_sub_minion):
450428
"""
451429
test salt static call
@@ -456,7 +434,6 @@ def test_static(salt_cli, salt_minion, salt_sub_minion):
456434
assert salt_minion.id in ret.stdout
457435

458436

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

468445

469-
@slowTest
470446
def test_salt_documentation_too_many_arguments(salt_cli, salt_minion):
471447
"""
472448
Test to see if passing additional arguments shows an error

tests/pytests/integration/cli/test_salt.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
import pytest
1717
import salt.defaults.exitcodes
1818
import salt.utils.path
19-
from tests.support.helpers import slowTest
2019

2120
log = logging.getLogger(__name__)
2221

23-
pytestmark = pytest.mark.windows_whitelisted
22+
pytestmark = [
23+
pytest.mark.slow_test,
24+
pytest.mark.windows_whitelisted,
25+
]
2426

2527

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

3839

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

8888

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

115114

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

128126

129-
@slowTest
130127
def test_exit_status_correct_usage(salt_cli, salt_minion):
131128
"""
132129
Ensure correct exit status when salt CLI starts correctly.

tests/pytests/integration/cli/test_salt_auth.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import pytest
1010
import salt.utils.platform
1111
import salt.utils.pycrypto
12-
from tests.support.helpers import slowTest
1312

1413
log = logging.getLogger(__name__)
1514

1615
pytestmark = [
16+
pytest.mark.slow_test,
1717
pytest.mark.skip_if_not_root,
1818
pytest.mark.destructive_test,
1919
pytest.mark.skip_on_windows,
@@ -74,7 +74,6 @@ def saltadm_account(sminion, saltops_group):
7474
sminion.functions.user.delete(USERB, remove=True)
7575

7676

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

9695

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

114112

115-
@slowTest
116113
def test_pam_auth_valid_group(salt_minion, salt_cli, saltadm_account):
117114
"""
118115
test that pam auth mechanism works for a valid group

0 commit comments

Comments
 (0)