2023-01-17 11:21:32 -07:00
|
|
|
import sys
|
2023-11-20 13:19:28 +00:00
|
|
|
import time
|
2023-01-17 11:21:32 -07:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
2023-02-08 13:51:16 -07:00
|
|
|
def pkg_name(salt_call_cli, grains):
|
2023-01-17 11:21:32 -07:00
|
|
|
if sys.platform.startswith("win"):
|
2023-02-08 13:51:16 -07:00
|
|
|
ret = salt_call_cli.run("--local", "winrepo.update_git_repos")
|
|
|
|
assert ret.returncode == 0
|
2023-11-20 13:19:28 +00:00
|
|
|
attempts = 3
|
|
|
|
while attempts:
|
|
|
|
attempts -= 1
|
|
|
|
ret = salt_call_cli.run("--local", "pkg.refresh_db")
|
|
|
|
if ret.returncode:
|
|
|
|
time.sleep(5)
|
|
|
|
continue
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
pytest.fail("Failed to run 'pkg.refresh_db' 3 times.")
|
2023-01-17 11:21:32 -07:00
|
|
|
return "putty"
|
|
|
|
elif grains["os_family"] == "RedHat":
|
|
|
|
if grains["os"] == "VMware Photon OS":
|
|
|
|
return "snoopy"
|
2023-10-18 12:49:59 -06:00
|
|
|
elif grains["osfinger"] == "Amazon Linux-2023":
|
2023-10-17 12:59:51 -06:00
|
|
|
return "dnf-utils"
|
2023-01-17 11:21:32 -07:00
|
|
|
return "units"
|
|
|
|
elif grains["os_family"] == "Debian":
|
|
|
|
return "ifenslave"
|
|
|
|
return "figlet"
|
|
|
|
|
|
|
|
|
2023-02-08 13:51:16 -07:00
|
|
|
def test_pkg_install(salt_call_cli, pkg_name):
|
|
|
|
ret = salt_call_cli.run("--local", "state.single", "pkg.installed", pkg_name)
|
2023-01-17 11:21:32 -07:00
|
|
|
assert ret.returncode == 0
|