Test fixup

- Actually fix cluster key rotate test by useing getpass module.
- Skip a test that won't pass because amazon linux 2 systemd is not
  fully working in a container.
This commit is contained in:
Daniel A. Wozniak 2025-02-05 19:25:46 -07:00
parent 98a0673eca
commit 65dff0ba98
2 changed files with 5 additions and 13 deletions

View file

@ -6,6 +6,8 @@ import types
import pytest
from tests.pytests.functional.states.test_service import _check_systemctl
pytestmark = [
pytest.mark.skip_on_windows,
pytest.mark.destructive_test,
@ -18,6 +20,7 @@ def formula():
return types.SimpleNamespace(name="nginx-formula", tag="2.8.1")
@pytest.mark.skipif(_check_systemctl(), reason="systemctl degraded")
def test_formula(modules):
ret = modules.state.sls("nginx")
assert not ret.errors

View file

@ -2,30 +2,19 @@
Cluster scinarios.
"""
import os
import getpass
import pathlib
import time
import pytest
import salt.crypt
@pytest.fixture
def login():
path = pathlib.Path("/proc/self/loginuid")
if not path.exists():
path.write_text(f"{os.getuid()}", encoding="utf-8")
return os.getlogin()
def test_cluster_key_rotation(
cluster_master_1,
cluster_master_2,
cluster_master_3,
cluster_minion_1,
cluster_cache_path,
login,
):
cli = cluster_master_2.salt_cli(timeout=120)
ret = cli.run("test.ping", minion_tgt="cluster-minion-1")
@ -55,7 +44,7 @@ def test_cluster_key_rotation(
assert not dfpath.exists()
salt.crypt.dropfile(
cluster_master_1.config["cachedir"],
user=login,
user=getpass.getuser(),
master_id=cluster_master_1.config["id"],
)
assert dfpath.exists()