Merge 3006.x into master

This commit is contained in:
Pedro Algarvio 2023-06-29 09:40:29 +01:00
commit 819c2dc9e7
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
14 changed files with 40 additions and 52 deletions

View file

@ -0,0 +1,5 @@
Some more deprecated code fixes:
* Stop using the deprecated `locale.getdefaultlocale()` function
* Stop accessing deprecated attributes
* `pathlib.Path.__enter__()` usage is deprecated and not required, a no-op

View file

@ -577,33 +577,37 @@ def pytest_runtest_setup(item):
):
item._skipped_by_mark = True
pytest.skip(PRE_PYTEST_SKIP_REASON)
test_group_count = sum(
bool(item.get_closest_marker(group))
for group in ("core_test", "slow_test", "flaky_jail")
)
if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"):
raise pytest.UsageError(
"Tests can only be in one test group. ('core_test', 'slow_test')"
)
if item.get_closest_marker("core_test"):
if not item.config.getoption("--core-tests"):
raise pytest.skip.Exception(
"Core tests are disabled, pass '--core-tests' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("slow_test"):
if not item.config.getoption("--slow-tests"):
raise pytest.skip.Exception(
"Slow tests are disabled, pass '--run-slow' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("flaky_jail"):
if not item.config.getoption("--flaky-jail"):
raise pytest.skip.Exception(
"flaky jail tests are disabled, pass '--flaky-jail' to enable them.",
_use_item_location=True,
)
if (
not item.get_closest_marker("slow_test")
and not item.get_closest_marker("core_test")
and not item.get_closest_marker("flaky_jail")
):
if not item.config.getoption("--no-fast-tests"):
else:
if item.get_closest_marker("core_test"):
if not item.config.getoption("--core-tests"):
raise pytest.skip.Exception(
"Core tests are disabled, pass '--core-tests' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("slow_test"):
if not item.config.getoption("--slow-tests"):
raise pytest.skip.Exception(
"Slow tests are disabled, pass '--run-slow' to enable them.",
_use_item_location=True,
)
if test_group_count == 0 and item.config.getoption("--no-fast-tests"):
raise pytest.skip.Exception(
"Fast tests are disabled, dont pass '--no-fast-tests' to enable them.",
"Fast tests have been disabled by '--no-fast-tests'.",
_use_item_location=True,
)

View file

@ -322,7 +322,6 @@ def test_issue_46762_prereqs_on_a_state_with_unfulfilled_requirements(
@pytest.mark.skip_on_darwin(reason="Test is broken on macosx")
@pytest.mark.slow_test
def test_issue_30161_unless_and_onlyif_together(state, state_tree, tmp_path):
"""
test cmd.run using multiple unless options where the first cmd in the

View file

@ -571,7 +571,6 @@ def test_issue_38683_require_order_failhard_combination(state, state_tree):
assert ret[state_id].comment == "Failure!"
@pytest.mark.slow_test
@pytest.mark.skip_on_windows
def test_parallel_state_with_requires(state, state_tree):
"""

View file

@ -57,7 +57,6 @@ def test_watch_in_failure(state, state_tree):
)
@pytest.mark.slow_test
def test_requisites_watch_any(state, state_tree):
"""
Call sls file containing several require_in and require.

View file

@ -650,7 +650,6 @@ def test_issues_7905_and_8174_sls_syntax_error(state, state_tree):
assert ret.errors == ["State 'C' in SLS 'badlist2' is not formed as a list"]
@pytest.mark.slow_test
def test_retry_option(state, state_tree):
"""
test the retry option on a simple state with defaults
@ -752,7 +751,6 @@ def test_retry_option_success_parallel(state, state_tree, tmp_path):
assert "Attempt 2" not in state_return.comment
@pytest.mark.slow_test
def test_retry_option_eventual_success(state, state_tree, tmp_path):
"""
test a state with the retry option that should return True, eventually
@ -800,7 +798,6 @@ def test_retry_option_eventual_success(state, state_tree, tmp_path):
@pytest.mark.skip_on_windows(
reason="Skipped until parallel states can be fixed on Windows"
)
@pytest.mark.slow_test
def test_retry_option_eventual_success_parallel(state, state_tree, tmp_path):
"""
test a state with the retry option that should return True, eventually
@ -849,7 +846,6 @@ def test_retry_option_eventual_success_parallel(state, state_tree, tmp_path):
assert "Attempt 5" not in state_return.comment
@pytest.mark.slow_test
def test_state_non_base_environment(state, state_tree_prod, tmp_path):
"""
test state.sls with saltenv using a nonbase environment

View file

@ -132,7 +132,6 @@ def test_exit_status_correct_usage(salt_cli, salt_minion):
assert ret.returncode == salt.defaults.exitcodes.EX_OK, ret
@pytest.mark.slow_test
@pytest.mark.skip_on_windows(reason="Windows does not support SIGINT")
@pytest.mark.skip_initial_onedir_failure
def test_interrupt_on_long_running_job(salt_cli, salt_master, salt_minion):

View file

@ -32,7 +32,6 @@ def dest_testfile():
dst.unlink()
@pytest.mark.slow_test
@pytest.mark.windows_whitelisted
@pytest.mark.core_test
def test_cp_testfile(salt_minion, salt_cp_cli, source_testfile, dest_testfile):

View file

@ -51,7 +51,6 @@ def clear_proxy_minions(salt_master, proxy_minion_id):
os.unlink(cachefile)
@pytest.mark.slow_test
def test_exit_status_no_proxyid(salt_master, proxy_minion_id):
"""
Ensure correct exit status when --proxyid argument is missing.
@ -93,7 +92,6 @@ def test_exit_status_unknown_user(salt_master, proxy_minion_id):
assert "The user is not available." in exc.value.process_result.stderr
@pytest.mark.slow_test
def test_exit_status_unknown_argument(salt_master, proxy_minion_id):
"""
Ensure correct exit status when an unknown argument is passed to

View file

@ -16,8 +16,8 @@ def reset_pillar(salt_call_cli):
finally:
# Refresh pillar once all tests are done.
ret = salt_call_cli.run("saltutil.refresh_pillar", wait=True)
assert ret.exitcode == 0
assert ret.json is True
assert ret.returncode == 0
assert ret.data is True
@pytest.fixture
@ -77,8 +77,8 @@ def test_state_apply_aborts_on_pillar_error(
shell_result = salt_cli.run(
"state.apply", "sls-id-test", minion_tgt=salt_minion.id
)
assert shell_result.exitcode == 1
assert shell_result.json == expected_comment
assert shell_result.returncode == 1
assert shell_result.data == expected_comment
@pytest.mark.usefixtures("testfile_path", "reset_pillar")
@ -117,7 +117,7 @@ def test_state_apply_continues_after_pillar_error_is_fixed(
shell_result = salt_cli.run(
"saltutil.refresh_pillar", minion_tgt=salt_minion.id
)
assert shell_result.exitcode == 0
assert shell_result.returncode == 0
# run state.apply with fixed pillar render error
with pytest.helpers.temp_file(
@ -128,7 +128,7 @@ def test_state_apply_continues_after_pillar_error_is_fixed(
shell_result = salt_cli.run(
"state.apply", "sls-id-test", minion_tgt=salt_minion.id
)
assert shell_result.exitcode == 0
state_result = StateResult(shell_result.json)
assert shell_result.returncode == 0
state_result = StateResult(shell_result.data)
assert state_result.result is True
assert state_result.changes == {"diff": "New file", "mode": "0644"}

View file

@ -87,13 +87,13 @@ def world():
return "world"
"""
test_moduledir = salt_master.state_tree.base.paths[0] / f"_{module_type}"
test_moduledir = salt_master.state_tree.base.write_path / f"_{module_type}"
test_moduledir.mkdir(parents=True, exist_ok=True)
module_tempfile = salt_master.state_tree.base.temp_file(
f"_{module_type}/{module_name}.py", module_contents
)
with module_tempfile, test_moduledir:
with module_tempfile:
salt_cmd = f"saltutil.sync_{module_sync_functions[module_type]}"
ret = salt_run_cli.run(salt_cmd)
assert ret.returncode == 0

View file

@ -1070,7 +1070,7 @@ def test_recurse(
"{}.sls".format(sls_name), sls_contents
)
with sls_tempfile, test_tempdir:
with sls_tempfile:
for _dir in "test1", "test2", "test3":
test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True)
@ -1117,7 +1117,7 @@ def test_recurse_keep_symlinks_in_fileserver_root(
"{}.sls".format(sls_name), sls_contents
)
with sls_tempfile, test_tempdir:
with sls_tempfile:
for _dir in "test1", "test2", "test3":
test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True)
@ -1169,7 +1169,7 @@ def test_recurse_keep_symlinks_outside_fileserver_root(
"{}.sls".format(sls_name), sls_contents
)
with sls_tempfile, test_tempdir:
with sls_tempfile:
for _dir in "test1", "test2", "test3":
test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True)

View file

@ -38,7 +38,6 @@ def test_format_log_non_ascii_character():
salt.state.format_log(ret)
@pytest.mark.slow_test
def test_render_error_on_invalid_requisite(minion_opts):
"""
Test that the state compiler correctly deliver a rendering

View file

@ -35,7 +35,6 @@ def test_format_slots_no_slots(state_obj):
assert cdata == {"args": ["arg"], "kwargs": {"key": "val"}}
@pytest.mark.slow_test
def test_format_slots_arg(state_obj):
"""
Test the format slots is calling a slot specified in args with corresponding arguments.
@ -51,7 +50,6 @@ def test_format_slots_arg(state_obj):
assert cdata == {"args": ["fun_return"], "kwargs": {"key": "val"}}
@pytest.mark.slow_test
def test_format_slots_dict_arg(state_obj):
"""
Test the format slots is calling a slot specified in dict arg.
@ -67,7 +65,6 @@ def test_format_slots_dict_arg(state_obj):
assert cdata == {"args": [{"subarg": "fun_return"}], "kwargs": {"key": "val"}}
@pytest.mark.slow_test
def test_format_slots_listdict_arg(state_obj):
"""
Test the format slots is calling a slot specified in list containing a dict.
@ -83,7 +80,6 @@ def test_format_slots_listdict_arg(state_obj):
assert cdata == {"args": [[{"subarg": "fun_return"}]], "kwargs": {"key": "val"}}
@pytest.mark.slow_test
def test_format_slots_liststr_arg(state_obj):
"""
Test the format slots is calling a slot specified in list containing a dict.
@ -99,7 +95,6 @@ def test_format_slots_liststr_arg(state_obj):
assert cdata == {"args": [["fun_return"]], "kwargs": {"key": "val"}}
@pytest.mark.slow_test
def test_format_slots_kwarg(state_obj):
"""
Test the format slots is calling a slot specified in kwargs with corresponding arguments.
@ -115,7 +110,6 @@ def test_format_slots_kwarg(state_obj):
assert cdata == {"args": ["arg"], "kwargs": {"key": "fun_return"}}
@pytest.mark.slow_test
def test_format_slots_multi(state_obj):
"""
Test the format slots is calling all slots with corresponding arguments when multiple slots
@ -155,7 +149,6 @@ def test_format_slots_multi(state_obj):
}
@pytest.mark.slow_test
def test_format_slots_malformed(state_obj):
"""
Test the format slots keeps malformed slots untouched.
@ -186,7 +179,6 @@ def test_format_slots_malformed(state_obj):
assert cdata == sls_data
@pytest.mark.slow_test
def test_slot_traverse_dict(state_obj):
"""
Test the slot parsing of dict response.
@ -203,7 +195,6 @@ def test_slot_traverse_dict(state_obj):
assert cdata == {"args": ["arg"], "kwargs": {"key": "value1"}}
@pytest.mark.slow_test
def test_slot_append(state_obj):
"""
Test the slot parsing of dict response.