mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Confirm salt extensions are discoverable by salt when salt-pip
installed
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
a59929ad20
commit
9a94ec6d6a
2 changed files with 75 additions and 2 deletions
|
@ -143,3 +143,44 @@ def test_pip_non_root(shell, install_salt, test_account, extras_pypath_bin):
|
|||
assert check_path.exists()
|
||||
|
||||
assert ret.returncode == 0, ret.stderr
|
||||
|
||||
|
||||
def test_pip_install_salt_extension_in_extras(install_salt, extras_pypath, shell):
|
||||
"""
|
||||
Test salt-pip installs into the correct directory and the salt extension
|
||||
is properly loaded.
|
||||
"""
|
||||
dep = "salt-analytics-framework"
|
||||
dep_version = "0.1.0"
|
||||
|
||||
install_ret = shell.run(
|
||||
*(install_salt.binary_paths["pip"] + ["install", f"{dep}=={dep_version}"]),
|
||||
)
|
||||
assert install_ret.returncode == 0
|
||||
|
||||
ret = shell.run(
|
||||
*(install_salt.binary_paths["pip"] + ["list", "--format=json"]),
|
||||
)
|
||||
assert ret.returncode == 0
|
||||
pkgs_installed = json.loads(ret.stdout.strip())
|
||||
for pkg in pkgs_installed:
|
||||
if pkg["name"] == dep:
|
||||
break
|
||||
else:
|
||||
pytest.fail(
|
||||
f"The {dep!r} package was not found installed. Packages Installed: {pkgs_installed}"
|
||||
)
|
||||
|
||||
show_ret = shell.run(
|
||||
*(install_salt.binary_paths["pip"] + ["show", dep]),
|
||||
)
|
||||
assert show_ret.returncode == 0
|
||||
|
||||
assert extras_pypath.joinpath("saf").is_dir()
|
||||
|
||||
ret = shell.run(
|
||||
*(install_salt.binary_paths["minion"] + ["--versions-report"]),
|
||||
)
|
||||
assert show_ret.returncode == 0
|
||||
assert "Salt Extensions" in ret.stdout
|
||||
assert f"{dep}: {dep_version}" in ret.stdout
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.version
|
||||
from tests.conftest import CODE_DIR
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _install_salt_extension(shell):
|
||||
if os.environ.get("ONEDIR_TESTRUN", "0") == "0":
|
||||
return
|
||||
|
||||
script_name = "salt-pip"
|
||||
if salt.utils.platform.is_windows():
|
||||
script_name += ".exe"
|
||||
|
||||
script_path = CODE_DIR / "artifacts" / "salt" / script_name
|
||||
assert script_path.exists()
|
||||
try:
|
||||
ret = shell.run(str(script_path), "install", "salt-analytics-framework==0.1.0")
|
||||
assert ret.returncode == 0
|
||||
log.info(ret)
|
||||
yield
|
||||
finally:
|
||||
ret = shell.run(str(script_path), "uninstall", "-y", "salt-analytics-framework")
|
||||
log.info(ret)
|
||||
shutil.rmtree(script_path.parent / "extras-3.10", ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.mark.windows_whitelisted
|
||||
|
@ -52,5 +79,10 @@ def test_versions_report(salt_cli):
|
|||
assert key in expected_keys
|
||||
expected_keys.remove(key)
|
||||
assert not expected_keys
|
||||
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
|
||||
assert "relenv" in ret_dict["Dependency Versions"]
|
||||
if os.environ.get("ONEDIR_TESTRUN", "0") == "0":
|
||||
# Stop any more testing
|
||||
return
|
||||
|
||||
assert "relenv" in ret_dict["Dependency Versions"]
|
||||
assert "Salt Extensions" in ret_dict
|
||||
assert "salt-analytics-framework" in ret_dict["Salt Extensions"]
|
||||
|
|
Loading…
Add table
Reference in a new issue