From 6a715107fa89b060175ef0c0ae0827b409411543 Mon Sep 17 00:00:00 2001 From: jeanluc Date: Fri, 8 Dec 2023 11:17:50 +0100 Subject: [PATCH] Fix tests after rebase --- .../pytests/integration/ssh/state/conftest.py | 2 +- .../integration/ssh/state/test_state.py | 59 ----------------- .../ssh/state/test_with_import_dir.py | 65 +++++++++++++++++++ tests/pytests/integration/ssh/test_config.py | 4 +- 4 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 tests/pytests/integration/ssh/state/test_with_import_dir.py diff --git a/tests/pytests/integration/ssh/state/conftest.py b/tests/pytests/integration/ssh/state/conftest.py index 14d645ae8e8..9de0d6bcad8 100644 --- a/tests/pytests/integration/ssh/state/conftest.py +++ b/tests/pytests/integration/ssh/state/conftest.py @@ -17,7 +17,7 @@ def state_tree(base_env_state_tree_root_dir): state_file = """ {%- from "map.jinja" import abc with context %} Ok with {{ abc }}: - test.succeed_without_changes + test.succeed_with_changes """ top_tempfile = pytest.helpers.temp_file( "top.sls", top_file, base_env_state_tree_root_dir diff --git a/tests/pytests/integration/ssh/state/test_state.py b/tests/pytests/integration/ssh/state/test_state.py index a7ebb22a601..0a0cad15272 100644 --- a/tests/pytests/integration/ssh/state/test_state.py +++ b/tests/pytests/integration/ssh/state/test_state.py @@ -15,65 +15,6 @@ def test_state_with_import(salt_ssh_cli, state_tree): assert ret.data -@pytest.mark.parametrize( - "ssh_cmd", - [ - "state.sls", - "state.highstate", - "state.apply", - "state.show_top", - "state.show_highstate", - "state.show_low_sls", - "state.show_lowstate", - "state.sls_id", - "state.show_sls", - "state.top", - ], -) -def test_state_with_import_dir(salt_ssh_cli, state_tree_dir, ssh_cmd): - """ - verify salt-ssh can use imported map files in states - when the map files are in another directory outside of - sls files importing them. - """ - if ssh_cmd in ("state.sls", "state.show_low_sls", "state.show_sls"): - ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "test") - elif ssh_cmd == "state.top": - ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "top.sls") - elif ssh_cmd == "state.sls_id": - ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "Ok with def", "test") - else: - ret = salt_ssh_cli.run("-w", "-t", ssh_cmd) - assert ret.returncode == 0 - if ssh_cmd == "state.show_top": - assert ret.data == {"base": ["test", "master_tops_test"]} or {"base": ["test"]} - elif ssh_cmd in ("state.show_highstate", "state.show_sls"): - assert ret.data == { - "Ok with def": { - "__sls__": "test", - "__env__": "base", - "test": ["succeed_without_changes", {"order": 10000}], - } - } - elif ssh_cmd in ("state.show_low_sls", "state.show_lowstate", "state.show_sls"): - assert ret.data == [ - { - "state": "test", - "name": "Ok with def", - "__sls__": "test", - "__env__": "base", - "__id__": "Ok with def", - "order": 10000, - "fun": "succeed_without_changes", - } - ] - else: - assert ret.data["test_|-Ok with def_|-Ok with def_|-succeed_without_changes"][ - "result" - ] - assert ret.data - - def test_state_with_import_from_dir(salt_ssh_cli, nested_state_tree): """ verify salt-ssh can use imported map files in states diff --git a/tests/pytests/integration/ssh/state/test_with_import_dir.py b/tests/pytests/integration/ssh/state/test_with_import_dir.py new file mode 100644 index 00000000000..4048545bfc2 --- /dev/null +++ b/tests/pytests/integration/ssh/state/test_with_import_dir.py @@ -0,0 +1,65 @@ +""" +Verify salt-ssh can use imported map files in states +when the map files are in another directory outside of +sls files importing them. +""" +import pytest + +pytestmark = [ + pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"), + pytest.mark.slow_test, +] + + +@pytest.mark.parametrize( + "ssh_cmd", + [ + "state.sls", + "state.highstate", + "state.apply", + "state.show_top", + "state.show_highstate", + "state.show_low_sls", + "state.show_lowstate", + "state.sls_id", + "state.show_sls", + "state.top", + ], +) +def test_state_with_import_dir(salt_ssh_cli, state_tree_dir, ssh_cmd): + if ssh_cmd in ("state.sls", "state.show_low_sls", "state.show_sls"): + ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "test") + elif ssh_cmd == "state.top": + ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "top.sls") + elif ssh_cmd == "state.sls_id": + ret = salt_ssh_cli.run("-w", "-t", ssh_cmd, "Ok with def", "test") + else: + ret = salt_ssh_cli.run("-w", "-t", ssh_cmd) + assert ret.returncode == 0 + if ssh_cmd == "state.show_top": + assert ret.data == {"base": ["test", "master_tops_test"]} or {"base": ["test"]} + elif ssh_cmd in ("state.show_highstate", "state.show_sls"): + assert ret.data == { + "Ok with def": { + "__sls__": "test", + "__env__": "base", + "test": ["succeed_without_changes", {"order": 10000}], + } + } + elif ssh_cmd in ("state.show_low_sls", "state.show_lowstate", "state.show_sls"): + assert ret.data == [ + { + "state": "test", + "name": "Ok with def", + "__sls__": "test", + "__env__": "base", + "__id__": "Ok with def", + "order": 10000, + "fun": "succeed_without_changes", + } + ] + else: + assert ret.data["test_|-Ok with def_|-Ok with def_|-succeed_without_changes"][ + "result" + ] + assert ret.data diff --git a/tests/pytests/integration/ssh/test_config.py b/tests/pytests/integration/ssh/test_config.py index d3ae2b03a3e..7f38ec5a0a8 100644 --- a/tests/pytests/integration/ssh/test_config.py +++ b/tests/pytests/integration/ssh/test_config.py @@ -16,7 +16,9 @@ def test_items(salt_ssh_cli): @pytest.mark.parametrize("omit", (False, True)) def test_option_minion_opt(salt_ssh_cli, omit): # Minion opt - ret = salt_ssh_cli.run("config.option", "id", omit_opts=omit, omit_grains=True) + ret = salt_ssh_cli.run( + "config.option", "id", omit_opts=omit, omit_grains=True, omit_master=True + ) assert ret.returncode == 0 assert (ret.data != salt_ssh_cli.get_minion_tgt()) is omit assert (ret.data == "") is omit