mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Fix pkg tests on debian containers
This commit is contained in:
parent
8909607ab9
commit
6f7b448591
3 changed files with 27 additions and 0 deletions
|
@ -4,6 +4,8 @@ Integration tests for timezone module
|
|||
Linux and Solaris are supported
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -16,6 +18,16 @@ except ImportError:
|
|||
HAS_TZLOCAL = False
|
||||
|
||||
|
||||
def _check_systemctl():
|
||||
if not hasattr(_check_systemctl, "memo"):
|
||||
proc = subprocess.run(["systemctl"], capture_output=True, check=False)
|
||||
_check_systemctl.memo = (
|
||||
b"Failed to get D-Bus connection: No such file or directory" in proc.stderr
|
||||
)
|
||||
return _check_systemctl.memo
|
||||
|
||||
|
||||
@pytest.mark.skipif(_check_systemctl(), reason="systemctl degraded")
|
||||
class TimezoneLinuxModuleTest(ModuleCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
|
@ -32,6 +44,7 @@ class TimezoneLinuxModuleTest(ModuleCase):
|
|||
self.assertIn(ret, timescale)
|
||||
|
||||
|
||||
@pytest.mark.skipif(_check_systemctl(), reason="systemctl degraded")
|
||||
class TimezoneSolarisModuleTest(ModuleCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
|
|
|
@ -27,6 +27,9 @@ pytestmark = [
|
|||
|
||||
@pytest.fixture
|
||||
def pkgrepo(states, grains):
|
||||
sources = pathlib.Path("/etc/apt/sources.list")
|
||||
if not sources.exists():
|
||||
sources.touch()
|
||||
if grains["os_family"] != "Debian":
|
||||
raise pytest.skip.Exception(
|
||||
"Test only for debian based platforms", _use_item_location=True
|
||||
|
|
|
@ -25,6 +25,11 @@ def salt_extension(tmp_path_factory):
|
|||
|
||||
def test_salt_extensions_in_versions_report(tmp_path, salt_extension):
|
||||
with SaltVirtualEnv(venv_dir=tmp_path / ".venv") as venv:
|
||||
# These are required for the test to pass, why are they not already
|
||||
# installed?
|
||||
venv.install("pyyaml")
|
||||
venv.install("looseversion")
|
||||
venv.install("packaging")
|
||||
# Install our extension into the virtualenv
|
||||
venv.install(str(salt_extension.srcdir))
|
||||
installed_packages = venv.get_installed_packages()
|
||||
|
@ -47,6 +52,12 @@ def test_salt_extensions_absent_in_versions_report(tmp_path, salt_extension):
|
|||
Ensure that the 'Salt Extensions' header does not show up when no extension is installed
|
||||
"""
|
||||
with SaltVirtualEnv(venv_dir=tmp_path / ".venv") as venv:
|
||||
# These are required for the test to pass, why are they not already
|
||||
# installed?
|
||||
venv.install("pyyaml")
|
||||
venv.install("looseversion")
|
||||
venv.install("packaging")
|
||||
venv.install("distro")
|
||||
installed_packages = venv.get_installed_packages()
|
||||
assert salt_extension.name not in installed_packages
|
||||
ret = venv.run_code(
|
||||
|
|
Loading…
Add table
Reference in a new issue