Remove some duplicate fixtures

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-12-06 11:55:46 +00:00 committed by Daniel Wozniak
parent 8bf7684883
commit fd563dcba5
3 changed files with 26 additions and 46 deletions

View file

@ -21,7 +21,6 @@ from tests.pytests.pkg.support.helpers import (
SaltPkgInstall,
TestUser,
)
from tests.support.sminion import create_sminion
log = logging.getLogger(__name__)
@ -37,16 +36,6 @@ def version(install_salt):
return install_salt.version
@pytest.fixture(scope="session")
def sminion():
return create_sminion()
@pytest.fixture(scope="session")
def grains(sminion):
return sminion.opts["grains"].copy()
@pytest.fixture(scope="session", autouse=True)
def _system_up_to_date(
grains,
@ -510,7 +499,7 @@ def salt_minion(salt_factories, salt_master, install_salt):
subprocess.run(["chown", "-R", "salt:salt", str(_dir)], check=True)
factory.after_terminate(
pytest.helpers.remove_stale_minion_key_pkg, salt_master, factory.id
pytest.helpers.remove_stale_minion_key, salt_master, factory.id
)
with factory.started(start_timeout=start_timeout):
yield factory

View file

@ -1559,40 +1559,6 @@ class ApiRequest:
self.session.__exit__(*args)
@pytest.helpers.register
def remove_stale_minion_key_pkg(master, minion_id):
key_path = os.path.join(master.config["pki_dir"], "minions", minion_id)
if os.path.exists(key_path):
os.unlink(key_path)
else:
log.debug("The minion(id=%r) key was not found at %s", minion_id, key_path)
@pytest.helpers.register
def remove_stale_master_key(master):
keys_path = os.path.join(master.config["pki_dir"], "master")
for key_name in ("master.pem", "master.pub"):
key_path = os.path.join(keys_path, key_name)
if os.path.exists(key_path):
os.unlink(key_path)
else:
log.debug(
"The master(id=%r) %s key was not found at %s",
master.id,
key_name,
key_path,
)
key_path = os.path.join(master.config["pki_dir"], "minion", "minion_master.pub")
if os.path.exists(key_path):
os.unlink(key_path)
else:
log.debug(
"The master(id=%r) minion_master.pub key was not found at %s",
master.id,
key_path,
)
@pytest.helpers.register
def download_file(url, dest, auth=None):
# NOTE the stream=True parameter below

View file

@ -174,6 +174,31 @@ def remove_stale_minion_key(master, minion_id):
log.debug("The minion(id=%r) key was not found at %s", minion_id, key_path)
@pytest.helpers.register
def remove_stale_master_key(master):
keys_path = os.path.join(master.config["pki_dir"], "master")
for key_name in ("master.pem", "master.pub"):
key_path = os.path.join(keys_path, key_name)
if os.path.exists(key_path):
os.unlink(key_path)
else:
log.debug(
"The master(id=%r) %s key was not found at %s",
master.id,
key_name,
key_path,
)
key_path = os.path.join(master.config["pki_dir"], "minion", "minion_master.pub")
if os.path.exists(key_path):
os.unlink(key_path)
else:
log.debug(
"The master(id=%r) minion_master.pub key was not found at %s",
master.id,
key_path,
)
@pytest.helpers.register
def remove_stale_proxy_minion_cache_file(proxy_minion, minion_id=None):
cachefile = os.path.join(