Sync from SUSE:SLFO:Main salt revision 3b605b96dea0e5c9ae566562f96f1fab

This commit is contained in:
Adrian Schröter 2024-06-08 17:40:14 +02:00
parent b96fd517e4
commit 6bb0bf561e
11 changed files with 7871 additions and 36 deletions

View File

@ -1 +1 @@
d0c2f35ff4a0b21786b20c884cbb191ad2e63904 6f191fc01de41fe2c1c4b659d5738e80aeb89b4c

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<flavor>testsuite</flavor>
</multibuild>

View File

@ -0,0 +1,80 @@
From 45b97042766e15a4336b141b40a03d68156771bc Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
Date: Thu, 14 Mar 2024 16:16:02 +0100
Subject: [PATCH] Decode oscap byte stream to string (bsc#1219001)
---
salt/modules/openscap.py | 5 +++--
tests/unit/modules/test_openscap.py | 10 +++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py
index 216fd89eef..89712ae722 100644
--- a/salt/modules/openscap.py
+++ b/salt/modules/openscap.py
@@ -152,10 +152,11 @@ def xccdf_eval(xccdffile, ovalfiles=None, **kwargs):
if success:
tempdir = tempfile.mkdtemp()
proc = Popen(cmd_opts, stdout=PIPE, stderr=PIPE, cwd=tempdir)
- (stdoutdata, error) = proc.communicate()
+ (_, error) = proc.communicate()
+ error = error.decode('ascii', errors='ignore')
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
- error += "\nKilled by signal {}\n".format(proc.returncode).encode('ascii')
+ error += "\nKilled by signal {}\n".format(proc.returncode)
returncode = proc.returncode
if success:
__salt__["cp.push_dir"](tempdir)
diff --git a/tests/unit/modules/test_openscap.py b/tests/unit/modules/test_openscap.py
index 301c1869ec..6fbdfed7cf 100644
--- a/tests/unit/modules/test_openscap.py
+++ b/tests/unit/modules/test_openscap.py
@@ -218,7 +218,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 0, "communicate.return_value": ("", "")}
+ **{"returncode": 0, "communicate.return_value": (bytes(0), bytes(0))}
)
),
):
@@ -269,7 +269,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 0, "communicate.return_value": ("", "")}
+ **{"returncode": 0, "communicate.return_value": (bytes(0), bytes(0))}
)
),
):
@@ -323,7 +323,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 2, "communicate.return_value": ("", "some error")}
+ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))}
)
),
):
@@ -374,7 +374,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 2, "communicate.return_value": ("", "some error")}
+ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))}
)
),
):
@@ -423,7 +423,7 @@ class OpenscapTestCase(TestCase):
return_value=Mock(
**{
"returncode": 1,
- "communicate.return_value": ("", "evaluation error"),
+ "communicate.return_value": (bytes(0), bytes("evaluation error", "UTF-8")),
}
)
),
--
2.43.0

View File

@ -0,0 +1,188 @@
From 05fbd376090c5d7f997c510db0abb62be54d6d40 Mon Sep 17 00:00:00 2001
From: Johannes Hahn <johannes.hahn@suse.com>
Date: Tue, 20 Feb 2024 15:38:08 +0100
Subject: [PATCH] Discover both *.yml and *.yaml playbooks (bsc#1211888)
Allow for 'playbook_extension' to be either a string or a tuple and
change the default behavior to discover both.
---
changelog/66048.changed.md | 1 +
salt/modules/ansiblegate.py | 46 +++++++++----------
.../pytests/unit/modules/test_ansiblegate.py | 3 ++
.../example_playbooks/playbook1.yaml | 5 ++
4 files changed, 30 insertions(+), 25 deletions(-)
create mode 100644 changelog/66048.changed.md
create mode 100644 tests/unit/files/playbooks/example_playbooks/playbook1.yaml
diff --git a/changelog/66048.changed.md b/changelog/66048.changed.md
new file mode 100644
index 0000000000..b042e0d313
--- /dev/null
+++ b/changelog/66048.changed.md
@@ -0,0 +1 @@
+Ansiblegate discover_playbooks was changed to find playbooks as either *.yml or *.yaml files
diff --git a/salt/modules/ansiblegate.py b/salt/modules/ansiblegate.py
index 2f60a7444f..920c374e5a 100644
--- a/salt/modules/ansiblegate.py
+++ b/salt/modules/ansiblegate.py
@@ -111,7 +111,7 @@ def __virtual__():
if proc.returncode != 0:
return (
False,
- "Failed to get the listing of ansible modules:\n{}".format(proc.stderr),
+ f"Failed to get the listing of ansible modules:\n{proc.stderr}",
)
module_funcs = dir(sys.modules[__name__])
@@ -240,7 +240,7 @@ def call(module, *args, **kwargs):
_kwargs = {k: v for (k, v) in kwargs.items() if not k.startswith("__pub")}
for key, value in _kwargs.items():
- module_args.append("{}={}".format(key, salt.utils.json.dumps(value)))
+ module_args.append(f"{key}={salt.utils.json.dumps(value)}")
with NamedTemporaryFile(mode="w") as inventory:
@@ -367,15 +367,15 @@ def playbooks(
if diff:
command.append("--diff")
if isinstance(extra_vars, dict):
- command.append("--extra-vars='{}'".format(json.dumps(extra_vars)))
+ command.append(f"--extra-vars='{json.dumps(extra_vars)}'")
elif isinstance(extra_vars, str) and extra_vars.startswith("@"):
- command.append("--extra-vars={}".format(extra_vars))
+ command.append(f"--extra-vars={extra_vars}")
if flush_cache:
command.append("--flush-cache")
if inventory:
- command.append("--inventory={}".format(inventory))
+ command.append(f"--inventory={inventory}")
if limit:
- command.append("--limit={}".format(limit))
+ command.append(f"--limit={limit}")
if list_hosts:
command.append("--list-hosts")
if list_tags:
@@ -383,25 +383,25 @@ def playbooks(
if list_tasks:
command.append("--list-tasks")
if module_path:
- command.append("--module-path={}".format(module_path))
+ command.append(f"--module-path={module_path}")
if skip_tags:
- command.append("--skip-tags={}".format(skip_tags))
+ command.append(f"--skip-tags={skip_tags}")
if start_at_task:
- command.append("--start-at-task={}".format(start_at_task))
+ command.append(f"--start-at-task={start_at_task}")
if syntax_check:
command.append("--syntax-check")
if tags:
- command.append("--tags={}".format(tags))
+ command.append(f"--tags={tags}")
if playbook_kwargs:
for key, value in playbook_kwargs.items():
key = key.replace("_", "-")
if value is True:
- command.append("--{}".format(key))
+ command.append(f"--{key}")
elif isinstance(value, str):
- command.append("--{}={}".format(key, value))
+ command.append(f"--{key}={value}")
elif isinstance(value, dict):
- command.append("--{}={}".format(key, json.dumps(value)))
- command.append("--forks={}".format(forks))
+ command.append(f"--{key}={json.dumps(value)}")
+ command.append(f"--forks={forks}")
cmd_kwargs = {
"env": {
"ANSIBLE_STDOUT_CALLBACK": "json",
@@ -502,7 +502,7 @@ def discover_playbooks(
List of paths to discover playbooks from.
:param playbook_extension:
- File extension of playbooks file to search for. Default: "yml"
+ File extension(s) of playbook files to search for, can be a string or tuple of strings. Default: (".yml", ".yaml")
:param hosts_filename:
Filename of custom playbook inventory to search for. Default: "hosts"
@@ -533,19 +533,17 @@ def discover_playbooks(
)
if not playbook_extension:
- playbook_extension = "yml"
+ playbook_extension = (".yml", ".yaml")
if not hosts_filename:
hosts_filename = "hosts"
if path:
if not os.path.isabs(path):
raise CommandExecutionError(
- "The given path is not an absolute path: {}".format(path)
+ f"The given path is not an absolute path: {path}"
)
if not os.path.isdir(path):
- raise CommandExecutionError(
- "The given path is not a directory: {}".format(path)
- )
+ raise CommandExecutionError(f"The given path is not a directory: {path}")
return {
path: _explore_path(path, playbook_extension, hosts_filename, syntax_check)
}
@@ -573,7 +571,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
# Check files in the given path
for _f in os.listdir(path):
_path = os.path.join(path, _f)
- if os.path.isfile(_path) and _path.endswith("." + playbook_extension):
+ if os.path.isfile(_path) and _path.endswith(playbook_extension):
ret[_f] = {"fullpath": _path}
# Check for custom inventory file
if os.path.isfile(os.path.join(path, hosts_filename)):
@@ -584,9 +582,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
# Check files in the 1st level of subdirectories
for _f2 in os.listdir(_path):
_path2 = os.path.join(_path, _f2)
- if os.path.isfile(_path2) and _path2.endswith(
- "." + playbook_extension
- ):
+ if os.path.isfile(_path2) and _path2.endswith(playbook_extension):
ret[os.path.join(_f, _f2)] = {"fullpath": _path2}
# Check for custom inventory file
if os.path.isfile(os.path.join(_path, hosts_filename)):
@@ -599,7 +595,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
)
except Exception as exc:
raise CommandExecutionError(
- "There was an exception while discovering playbooks: {}".format(exc)
+ f"There was an exception while discovering playbooks: {exc}"
)
# Run syntax check validation
diff --git a/tests/pytests/unit/modules/test_ansiblegate.py b/tests/pytests/unit/modules/test_ansiblegate.py
index 6201809c22..272da721bf 100644
--- a/tests/pytests/unit/modules/test_ansiblegate.py
+++ b/tests/pytests/unit/modules/test_ansiblegate.py
@@ -198,6 +198,9 @@ def test_ansible_discover_playbooks_single_path():
assert ret[playbooks_dir]["playbook1.yml"] == {
"fullpath": os.path.join(playbooks_dir, "playbook1.yml")
}
+ assert ret[playbooks_dir]["playbook1.yaml"] == {
+ "fullpath": os.path.join(playbooks_dir, "playbook1.yaml")
+ }
assert ret[playbooks_dir]["example-playbook2/site.yml"] == {
"fullpath": os.path.join(playbooks_dir, "example-playbook2/site.yml"),
"custom_inventory": os.path.join(playbooks_dir, "example-playbook2/hosts"),
diff --git a/tests/unit/files/playbooks/example_playbooks/playbook1.yaml b/tests/unit/files/playbooks/example_playbooks/playbook1.yaml
new file mode 100644
index 0000000000..e258a101e1
--- /dev/null
+++ b/tests/unit/files/playbooks/example_playbooks/playbook1.yaml
@@ -0,0 +1,5 @@
+---
+- hosts: all
+ gather_facts: false
+ tasks:
+ - ping:
--
2.43.1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,772 @@
From 737b0bd931c07239d50e7395eb7425c06f485848 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Thu, 14 Mar 2024 13:03:00 +0000
Subject: [PATCH] Fix tests failures and errors when detected on VM
execution from Salt Shaker (#636)
* test_chmod: fix test expectation
* test_pkg: Adjust package expectation for SUSE family
* test_docker_network: Skip non-supported operation for SUSE family
* Fix tests failing due wrong docker-py version
* test_version: skip test in packaged scenario when setup.py is missing
* Fix issue related to docker version used during testing
* Fix test errors when setup.py is not available
* test_loader: do not run if setup.py is missing
* test_install: Fix test errors when setup.py is not available
* test_master: use a right service name expected on SUSE family
* test_jinja_filters: prevent test failure when which binary is not available
* Prevent errors when x509 utils cannot be loaded
* test_thin: skip test if virtualenv binary is missing
---
tests/integration/pillar/test_git_pillar.py | 12 +++++++++++-
tests/pytests/functional/cache/test_consul.py | 5 +++++
tests/pytests/functional/cache/test_mysql.py | 5 +++++
tests/pytests/functional/loader/test_loader.py | 9 +++++++++
.../functional/modules/state/test_jinja_filters.py | 4 ++--
tests/pytests/functional/modules/test_cmdmod.py | 2 +-
tests/pytests/functional/modules/test_dockermod.py | 8 +++++++-
tests/pytests/functional/modules/test_pkg.py | 2 ++
tests/pytests/functional/modules/test_swarm.py | 6 +++++-
tests/pytests/functional/states/rabbitmq/conftest.py | 11 +++++++++++
.../functional/states/rabbitmq/test_cluster.py | 7 ++++++-
.../functional/states/rabbitmq/test_plugin.py | 8 +++++++-
.../functional/states/rabbitmq/test_policy.py | 7 ++++++-
.../functional/states/rabbitmq/test_upstream.py | 7 ++++++-
.../pytests/functional/states/rabbitmq/test_user.py | 7 ++++++-
.../pytests/functional/states/rabbitmq/test_vhost.py | 7 ++++++-
.../pytests/functional/states/test_docker_network.py | 7 ++++++-
tests/pytests/functional/states/test_pkg.py | 2 +-
tests/pytests/functional/test_version.py | 9 +++++++++
tests/pytests/integration/modules/test_virt.py | 5 +++++
tests/pytests/integration/modules/test_x509_v2.py | 2 +-
tests/pytests/integration/ssh/test_log.py | 7 ++++++-
tests/pytests/integration/ssh/test_master.py | 2 +-
tests/pytests/integration/ssh/test_py_versions.py | 7 ++++++-
tests/pytests/integration/ssh/test_ssh_setup.py | 7 ++++++-
tests/pytests/integration/states/test_x509_v2.py | 2 +-
tests/pytests/scenarios/setup/test_install.py | 8 ++++++++
tests/pytests/unit/modules/test_pip.py | 8 ++++++++
tests/pytests/unit/utils/test_x509.py | 3 ++-
tests/unit/states/test_pip_state.py | 6 ++++++
tests/unit/utils/test_thin.py | 3 +++
31 files changed, 164 insertions(+), 21 deletions(-)
diff --git a/tests/integration/pillar/test_git_pillar.py b/tests/integration/pillar/test_git_pillar.py
index 5b4cbda95c9..d56785f97c2 100644
--- a/tests/integration/pillar/test_git_pillar.py
+++ b/tests/integration/pillar/test_git_pillar.py
@@ -79,6 +79,7 @@ from salt.utils.gitfs import (
PYGIT2_VERSION,
FileserverConfigError,
)
+from salt.utils.versions import Version
from tests.support.gitfs import ( # pylint: disable=unused-import
PASSWORD,
USERNAME,
@@ -101,11 +102,20 @@ try:
except Exception: # pylint: disable=broad-except
HAS_PYGIT2 = False
+docker = pytest.importorskip("docker")
+
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
+
pytestmark = [
SKIP_INITIAL_PHOTONOS_FAILURES,
pytest.mark.skip_on_platforms(windows=True, darwin=True),
- pytest.mark.skipif(INSIDE_CONTAINER, reason="Communication problems between containers."),
+ pytest.mark.skipif(
+ INSIDE_CONTAINER, reason="Communication problems between containers."
+ ),
+ 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_consul.py b/tests/pytests/functional/cache/test_consul.py
index c6e16d2588e..30dc6925f26 100644
--- a/tests/pytests/functional/cache/test_consul.py
+++ b/tests/pytests/functional/cache/test_consul.py
@@ -8,6 +8,7 @@ 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
docker = pytest.importorskip("docker")
@@ -20,6 +21,10 @@ 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 e15fc732a4a..93c6c7c6f6f 100644
--- a/tests/pytests/functional/cache/test_mysql.py
+++ b/tests/pytests/functional/cache/test_mysql.py
@@ -5,6 +5,7 @@ import pytest
import salt.cache
import salt.loader
+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
@@ -18,6 +19,10 @@ 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/loader/test_loader.py b/tests/pytests/functional/loader/test_loader.py
index 963d33f59c3..e81ef126ca3 100644
--- a/tests/pytests/functional/loader/test_loader.py
+++ b/tests/pytests/functional/loader/test_loader.py
@@ -1,14 +1,23 @@
import json
+import os
import pytest
from salt.utils.versions import Version
from tests.support.helpers import SaltVirtualEnv
from tests.support.pytest.helpers import FakeSaltExtension
+from tests.support.runtests import RUNTIME_VARS
+
+MISSING_SETUP_PY_FILE = not os.path.exists(
+ os.path.join(RUNTIME_VARS.CODE_DIR, "setup.py")
+)
pytestmark = [
# These are slow because they create a virtualenv and install salt in it
pytest.mark.slow_test,
+ pytest.mark.skipif(
+ MISSING_SETUP_PY_FILE, reason="This test only work if setup.py is available"
+ ),
]
diff --git a/tests/pytests/functional/modules/state/test_jinja_filters.py b/tests/pytests/functional/modules/state/test_jinja_filters.py
index 220310aaaf0..cc8ffcb731b 100644
--- a/tests/pytests/functional/modules/state/test_jinja_filters.py
+++ b/tests/pytests/functional/modules/state/test_jinja_filters.py
@@ -798,9 +798,9 @@ def _filter_id(value):
),
Filter(
name="which",
- expected={"ret": salt.utils.path.which("which")},
+ expected={"ret": salt.utils.path.which("ls")},
sls="""
- {% set result = 'which' | which() %}
+ {% set result = 'ls' | which() %}
test:
module.run:
- name: test.echo
diff --git a/tests/pytests/functional/modules/test_cmdmod.py b/tests/pytests/functional/modules/test_cmdmod.py
index d30b474c6d2..adaf469c283 100644
--- a/tests/pytests/functional/modules/test_cmdmod.py
+++ b/tests/pytests/functional/modules/test_cmdmod.py
@@ -105,7 +105,7 @@ def test_run(cmdmod):
template="jinja",
python_shell=True,
)
- == "func-tests-minion"
+ == "func-tests-minion-opts"
)
assert cmdmod.run("grep f", stdin="one\ntwo\nthree\nfour\nfive\n") == "four\nfive"
assert cmdmod.run('echo "a=b" | sed -e s/=/:/g', python_shell=True) == "a:b"
diff --git a/tests/pytests/functional/modules/test_dockermod.py b/tests/pytests/functional/modules/test_dockermod.py
index a5b40869352..eb0cc20f9ff 100644
--- a/tests/pytests/functional/modules/test_dockermod.py
+++ b/tests/pytests/functional/modules/test_dockermod.py
@@ -8,7 +8,9 @@ import pytest
from saltfactories.utils import random_string
from saltfactories.utils.functional import StateResult
-pytest.importorskip("docker")
+from salt.utils.versions import Version
+
+docker = pytest.importorskip("docker")
log = logging.getLogger(__name__)
@@ -18,6 +20,10 @@ pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_binaries_missing("docker", "dockerd", check_all=False),
pytest.mark.skipif(INSIDE_CONTAINER, reason="Cannot run inside 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/modules/test_pkg.py b/tests/pytests/functional/modules/test_pkg.py
index 707361c227b..7cedd32bf6c 100644
--- a/tests/pytests/functional/modules/test_pkg.py
+++ b/tests/pytests/functional/modules/test_pkg.py
@@ -67,6 +67,8 @@ def test_pkg(grains):
_pkg = "units"
elif grains["os_family"] == "Debian":
_pkg = "ifenslave"
+ elif grains["os_family"] == "Suse":
+ _pkg = "wget"
return _pkg
diff --git a/tests/pytests/functional/modules/test_swarm.py b/tests/pytests/functional/modules/test_swarm.py
index 9dc70f5b3dc..fc3c2b739cd 100644
--- a/tests/pytests/functional/modules/test_swarm.py
+++ b/tests/pytests/functional/modules/test_swarm.py
@@ -20,7 +20,11 @@ pytest.importorskip("docker")
def docker_version(shell, grains):
ret = shell.run("docker", "--version")
assert ret.returncode == 0
- return salt.utils.versions.Version(ret.stdout.split(",")[0].split()[-1].strip())
+ # Example output:
+ # Docker version 24.0.7-ce, build 311b9ff0aa93
+ return salt.utils.versions.Version(
+ ret.stdout.split(",")[0].split()[-1].split("-")[0].strip()
+ )
@pytest.fixture
diff --git a/tests/pytests/functional/states/rabbitmq/conftest.py b/tests/pytests/functional/states/rabbitmq/conftest.py
index d8ccc1761b8..60f8206a088 100644
--- a/tests/pytests/functional/states/rabbitmq/conftest.py
+++ b/tests/pytests/functional/states/rabbitmq/conftest.py
@@ -5,8 +5,19 @@ import attr
import pytest
from saltfactories.utils import random_string
+from salt.utils.versions import Version
+
log = logging.getLogger(__name__)
+docker = pytest.importorskip("docker")
+
+pytestmark = [
+ pytest.mark.skipif(
+ Version(docker.__version__) < Version("4.0.0"),
+ reason="Test does not work in this version of docker-py",
+ ),
+]
+
@attr.s(kw_only=True, slots=True)
class RabbitMQImage:
diff --git a/tests/pytests/functional/states/rabbitmq/test_cluster.py b/tests/pytests/functional/states/rabbitmq/test_cluster.py
index 210b22a2360..df85f04f78d 100644
--- a/tests/pytests/functional/states/rabbitmq/test_cluster.py
+++ b/tests/pytests/functional/states/rabbitmq/test_cluster.py
@@ -9,8 +9,9 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_cluster as rabbitmq_cluster
+from salt.utils.versions import Version
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
log = logging.getLogger(__name__)
@@ -22,6 +23,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/rabbitmq/test_plugin.py b/tests/pytests/functional/states/rabbitmq/test_plugin.py
index f1191490536..6ed4cdc9238 100644
--- a/tests/pytests/functional/states/rabbitmq/test_plugin.py
+++ b/tests/pytests/functional/states/rabbitmq/test_plugin.py
@@ -9,11 +9,13 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_plugin as rabbitmq_plugin
+from salt.utils.versions import Version
from tests.support.mock import patch
log = logging.getLogger(__name__)
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
+
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -23,6 +25,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/rabbitmq/test_policy.py b/tests/pytests/functional/states/rabbitmq/test_policy.py
index 7ccf6a522e0..c648c9ff947 100644
--- a/tests/pytests/functional/states/rabbitmq/test_policy.py
+++ b/tests/pytests/functional/states/rabbitmq/test_policy.py
@@ -9,11 +9,12 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_policy as rabbitmq_policy
+from salt.utils.versions import Version
from tests.support.mock import MagicMock, patch
log = logging.getLogger(__name__)
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -23,6 +24,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/rabbitmq/test_upstream.py b/tests/pytests/functional/states/rabbitmq/test_upstream.py
index c7bcf3b0d44..0a9686d6948 100644
--- a/tests/pytests/functional/states/rabbitmq/test_upstream.py
+++ b/tests/pytests/functional/states/rabbitmq/test_upstream.py
@@ -9,10 +9,11 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_upstream as rabbitmq_upstream
+from salt.utils.versions import Version
log = logging.getLogger(__name__)
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -22,6 +23,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/rabbitmq/test_user.py b/tests/pytests/functional/states/rabbitmq/test_user.py
index 31723df7be8..a6b0766087f 100644
--- a/tests/pytests/functional/states/rabbitmq/test_user.py
+++ b/tests/pytests/functional/states/rabbitmq/test_user.py
@@ -9,10 +9,11 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_user as rabbitmq_user
+from salt.utils.versions import Version
log = logging.getLogger(__name__)
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -22,6 +23,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/rabbitmq/test_vhost.py b/tests/pytests/functional/states/rabbitmq/test_vhost.py
index d6ac6901a25..f3553c03e58 100644
--- a/tests/pytests/functional/states/rabbitmq/test_vhost.py
+++ b/tests/pytests/functional/states/rabbitmq/test_vhost.py
@@ -9,10 +9,11 @@ import pytest
import salt.modules.rabbitmq as rabbitmq
import salt.states.rabbitmq_vhost as rabbitmq_vhost
+from salt.utils.versions import Version
log = logging.getLogger(__name__)
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -22,6 +23,10 @@ pytestmark = [
"docker", "dockerd", reason="Docker not installed"
),
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/states/test_docker_network.py b/tests/pytests/functional/states/test_docker_network.py
index 0da01ed8bac..19868d03ad1 100644
--- a/tests/pytests/functional/states/test_docker_network.py
+++ b/tests/pytests/functional/states/test_docker_network.py
@@ -220,10 +220,15 @@ def test_present_with_containers(network, docker, docker_network, container):
@pytest.mark.parametrize("reconnect", [True, False])
-def test_present_with_reconnect(network, docker, docker_network, container, reconnect):
+def test_present_with_reconnect(
+ network, docker, docker_network, container, reconnect, grains
+):
"""
Test reconnecting with containers not passed to state
"""
+ if grains["os_family"] == "Suse":
+ pytest.skip("This test is failing for SUSE family")
+
with network() as net:
ret = docker_network.present(name=net.name, driver="bridge")
assert ret.result is True
diff --git a/tests/pytests/functional/states/test_pkg.py b/tests/pytests/functional/states/test_pkg.py
index 12318c996d1..864c1d025f3 100644
--- a/tests/pytests/functional/states/test_pkg.py
+++ b/tests/pytests/functional/states/test_pkg.py
@@ -55,7 +55,7 @@ def PKG_TARGETS(grains):
else:
_PKG_TARGETS = ["units", "zsh-html"]
elif grains["os_family"] == "Suse":
- _PKG_TARGETS = ["lynx", "htop"]
+ _PKG_TARGETS = ["iotop", "screen"]
return _PKG_TARGETS
diff --git a/tests/pytests/functional/test_version.py b/tests/pytests/functional/test_version.py
index dfa8850557e..3b85c05ccc6 100644
--- a/tests/pytests/functional/test_version.py
+++ b/tests/pytests/functional/test_version.py
@@ -1,14 +1,23 @@
import json
import logging
+import os
import pytest
from tests.support.helpers import SaltVirtualEnv
from tests.support.pytest.helpers import FakeSaltExtension
+from tests.support.runtests import RUNTIME_VARS
+
+MISSING_SETUP_PY_FILE = not os.path.exists(
+ os.path.join(RUNTIME_VARS.CODE_DIR, "setup.py")
+)
pytestmark = [
# These are slow because they create a virtualenv and install salt in it
pytest.mark.slow_test,
+ pytest.mark.skipif(
+ MISSING_SETUP_PY_FILE, reason="This test only work if setup.py is available"
+ ),
]
log = logging.getLogger(__name__)
diff --git a/tests/pytests/integration/modules/test_virt.py b/tests/pytests/integration/modules/test_virt.py
index 1b7f30154a7..572923764bb 100644
--- a/tests/pytests/integration/modules/test_virt.py
+++ b/tests/pytests/integration/modules/test_virt.py
@@ -9,6 +9,7 @@ from xml.etree import ElementTree
import pytest
import salt.version
+from salt.utils.versions import Version
from tests.support.virt import SaltVirtMinionContainerFactory
docker = pytest.importorskip("docker")
@@ -21,6 +22,10 @@ pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_binaries_missing("docker"),
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/integration/modules/test_x509_v2.py b/tests/pytests/integration/modules/test_x509_v2.py
index 2fd005778c5..cc8712e45cd 100644
--- a/tests/pytests/integration/modules/test_x509_v2.py
+++ b/tests/pytests/integration/modules/test_x509_v2.py
@@ -11,7 +11,7 @@ from pathlib import Path
import pytest
from saltfactories.utils import random_string
-import salt.utils.x509 as x509util
+x509util = pytest.importorskip("salt.utils.x509")
try:
import cryptography
diff --git a/tests/pytests/integration/ssh/test_log.py b/tests/pytests/integration/ssh/test_log.py
index 683feb8bd91..a63dd72373d 100644
--- a/tests/pytests/integration/ssh/test_log.py
+++ b/tests/pytests/integration/ssh/test_log.py
@@ -8,9 +8,10 @@ import time
import pytest
from saltfactories.utils import random_string
+from salt.utils.versions import Version
from tests.support.helpers import Keys
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -20,6 +21,10 @@ 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/integration/ssh/test_master.py b/tests/pytests/integration/ssh/test_master.py
index 0c2f482cf9f..c658123726b 100644
--- a/tests/pytests/integration/ssh/test_master.py
+++ b/tests/pytests/integration/ssh/test_master.py
@@ -23,7 +23,7 @@ def test_service(salt_ssh_cli, grains):
os_release = grains["osrelease"]
if os_family == "RedHat":
service = "crond"
- elif os_family == "Arch":
+ elif os_family in ["Suse", "Arch"]:
service = "sshd"
elif os_family == "MacOS":
service = "org.ntp.ntpd"
diff --git a/tests/pytests/integration/ssh/test_py_versions.py b/tests/pytests/integration/ssh/test_py_versions.py
index 71d4cfaa94e..991a3b71c44 100644
--- a/tests/pytests/integration/ssh/test_py_versions.py
+++ b/tests/pytests/integration/ssh/test_py_versions.py
@@ -9,9 +9,10 @@ import time
import pytest
from saltfactories.utils import random_string
+from salt.utils.versions import Version
from tests.support.helpers import Keys
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -21,6 +22,10 @@ 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/integration/ssh/test_ssh_setup.py b/tests/pytests/integration/ssh/test_ssh_setup.py
index 79b55ad90a5..97494bed36b 100644
--- a/tests/pytests/integration/ssh/test_ssh_setup.py
+++ b/tests/pytests/integration/ssh/test_ssh_setup.py
@@ -13,9 +13,10 @@ import pytest
from pytestshellutils.utils.processes import ProcessResult, terminate_process
from saltfactories.utils import random_string
+from salt.utils.versions import Version
from tests.support.helpers import Keys
-pytest.importorskip("docker")
+docker = pytest.importorskip("docker")
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
@@ -25,6 +26,10 @@ 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/integration/states/test_x509_v2.py b/tests/pytests/integration/states/test_x509_v2.py
index 9a1c09bb8bd..4f943412950 100644
--- a/tests/pytests/integration/states/test_x509_v2.py
+++ b/tests/pytests/integration/states/test_x509_v2.py
@@ -10,7 +10,7 @@ from pathlib import Path
import pytest
from saltfactories.utils import random_string
-import salt.utils.x509 as x509util
+x509util = pytest.importorskip("salt.utils.x509")
try:
import cryptography
diff --git a/tests/pytests/scenarios/setup/test_install.py b/tests/pytests/scenarios/setup/test_install.py
index 7664fda804e..7a4abfc6e9e 100644
--- a/tests/pytests/scenarios/setup/test_install.py
+++ b/tests/pytests/scenarios/setup/test_install.py
@@ -14,11 +14,16 @@ import salt.utils.path
import salt.utils.platform
import salt.version
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
+from tests.support.runtests import RUNTIME_VARS
log = logging.getLogger(__name__)
INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
+MISSING_SETUP_PY_FILE = not os.path.exists(
+ os.path.join(RUNTIME_VARS.CODE_DIR, "setup.py")
+)
+
pytestmark = [
pytest.mark.core_test,
pytest.mark.windows_whitelisted,
@@ -27,6 +32,9 @@ pytestmark = [
pytest.mark.skipif(
INSIDE_CONTAINER, reason="No gcc and python3-devel in container."
),
+ pytest.mark.skipif(
+ MISSING_SETUP_PY_FILE, reason="This test only work if setup.py is available"
+ ),
]
diff --git a/tests/pytests/unit/modules/test_pip.py b/tests/pytests/unit/modules/test_pip.py
index c03e6ed292b..4b2da77786b 100644
--- a/tests/pytests/unit/modules/test_pip.py
+++ b/tests/pytests/unit/modules/test_pip.py
@@ -9,6 +9,11 @@ import salt.utils.files
import salt.utils.platform
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, patch
+from tests.support.runtests import RUNTIME_VARS
+
+MISSING_SETUP_PY_FILE = not os.path.exists(
+ os.path.join(RUNTIME_VARS.CODE_DIR, "setup.py")
+)
class FakeFopen:
@@ -1738,6 +1743,9 @@ def test_when_version_is_called_with_a_user_it_should_be_passed_to_undelying_run
)
+@pytest.mark.skipif(
+ MISSING_SETUP_PY_FILE, reason="This test only work if setup.py is available"
+)
@pytest.mark.parametrize(
"bin_env,target,target_env,expected_target",
[
diff --git a/tests/pytests/unit/utils/test_x509.py b/tests/pytests/unit/utils/test_x509.py
index 25971af40d8..dade9eda46b 100644
--- a/tests/pytests/unit/utils/test_x509.py
+++ b/tests/pytests/unit/utils/test_x509.py
@@ -4,9 +4,10 @@ import ipaddress
import pytest
import salt.exceptions
-import salt.utils.x509 as x509
from tests.support.mock import ANY, Mock, patch
+x509 = pytest.importorskip("salt.utils.x509")
+
try:
import cryptography
import cryptography.x509 as cx509
diff --git a/tests/unit/states/test_pip_state.py b/tests/unit/states/test_pip_state.py
index 981ad46a135..d70b1150008 100644
--- a/tests/unit/states/test_pip_state.py
+++ b/tests/unit/states/test_pip_state.py
@@ -27,6 +27,9 @@ try:
except ImportError:
HAS_PIP = False
+MISSING_SETUP_PY_FILE = not os.path.exists(
+ os.path.join(RUNTIME_VARS.CODE_DIR, "setup.py")
+)
log = logging.getLogger(__name__)
@@ -408,6 +411,9 @@ class PipStateUtilsTest(TestCase):
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
@pytest.mark.requires_network
+@pytest.mark.skipif(
+ MISSING_SETUP_PY_FILE, reason="This test only work if setup.py is available"
+)
class PipStateInstallationErrorTest(TestCase):
@pytest.mark.slow_test
def test_importable_installation_error(self):
diff --git a/tests/unit/utils/test_thin.py b/tests/unit/utils/test_thin.py
index 7fd1e7b5dc3..c4e9c3b3bef 100644
--- a/tests/unit/utils/test_thin.py
+++ b/tests/unit/utils/test_thin.py
@@ -1379,6 +1379,9 @@ class SSHThinTestCase(TestCase):
assert [x for x in calls if "{}".format(_file) in x[-2]]
@pytest.mark.slow_test
+ @pytest.mark.skip_if_binaries_missing(
+ "virtualenv", reason="Needs virtualenv binary"
+ )
@pytest.mark.skip_on_windows(reason="salt-ssh does not deploy to/from windows")
def test_thin_dir(self):
"""
--
2.43.0

View File

@ -0,0 +1,63 @@
From 0913a58a36ef69d957dd9cc5c95fafe6d56448d5 Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
Date: Mon, 4 Mar 2024 11:27:35 +0100
Subject: [PATCH] Make importing seco.range thread safe (bsc#1211649)
---
salt/roster/range.py | 5 +++++
salt/utils/roster_matcher.py | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/salt/roster/range.py b/salt/roster/range.py
index 3f039dcef42..1525f70c32b 100644
--- a/salt/roster/range.py
+++ b/salt/roster/range.py
@@ -15,16 +15,21 @@ import copy
import fnmatch
import logging
+import salt.loader
+
log = logging.getLogger(__name__)
# Try to import range from https://github.com/ytoolshed/range
HAS_RANGE = False
try:
+ salt.loader.LOAD_LOCK.acquire()
import seco.range
HAS_RANGE = True
except ImportError:
log.error("Unable to load range library")
+finally:
+ salt.loader.LOAD_LOCK.release()
# pylint: enable=import-error
diff --git a/salt/utils/roster_matcher.py b/salt/utils/roster_matcher.py
index db5dfda3e03..5165dc122b7 100644
--- a/salt/utils/roster_matcher.py
+++ b/salt/utils/roster_matcher.py
@@ -8,14 +8,19 @@ import functools
import logging
import re
+import salt.loader
+
# Try to import range from https://github.com/ytoolshed/range
HAS_RANGE = False
try:
+ salt.loader.LOAD_LOCK.acquire()
import seco.range
HAS_RANGE = True
except ImportError:
pass
+finally:
+ salt.loader.LOAD_LOCK.release()
# pylint: enable=import-error
--
2.44.0

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Tue Apr 16 15:32:23 UTC 2024 - Yeray Gutiérrez Cedrés <yeray.gutierrez@suse.com>
- Convert oscap output to UTF-8
- Make Salt compatible with Python 3.11
- Ignore non-ascii chars in oscap output (bsc#1219001)
- Fix detected issues in Salt tests when running on VMs
- Make importing seco.range thread safe (bsc#1211649)
- Fix problematic tests and allow smooth tests executions on containers
- Discover Ansible playbook files as "*.yml" or "*.yaml" files (bsc#1211888)
- Provide user(salt)/group(salt) capabilities for RPM 4.19
- Extend dependencies for python3-salt-testsuite and python3-salt packages
- Improve Salt and testsuite packages multibuild
- Enable multibuilld and create test flavor
- Added:
* fix-tests-failures-and-errors-when-detected-on-vm-ex.patch
* decode-oscap-byte-stream-to-string-bsc-1219001.patch
* make-importing-seco.range-thread-safe-bsc-1211649.patch
* switch-oscap-encoding-to-utf-8-639.patch
* fix-salt-warnings-and-testuite-for-python-3.11-635.patch
* fix-problematic-tests-and-allow-smooth-tests-executi.patch
* discover-both-.yml-and-.yaml-playbooks-bsc-1211888.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Feb 1 14:48:40 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com> Thu Feb 1 14:48:40 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>

140
salt.spec
View File

@ -16,6 +16,13 @@
# #
%global debug_package %{nil} %global debug_package %{nil}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "testsuite"
%define psuffix -test
%else
%define psuffix %{nil}
%endif
%if 0%{?suse_version} > 1210 || 0%{?rhel} >= 7 || 0%{?fedora} >=28 %if 0%{?suse_version} > 1210 || 0%{?rhel} >= 7 || 0%{?fedora} >=28
%bcond_without systemd %bcond_without systemd
%else %else
@ -31,11 +38,10 @@
%bcond_with fish_completion %bcond_with fish_completion
%bcond_with zsh_completion %bcond_with zsh_completion
%endif %endif
%bcond_with test
%bcond_without docs %bcond_without docs
%bcond_with builddocs %bcond_with builddocs
Name: salt Name: salt%{psuffix}
Version: 3006.0 Version: 3006.0
Release: 0 Release: 0
Summary: A parallel remote execution system Summary: A parallel remote execution system
@ -343,7 +349,27 @@ Patch97: fixed-keyerror-in-logs-when-running-a-state-that-fai.patch
Patch98: improve-pip-target-override-condition-with-venv_pip_.patch Patch98: improve-pip-target-override-condition-with-venv_pip_.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/65819 # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/65819
Patch99: allow-kwargs-for-fileserver-roots-update-bsc-1218482.patch Patch99: allow-kwargs-for-fileserver-roots-update-bsc-1218482.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66048
Patch100: discover-both-.yml-and-.yaml-playbooks-bsc-1211888.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66130
Patch101: fix-problematic-tests-and-allow-smooth-tests-executi.patch
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/628
Patch102: make-importing-seco.range-thread-safe-bsc-1211649.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66130
PAtch103: fix-tests-failures-and-errors-when-detected-on-vm-ex.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66234 (modified at Patch106)
Patch104: decode-oscap-byte-stream-to-string-bsc-1219001.patch
### Commits to make Salt compatible with Python 3.11 (and 3.6)
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/d92b5423464f93da6e3feb47d05a9acef8da75f9
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/60b36489225f958772b6a2f99d8fe6ae33ee9d73
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/eee0eca5e48922e5e404f812ced08ca7484bb568
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/991f7cf0a7baf08a31194ce52f4ec08290db8e52
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/2688c86f45eea9f8a6b916fcdf8eb94b3f5e185b
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/a1873a1d6d50d1769ddef528d7442e38aba9de23
# PATCH-FIX_OPENSUSE https://github.com/openSUSE/salt/commit/c7ecccb0a080ca9cca097f760ef0992ab34f82df
Patch105: fix-salt-warnings-and-testuite-for-python-3.11-635.patch
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/639
Patch106: switch-oscap-encoding-to-utf-8-639.patch
### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
### SALT PATCHES LIST END ### SALT PATCHES LIST END
@ -359,6 +385,8 @@ Obsoletes: python2-%{name}
Requires(pre): %{_sbindir}/groupadd Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd Requires(pre): %{_sbindir}/useradd
Provides: user(salt)
Provides: group(salt)
%if 0%{?suse_version} %if 0%{?suse_version}
Requires(pre): %fillup_prereq Requires(pre): %fillup_prereq
@ -422,6 +450,8 @@ malleable. Salt accomplishes this via its ability to handle larger loads of
information, and not just dozens, but hundreds or even thousands of individual information, and not just dozens, but hundreds or even thousands of individual
servers, handle them quickly and through a simple and manageable interface. servers, handle them quickly and through a simple and manageable interface.
%if "%{flavor}" != "testsuite"
%package -n python3-salt %package -n python3-salt
Summary: python3 library for salt Summary: python3 library for salt
Group: System/Management Group: System/Management
@ -462,7 +492,7 @@ BuildRequires: python3-packaging
# requirements/zeromq.txt # requirements/zeromq.txt
%if %{with test} %if %{with test}
BuildRequires: python3-boto >= 2.32.1 BuildRequires: python3-boto >= 2.32.1
BuildRequires: python3-mock BuildRequires: %{python3-mock if %python-base < 3.8}
BuildRequires: python3-moto >= 0.3.6 BuildRequires: python3-moto >= 0.3.6
BuildRequires: python3-pip BuildRequires: python3-pip
BuildRequires: python3-salt-testing >= 2015.2.16 BuildRequires: python3-salt-testing >= 2015.2.16
@ -531,6 +561,12 @@ Recommends: python3-netaddr
Recommends: python3-pyinotify Recommends: python3-pyinotify
%endif %endif
# Required by Salt modules
Requires: iputils
Requires: sudo
Requires: file
Requires: man
Provides: bundled(python3-tornado) = 4.5.3 Provides: bundled(python3-tornado) = 4.5.3
%description -n python3-salt %description -n python3-salt
@ -699,31 +735,6 @@ Requires(pre): %fillup_prereq
Salt ssh is a master running without zmq. Salt ssh is a master running without zmq.
it enables the management of minions over a ssh connection. it enables the management of minions over a ssh connection.
%package -n python3-salt-testsuite
Summary: Unit and integration tests for Salt
Requires: %{name} = %{version}-%{release}
Requires: python3-CherryPy
Requires: python3-Genshi
Requires: python3-Mako
%if !0%{?suse_version} > 1600 || 0%{?centos}
Requires: python3-boto
%endif
Requires: python3-boto3
Requires: python3-docker
Requires: python3-mock
Requires: python3-pygit2
Requires: python3-pytest >= 7.0.1
Requires: python3-pytest-httpserver
Requires: python3-pytest-salt-factories >= 1.0.0~rc21
Requires: python3-pytest-subtests
Requires: python3-testinfra
Requires: python3-yamllint
Obsoletes: %{name}-tests
%description -n python3-salt-testsuite
Collection of unit, functional, and integration tests for %{name}.
%if %{with bash_completion} %if %{with bash_completion}
%package bash-completion %package bash-completion
Summary: Bash Completion for %{name} Summary: Bash Completion for %{name}
@ -790,6 +801,51 @@ For transactional systems, like MicroOS, Salt can operate
transparently if the executor "transactional-update" is registered in transparently if the executor "transactional-update" is registered in
list of active executors. This package add the configuration file. list of active executors. This package add the configuration file.
%endif
%if "%{flavor}" == "testsuite"
%package -n python3-salt-testsuite
Summary: Unit and integration tests for Salt
%if 0%{?rhel} == 8
BuildRequires: platform-python
%else
BuildRequires: python3
%endif
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: salt = %{version}
Requires: python3-CherryPy
Requires: python3-Genshi
Requires: python3-Mako
%if !0%{?suse_version} > 1600 || 0%{?centos}
Requires: python3-boto
%endif
Requires: python3-boto3
Requires: python3-docker
%if 0%{?suse_version} < 1600
Requires: python3-mock
%endif
Requires: python3-pygit2
Requires: python3-pytest >= 7.0.1
Requires: python3-pytest-httpserver
Requires: python3-pytest-salt-factories >= 1.0.0~rc21
Requires: python3-pytest-subtests
Requires: python3-testinfra
Requires: python3-yamllint
Requires: python3-pip
Requires: docker
Requires: openssh
Requires: git
Obsoletes: %{name}-tests
%description -n python3-salt-testsuite
Collection of unit, functional, and integration tests for %{name}.
%endif
%prep %prep
%setup -q -n salt-%{version}-suse %setup -q -n salt-%{version}-suse
@ -799,6 +855,8 @@ cp %{S:6} .
%autopatch -p1 %autopatch -p1
%build %build
%if "%{flavor}" != "testsuite"
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this # Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
# change, the RPM will require /bin/python, which is not provided by any package # change, the RPM will require /bin/python, which is not provided by any package
# on RHEL/RES 7. # on RHEL/RES 7.
@ -821,7 +879,11 @@ popd
cd doc && make html && rm _build/html/.buildinfo && rm _build/html/_images/proxy_minions.png && cd _build/html && chmod -R -x+X * cd doc && make html && rm _build/html/.buildinfo && rm _build/html/_images/proxy_minions.png && cd _build/html && chmod -R -x+X *
%endif %endif
%endif
%install %install
%if "%{flavor}" != "testsuite"
mv _build.python3 build mv _build.python3 build
python3 setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot} python3 setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot}
mv build _build.python3 mv build _build.python3
@ -869,6 +931,9 @@ install -Dd -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d/
# Install salt-support profiles # Install salt-support profiles
install -Dpm 0644 salt/cli/support/profiles/* %{buildroot}%{python3_sitelib}/salt/cli/support/profiles install -Dpm 0644 salt/cli/support/profiles/* %{buildroot}%{python3_sitelib}/salt/cli/support/profiles
%endif
%if "%{flavor}" == "testsuite"
# Install Salt tests # Install Salt tests
install -Dd %{buildroot}%{python3_sitelib}/salt-testsuite install -Dd %{buildroot}%{python3_sitelib}/salt-testsuite
cp -a tests %{buildroot}%{python3_sitelib}/salt-testsuite/ cp -a tests %{buildroot}%{python3_sitelib}/salt-testsuite/
@ -876,6 +941,9 @@ cp -a tests %{buildroot}%{python3_sitelib}/salt-testsuite/
rm %{buildroot}%{python3_sitelib}/salt-testsuite/tests/runtests.py rm %{buildroot}%{python3_sitelib}/salt-testsuite/tests/runtests.py
# Copy conf files to the testsuite as they are used by the tests # Copy conf files to the testsuite as they are used by the tests
cp -a conf %{buildroot}%{python3_sitelib}/salt-testsuite/ cp -a conf %{buildroot}%{python3_sitelib}/salt-testsuite/
%endif
%if "%{flavor}" != "testsuite"
## Install Zypper plugins only on SUSE machines ## Install Zypper plugins only on SUSE machines
%if 0%{?suse_version} %if 0%{?suse_version}
@ -986,11 +1054,10 @@ install -Dpm 0640 conf/suse/standalone-formulas-configuration.conf %{buildroot}%
%fdupes %{buildroot}%{python3_sitelib} %fdupes %{buildroot}%{python3_sitelib}
%endif %endif
%check
%if %{with test}
python3 setup.py test --runtests-opts=-u
%endif %endif
%if "%{flavor}" != "testsuite"
%pre %pre
S_HOME="/var/lib/salt" S_HOME="/var/lib/salt"
S_PHOME="/srv/salt" S_PHOME="/srv/salt"
@ -1464,9 +1531,6 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
%doc doc/_build/html %doc doc/_build/html
%endif %endif
%files -n python3-salt-testsuite
%{python3_sitelib}/salt-testsuite
%if %{with bash_completion} %if %{with bash_completion}
%files bash-completion %files bash-completion
%defattr(-,root,root) %defattr(-,root,root)
@ -1503,6 +1567,12 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
%defattr(-,root,root) %defattr(-,root,root)
%config(noreplace) %attr(0640, root, root) %{_sysconfdir}/salt/minion.d/transactional_update.conf %config(noreplace) %attr(0640, root, root) %{_sysconfdir}/salt/minion.d/transactional_update.conf
%endif
%if "%{flavor}" == "testsuite"
%files -n python3-salt-testsuite
%{python3_sitelib}/salt-testsuite
%endif
%changelog %changelog

View File

@ -0,0 +1,80 @@
From 4ec5c8bdb8aecac6752c639f494b86c7f8f57ba2 Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
Date: Tue, 26 Mar 2024 09:20:30 +0100
Subject: [PATCH] Switch oscap encoding to utf-8 (#639)
---
salt/modules/openscap.py | 7 ++++---
tests/unit/modules/test_openscap.py | 8 ++++----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py
index 89712ae722b..7322c667dcc 100644
--- a/salt/modules/openscap.py
+++ b/salt/modules/openscap.py
@@ -153,7 +153,7 @@ def xccdf_eval(xccdffile, ovalfiles=None, **kwargs):
tempdir = tempfile.mkdtemp()
proc = Popen(cmd_opts, stdout=PIPE, stderr=PIPE, cwd=tempdir)
(_, error) = proc.communicate()
- error = error.decode('ascii', errors='ignore')
+ error = error.decode('utf-8', errors='surogateescape')
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
error += "\nKilled by signal {}\n".format(proc.returncode)
@@ -204,10 +204,11 @@ def xccdf(params):
cmd = _XCCDF_MAP[action]["cmd_pattern"].format(args.profile, policy)
tempdir = tempfile.mkdtemp()
proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE, cwd=tempdir)
- (stdoutdata, error) = proc.communicate()
+ (_, error) = proc.communicate()
+ error = error.decode('utf-8', errors='surogateescape')
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
- error += "\nKilled by signal {}\n".format(proc.returncode).encode('ascii')
+ error += "\nKilled by signal {}\n".format(proc.returncode)
returncode = proc.returncode
if success:
__salt__["cp.push_dir"](tempdir)
diff --git a/tests/unit/modules/test_openscap.py b/tests/unit/modules/test_openscap.py
index 6fbdfed7cf9..c20220ea977 100644
--- a/tests/unit/modules/test_openscap.py
+++ b/tests/unit/modules/test_openscap.py
@@ -35,7 +35,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 0, "communicate.return_value": ("", "")}
+ **{"returncode": 0, "communicate.return_value": (bytes(0), bytes(0))}
)
),
):
@@ -82,7 +82,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 2, "communicate.return_value": ("", "some error")}
+ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))}
)
),
):
@@ -137,7 +137,7 @@ class OpenscapTestCase(TestCase):
"salt.modules.openscap.Popen",
MagicMock(
return_value=Mock(
- **{"returncode": 2, "communicate.return_value": ("", "some error")}
+ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))}
)
),
):
@@ -180,7 +180,7 @@ class OpenscapTestCase(TestCase):
return_value=Mock(
**{
"returncode": 1,
- "communicate.return_value": ("", "evaluation error"),
+ "communicate.return_value": (bytes(0), bytes("evaluation error", "UTF-8")),
}
)
),
--
2.44.0