From 9d7ecd47cd18faf5f43fcccfd5805849a5526e325d1dc8c39bff714f1a68800d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Thu, 6 Jun 2024 12:44:27 +0000 Subject: [PATCH 1/2] Accepting request 1179004 from home:mczernek:branches:systemsmanagement:saltstack - Add a timer to delete old env post update for venv-minion - Added: * provide-systemd-timer-unit.patch OBS-URL: https://build.opensuse.org/request/show/1179004 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=244 --- _lastrevision | 2 +- provide-systemd-timer-unit.patch | 43 ++++++++++++++++++++++++++++++++ salt.changes | 8 ++++++ salt.spec | 2 ++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 provide-systemd-timer-unit.patch diff --git a/_lastrevision b/_lastrevision index 2652c56..266f848 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -365aa2dd170197cd849f08270e3bd2376cd79be9 \ No newline at end of file +b64e3926ce9b365b4416429e48b567f34a5b818f \ No newline at end of file diff --git a/provide-systemd-timer-unit.patch b/provide-systemd-timer-unit.patch new file mode 100644 index 0000000..d6162ac --- /dev/null +++ b/provide-systemd-timer-unit.patch @@ -0,0 +1,43 @@ +From e3809178f7f6db4b0a5dcca48441100cec45c69d Mon Sep 17 00:00:00 2001 +From: Marek Czernek +Date: Thu, 6 Jun 2024 10:11:26 +0200 +Subject: [PATCH] Provide systemd timer unit + +--- + pkg/common/venv-salt-minion-postinstall.service | 7 +++++++ + pkg/common/venv-salt-minion-postinstall.timer | 9 +++++++++ + 2 files changed, 16 insertions(+) + create mode 100644 pkg/common/venv-salt-minion-postinstall.service + create mode 100644 pkg/common/venv-salt-minion-postinstall.timer + +diff --git a/pkg/common/venv-salt-minion-postinstall.service b/pkg/common/venv-salt-minion-postinstall.service +new file mode 100644 +index 00000000000..b122d7d6eab +--- /dev/null ++++ b/pkg/common/venv-salt-minion-postinstall.service +@@ -0,0 +1,7 @@ ++[Unit] ++Description=Clean old environment for venv-salt-minion ++ ++[Service] ++ExecStart=/bin/sh -c '/usr/lib/venv-salt-minion/bin/post_start_cleanup.sh || :' ++Type=oneshot ++ +diff --git a/pkg/common/venv-salt-minion-postinstall.timer b/pkg/common/venv-salt-minion-postinstall.timer +new file mode 100644 +index 00000000000..e6bd86d86e7 +--- /dev/null ++++ b/pkg/common/venv-salt-minion-postinstall.timer +@@ -0,0 +1,9 @@ ++[Unit] ++Description=Clean old venv-salt-minion environment in 60 seconds ++ ++[Timer] ++OnActiveSec=60 ++ ++[Install] ++WantedBy=timers.target ++ +-- +2.45.1 + diff --git a/salt.changes b/salt.changes index 89f0333..88e3320 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Jun 6 08:41:14 UTC 2024 - Marek Czernek + +- Add a timer to delete old env post update for venv-minion + +- Added: + * provide-systemd-timer-unit.patch + ------------------------------------------------------------------- Mon May 27 11:07:26 UTC 2024 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index 5ecdc12..269b142 100644 --- a/salt.spec +++ b/salt.spec @@ -396,6 +396,8 @@ Patch117: do-not-call-the-async-wrapper-calls-with-the-separat.patch Patch118: speed-up-salt.matcher.confirm_top-by-using-__context.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66593 Patch119: several-fixes-for-tests-to-avoid-errors-and-failures.patch +# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/656 +Patch120: provide-systemd-timer-unit.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END From fdd77ed694b8b90aaab26835ce945e7b1020e871bc9ec8e04557593716b2629a Mon Sep 17 00:00:00 2001 From: Marek Czernek Date: Wed, 12 Jun 2024 14:54:52 +0000 Subject: [PATCH 2/2] - Skip certain tests if necessary for some OSes and set flaky ones - Added: * skip-certain-tests-if-necessary-and-mark-some-flaky-.patch OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=245 --- _lastrevision | 2 +- salt.changes | 8 + salt.spec | 2 + ...ts-if-necessary-and-mark-some-flaky-.patch | 392 ++++++++++++++++++ 4 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 skip-certain-tests-if-necessary-and-mark-some-flaky-.patch diff --git a/_lastrevision b/_lastrevision index 266f848..4aac06a 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -b64e3926ce9b365b4416429e48b567f34a5b818f \ No newline at end of file +1eb7b9e2177458d1bd4b32462af85ea0e3f7b072 \ No newline at end of file diff --git a/salt.changes b/salt.changes index 88e3320..9b22782 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Jun 12 08:44:38 UTC 2024 - Pablo Suárez Hernández + +- Skip certain tests if necessary for some OSes and set flaky ones + +- Added: + * skip-certain-tests-if-necessary-and-mark-some-flaky-.patch + ------------------------------------------------------------------- Thu Jun 6 08:41:14 UTC 2024 - Marek Czernek diff --git a/salt.spec b/salt.spec index 269b142..0a1b61f 100644 --- a/salt.spec +++ b/salt.spec @@ -398,6 +398,8 @@ Patch118: speed-up-salt.matcher.confirm_top-by-using-__context.patch Patch119: several-fixes-for-tests-to-avoid-errors-and-failures.patch # PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/656 Patch120: provide-systemd-timer-unit.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66630 +Patch121: skip-certain-tests-if-necessary-and-mark-some-flaky-.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END diff --git a/skip-certain-tests-if-necessary-and-mark-some-flaky-.patch b/skip-certain-tests-if-necessary-and-mark-some-flaky-.patch new file mode 100644 index 0000000..1e5a5e7 --- /dev/null +++ b/skip-certain-tests-if-necessary-and-mark-some-flaky-.patch @@ -0,0 +1,392 @@ +From c02adf9e721dbebf0b50f202d2e86723e5642514 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= + +Date: Wed, 12 Jun 2024 09:38:43 +0100 +Subject: [PATCH] Skip certain tests if necessary and mark some flaky + ones (#657) + +* Small alignments with upstream + +* Skip tests if necessary and mark some flaky ones + +* Add extra flaky test +--- + tests/integration/modules/test_status.py | 1 + + tests/pytests/functional/cache/test_consul.py | 7 +------ + tests/pytests/functional/cache/test_mysql.py | 6 +++--- + tests/pytests/functional/modules/state/test_state.py | 3 +++ + tests/pytests/functional/modules/test_pkg.py | 8 ++++++++ + .../pytests/functional/modules/test_virtualenv_mod.py | 5 +++++ + tests/pytests/functional/states/file/test_managed.py | 2 +- + tests/pytests/functional/states/pkgrepo/test_suse.py | 10 ++++++++++ + .../functional/states/test_docker_container.py | 7 +++++++ + tests/pytests/functional/states/test_npm.py | 5 +++++ + tests/pytests/functional/states/test_pip_state.py | 4 ++++ + tests/pytests/functional/states/test_user.py | 11 ++++++++++- + tests/pytests/integration/cli/test_syndic_eauth.py | 2 -- + tests/pytests/integration/daemons/test_memory_leak.py | 2 +- + tests/support/pytest/mysql.py | 8 ++++++++ + 15 files changed, 67 insertions(+), 14 deletions(-) + +diff --git a/tests/integration/modules/test_status.py b/tests/integration/modules/test_status.py +index 73ce4817e82..a7265672ebe 100644 +--- a/tests/integration/modules/test_status.py ++++ b/tests/integration/modules/test_status.py +@@ -44,6 +44,7 @@ class StatusModuleTest(ModuleCase): + self.assertTrue(isinstance(ret, int)) + + @pytest.mark.slow_test ++ @pytest.mark.flaky(max_runs=4) + def test_status_diskusage(self): + """ + status.diskusage +diff --git a/tests/pytests/functional/cache/test_consul.py b/tests/pytests/functional/cache/test_consul.py +index 996a1e932b6..19ad6f4aae0 100644 +--- a/tests/pytests/functional/cache/test_consul.py ++++ b/tests/pytests/functional/cache/test_consul.py +@@ -8,14 +8,13 @@ from saltfactories.utils import random_string + + import salt.cache + import salt.loader +-from salt.utils.versions import Version + from tests.pytests.functional.cache.helpers import run_common_cache_tests + + pytest.importorskip( + "consul", + reason="Please install python-consul package to use consul data cache driver", + ) +-docker = pytest.importorskip("docker") ++docker = pytest.importorskip("docker", minversion="4.0.0") + + log = logging.getLogger(__name__) + +@@ -25,10 +24,6 @@ pytestmark = [ + pytest.mark.slow_test, + pytest.mark.skip_if_binaries_missing("dockerd"), + pytest.mark.skipif(INSIDE_CONTAINER, reason="Cannot run in a container"), +- pytest.mark.skipif( +- Version(docker.__version__) < Version("4.0.0"), +- reason="Test does not work in this version of docker-py", +- ), + ] + + +diff --git a/tests/pytests/functional/cache/test_mysql.py b/tests/pytests/functional/cache/test_mysql.py +index 93c6c7c6f6f..6cf3cc49534 100644 +--- a/tests/pytests/functional/cache/test_mysql.py ++++ b/tests/pytests/functional/cache/test_mysql.py +@@ -5,11 +5,12 @@ import pytest + + import salt.cache + import salt.loader ++import salt.modules.mysql + from salt.utils.versions import Version + from tests.pytests.functional.cache.helpers import run_common_cache_tests + from tests.support.pytest.mysql import * # pylint: disable=wildcard-import,unused-wildcard-import + +-docker = pytest.importorskip("docker") ++pytest.importorskip("docker", minversion="4.0.0") + + log = logging.getLogger(__name__) + +@@ -20,8 +21,7 @@ pytestmark = [ + pytest.mark.skip_if_binaries_missing("dockerd"), + pytest.mark.skipif(INSIDE_CONTAINER, reason="Cannot run in a container"), + pytest.mark.skipif( +- Version(docker.__version__) < Version("4.0.0"), +- reason="Test does not work in this version of docker-py", ++ not salt.modules.mysql.MySQLdb, reason="Missing python MySQLdb library" + ), + ] + +diff --git a/tests/pytests/functional/modules/state/test_state.py b/tests/pytests/functional/modules/state/test_state.py +index 7640afaa882..57aa53001ab 100644 +--- a/tests/pytests/functional/modules/state/test_state.py ++++ b/tests/pytests/functional/modules/state/test_state.py +@@ -714,6 +714,7 @@ def test_retry_option_success(state, state_tree, tmp_path): + @pytest.mark.skip_on_windows( + reason="Skipped until parallel states can be fixed on Windows" + ) ++@pytest.mark.xfail(reason="This test is flaky") + def test_retry_option_success_parallel(state, state_tree, tmp_path): + """ + test a state with the retry option that should return True immediately (i.e. no retries) +@@ -753,6 +754,7 @@ def test_retry_option_success_parallel(state, state_tree, tmp_path): + + + @pytest.mark.slow_test ++@pytest.mark.xfail(reason="This test is flaky") + def test_retry_option_eventual_success(state, state_tree, tmp_path): + """ + test a state with the retry option that should return True, eventually +@@ -801,6 +803,7 @@ def test_retry_option_eventual_success(state, state_tree, tmp_path): + reason="Skipped until parallel states can be fixed on Windows" + ) + @pytest.mark.slow_test ++@pytest.mark.xfail(reason="This test is flaky") + def test_retry_option_eventual_success_parallel(state, state_tree, tmp_path): + """ + test a state with the retry option that should return True, eventually +diff --git a/tests/pytests/functional/modules/test_pkg.py b/tests/pytests/functional/modules/test_pkg.py +index 7cedd32bf6c..82d0801965d 100644 +--- a/tests/pytests/functional/modules/test_pkg.py ++++ b/tests/pytests/functional/modules/test_pkg.py +@@ -232,6 +232,10 @@ def test_which(modules): + @pytest.mark.requires_salt_modules("pkg.version", "pkg.install", "pkg.remove") + @pytest.mark.slow_test + @pytest.mark.requires_network ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_install_remove(modules, test_pkg, refresh_db): + """ + successfully install and uninstall a package +@@ -272,6 +276,10 @@ def test_install_remove(modules, test_pkg, refresh_db): + @pytest.mark.slow_test + @pytest.mark.requires_network + @pytest.mark.requires_salt_states("pkg.installed") ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_hold_unhold(grains, modules, states, test_pkg, refresh_db): + """ + test holding and unholding a package +diff --git a/tests/pytests/functional/modules/test_virtualenv_mod.py b/tests/pytests/functional/modules/test_virtualenv_mod.py +index 7d8398e149b..2b6abf91e23 100644 +--- a/tests/pytests/functional/modules/test_virtualenv_mod.py ++++ b/tests/pytests/functional/modules/test_virtualenv_mod.py +@@ -2,6 +2,7 @@ import shutil + + import pytest + ++import salt.utils.path + from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES + + pytestmark = [ +@@ -63,6 +64,10 @@ def test_clear(virtualenv, venv_dir, modules): + assert "pep8" not in packages + + ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_virtualenv_ver(virtualenv, venv_dir): + ret = virtualenv.create(str(venv_dir)) + assert ret +diff --git a/tests/pytests/functional/states/file/test_managed.py b/tests/pytests/functional/states/file/test_managed.py +index 9678fb63432..1b904c33543 100644 +--- a/tests/pytests/functional/states/file/test_managed.py ++++ b/tests/pytests/functional/states/file/test_managed.py +@@ -658,7 +658,6 @@ def test_issue_8947_utf8_sls(modules, tmp_path, state_tree, subtests): + @pytest.mark.skip_if_not_root + @pytest.mark.skip_on_windows(reason="Windows does not support setuid. Skipping.") + def test_owner_after_setuid(file, modules, tmp_path, state_file_account): +- + """ + Test to check file user/group after setting setuid or setgid. + Because Python os.chown() does reset the setuid/setgid to 0. +@@ -767,6 +766,7 @@ def test_file_managed_keep_source_false_http( + + + @pytest.mark.parametrize("verify_ssl", [True, False]) ++@pytest.mark.flaky(max_runs=4) + def test_verify_ssl_https_source(file, tmp_path, ssl_webserver, verify_ssl): + """ + test verify_ssl when its False and True when managing +diff --git a/tests/pytests/functional/states/pkgrepo/test_suse.py b/tests/pytests/functional/states/pkgrepo/test_suse.py +index 19ba928ce6e..3bafeedc941 100644 +--- a/tests/pytests/functional/states/pkgrepo/test_suse.py ++++ b/tests/pytests/functional/states/pkgrepo/test_suse.py +@@ -1,5 +1,7 @@ + import pytest + ++import salt.utils.path ++ + pytestmark = [ + pytest.mark.destructive_test, + pytest.mark.skip_if_not_root, +@@ -80,6 +82,10 @@ def suse_state_tree(grains, pkgrepo, state_tree): + + + @pytest.mark.requires_salt_states("pkgrepo.managed", "pkgrepo.absent") ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_pkgrepo_managed_absent(grains, modules, subtests, suse_state_tree): + """ + Test adding and removing a repository +@@ -134,6 +140,10 @@ def test_pkgrepo_managed_absent(grains, modules, subtests, suse_state_tree): + + + @pytest.mark.requires_salt_states("pkgrepo.managed") ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_pkgrepo_managed_modify(grains, modules, subtests, suse_state_tree): + """ + Test adding and modifying a repository +diff --git a/tests/pytests/functional/states/test_docker_container.py b/tests/pytests/functional/states/test_docker_container.py +index 2267399891e..539a2acbf1a 100644 +--- a/tests/pytests/functional/states/test_docker_container.py ++++ b/tests/pytests/functional/states/test_docker_container.py +@@ -26,6 +26,7 @@ pytestmark = [ + pytest.mark.slow_test, + pytest.mark.skip_on_freebsd(reason="No Docker on FreeBSD available"), + pytest.mark.skip_if_binaries_missing("busybox", reason="Busybox not installed"), ++ pytest.mark.skip_if_binaries_missing("ldd", reason="ldd is missing"), + pytest.mark.skip_if_binaries_missing( + "docker", "dockerd", reason="Docker not installed" + ), +@@ -172,6 +173,12 @@ def image(tmp_path_factory): + # Somehow the above skip_if_binaries_missing marker for docker + # only get's evaluated after this fixture?!? + pytest.skip("The `docker` binary is not available") ++ if not salt.modules.cmdmod.retcode( ++ "ldd {}".format(salt.utils.path.which("busybox")) ++ ): ++ pytest.skip( ++ "`busybox` appears to be a dynamic executable, please use busybox-static" ++ ) + container_build_dir = tmp_path_factory.mktemp("busybox") + image_name = random_string("salt-busybox-", uppercase=False) + +diff --git a/tests/pytests/functional/states/test_npm.py b/tests/pytests/functional/states/test_npm.py +index 2899b7985a1..54db6042716 100644 +--- a/tests/pytests/functional/states/test_npm.py ++++ b/tests/pytests/functional/states/test_npm.py +@@ -3,6 +3,7 @@ import shutil + + import pytest + ++import salt.utils.path + from salt.exceptions import CommandExecutionError + from salt.utils.versions import Version + +@@ -10,6 +11,10 @@ pytestmark = [ + pytest.mark.slow_test, + pytest.mark.destructive_test, + pytest.mark.requires_network, ++ pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++ ), + ] + + MAX_NPM_VERSION = "5.0.0" +diff --git a/tests/pytests/functional/states/test_pip_state.py b/tests/pytests/functional/states/test_pip_state.py +index 1921751b5dc..1f2080f1f86 100644 +--- a/tests/pytests/functional/states/test_pip_state.py ++++ b/tests/pytests/functional/states/test_pip_state.py +@@ -80,6 +80,10 @@ def create_virtualenv(modules): + + + @pytest.mark.slow_test ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_pip_installed_removed(modules, states): + """ + Tests installed and removed states +diff --git a/tests/pytests/functional/states/test_user.py b/tests/pytests/functional/states/test_user.py +index 96b1ec55c88..5eac093ef44 100644 +--- a/tests/pytests/functional/states/test_user.py ++++ b/tests/pytests/functional/states/test_user.py +@@ -13,6 +13,7 @@ import pytest + from saltfactories.utils import random_string + + import salt.utils.files ++import salt.utils.path + import salt.utils.platform + + try: +@@ -137,7 +138,7 @@ def test_user_present_nondefault(grains, modules, states, username, user_home): + if not salt.utils.platform.is_darwin() and not salt.utils.platform.is_windows(): + assert user_home.is_dir() + +- if grains["os_family"] in ("Suse",): ++ if grains["os_family"] in ("Suse",) and not grains.get("transactional", False): + expected_group_name = "users" + elif grains["os_family"] == "MacOS": + expected_group_name = "staff" +@@ -380,6 +381,10 @@ def test_user_present_existing(states, username): + + + @pytest.mark.skip_unless_on_linux(reason="underlying functionality only runs on Linux") ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_user_present_change_groups(modules, states, username, group_1, group_2): + ret = states.user.present( + name=username, +@@ -404,6 +409,10 @@ def test_user_present_change_groups(modules, states, username, group_1, group_2) + + + @pytest.mark.skip_unless_on_linux(reason="underlying functionality only runs on Linux") ++@pytest.mark.skipif( ++ bool(salt.utils.path.which("transactional-update")), ++ reason="Skipping on transactional systems", ++) + def test_user_present_change_optional_groups( + modules, states, username, group_1, group_2 + ): +diff --git a/tests/pytests/integration/cli/test_syndic_eauth.py b/tests/pytests/integration/cli/test_syndic_eauth.py +index 8dcdd3fbd28..dde4c25bc91 100644 +--- a/tests/pytests/integration/cli/test_syndic_eauth.py ++++ b/tests/pytests/integration/cli/test_syndic_eauth.py +@@ -6,8 +6,6 @@ import time + + import pytest + +-from tests.conftest import CODE_DIR +- + docker = pytest.importorskip("docker", minversion="4.0.0") + + INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container" +diff --git a/tests/pytests/integration/daemons/test_memory_leak.py b/tests/pytests/integration/daemons/test_memory_leak.py +index f2c5307f1a5..869ce72f588 100644 +--- a/tests/pytests/integration/daemons/test_memory_leak.py ++++ b/tests/pytests/integration/daemons/test_memory_leak.py +@@ -49,7 +49,7 @@ def file_add_delete_sls(testfile_path, base_env_state_tree_root_dir): + + @pytest.mark.skip_on_darwin(reason="MacOS is a spawning platform, won't work") + @pytest.mark.skipif(GITHUB_ACTIONS, reason="Test is failing in GitHub Actions") +-@pytest.mark.flaky(max_runs=10) ++@pytest.mark.xfail(reason="This test is flaky") + def test_memory_leak(salt_cli, salt_minion, file_add_delete_sls): + max_usg = None + +diff --git a/tests/support/pytest/mysql.py b/tests/support/pytest/mysql.py +index 218c38686e7..6195d53d212 100644 +--- a/tests/support/pytest/mysql.py ++++ b/tests/support/pytest/mysql.py +@@ -5,11 +5,19 @@ import attr + import pytest + from saltfactories.utils import random_string + ++import salt.modules.mysql ++ + # This `pytest.importorskip` here actually works because this module + # is imported into test modules, otherwise, the skipping would just fail + pytest.importorskip("docker") + import docker.errors # isort:skip pylint: disable=3rd-party-module-not-gated + ++pytestmark = [ ++ pytest.mark.skipif( ++ not salt.modules.mysql.MySQLdb, reason="Missing python MySQLdb library" ++ ) ++] ++ + log = logging.getLogger(__name__) + + +-- +2.44.0 + +