minion_opts fixture is now available for all tests under tests/pytests/unit

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-09-16 16:57:57 +01:00 committed by Megan Wilhite
parent 413a6ef633
commit c1558ae7e7
3 changed files with 28 additions and 13 deletions

View file

@ -42,8 +42,8 @@ def minion_config_defaults():
@pytest.fixture(scope="module")
def minion_config_overrides():
"""
Functional test modules can provide this fixture to tweak the configuration overrides dictionary
passed to the minion factory
Functional test modules can provide this fixture to tweak the configuration
overrides dictionary passed to the minion factory
"""
return {}
@ -60,7 +60,14 @@ def minion_opts(
minion_config_overrides.update(
{
"file_client": "local",
"file_roots": {"base": [str(state_tree)], "prod": [str(state_tree_prod)]},
"file_roots": {
"base": [
str(state_tree),
],
"prod": [
str(state_tree_prod),
],
},
}
)
factory = salt_factories.salt_minion_daemon(

View file

@ -0,0 +1,18 @@
import pytest
import salt.config
@pytest.fixture
def minion_opts(tmp_path):
"""
Default minion configuration with relative temporary paths to not require root permissions.
"""
opts = salt.config.DEFAULT_MINION_OPTS.copy()
opts["root_dir"] = str(tmp_path)
for name in ("cachedir", "pki_dir", "sock_dir", "conf_dir"):
dirpath = tmp_path / name
dirpath.mkdir()
opts[name] = str(dirpath)
opts["log_file"] = "logs/minion.log"
return opts

View file

@ -21,16 +21,6 @@ from tests.support.mock import MagicMock, patch
log = logging.getLogger(__name__)
@pytest.fixture
def minion_opts(temp_salt_minion, tmp_path):
opts = salt.config.DEFAULT_MINION_OPTS.copy()
opts["root_dir"] = str(tmp_path)
for name in ("cachedir", "pki_dir", "sock_dir", "conf_dir"):
opts[name] = str(tmp_path / name)
opts["log_file"] = "logs/minion.log"
return opts
def test_minion_load_grains_false():
"""
Minion does not generate grains when load_grains is False