From 2240c084063ad94020bd233e16e24a2b76c64294 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sat, 27 Apr 2024 19:13:06 -0700 Subject: [PATCH] Add scenario test for syndic --- tests/pytests/scenarios/syndic/__init__.py | 0 tests/pytests/scenarios/syndic/conftest.py | 85 +++++++++++++++++++ tests/pytests/scenarios/syndic/test_syndic.py | 6 ++ 3 files changed, 91 insertions(+) create mode 100644 tests/pytests/scenarios/syndic/__init__.py create mode 100644 tests/pytests/scenarios/syndic/conftest.py create mode 100644 tests/pytests/scenarios/syndic/test_syndic.py diff --git a/tests/pytests/scenarios/syndic/__init__.py b/tests/pytests/scenarios/syndic/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/pytests/scenarios/syndic/conftest.py b/tests/pytests/scenarios/syndic/conftest.py new file mode 100644 index 00000000000..b014aa2bf0e --- /dev/null +++ b/tests/pytests/scenarios/syndic/conftest.py @@ -0,0 +1,85 @@ +import logging + +import pytest + +log = logging.getLogger(__name__) + + +@pytest.fixture(scope="package") +def master(request, salt_factories): + config_defaults = { + "transport": request.config.getoption("--transport"), + } + config_overrides = { + "interface": "127.0.0.1", + "auto_accept": True, + "order_masters": True, + } + factory = salt_factories.salt_master_daemon( + "master", + defaults=config_defaults, + overrides=config_overrides, + extra_cli_arguments_after_first_start_failure=["--log-level=info"], + ) + with factory.started(start_timeout=180): + yield factory + + +@pytest.fixture(scope="package") +def salt_cli(master): + return master.salt_cli(timeout=180) + + +@pytest.fixture(scope="package") +def syndic(master, salt_factories): + + ret_port = master.config["ret_port"] + port = master.config["publish_port"] + addr = master.config["interface"] + + # Force both master's publish port to be the same, this is a drawback of + # the current syndic design. + config_defaults = { + "transport": master.config["transport"], + "interface": "127.0.0.2", + "publish_port": f"{port}", + } + master_overrides = { + "interface": "127.0.0.2", + "auto_accept": True, + "syndic_master": f"{addr}", + "syndic_master_port": f"{ret_port}", + } + minion_overrides = { + "master": "127.0.0.2", + "publish_port": f"{port}", + } + factory = master.salt_syndic_daemon( + "syndic", + defaults=config_defaults, + master_overrides=master_overrides, + minion_overrides=minion_overrides, + extra_cli_arguments_after_first_start_failure=["--log-level=info"], + ) + with factory.started(start_timeout=180): + yield factory + + +@pytest.fixture(scope="package") +def minion(syndic, salt_factories): + config_defaults = { + "transport": syndic.config["transport"], + } + port = syndic.master.config["ret_port"] + addr = syndic.master.config["interface"] + config_overrides = { + "master": f"{addr}:{port}", + } + factory = syndic.master.salt_minion_daemon( + "minion", + defaults=config_defaults, + overrides=config_overrides, + extra_cli_arguments_after_first_start_failure=["--log-level=info"], + ) + with factory.started(start_timeout=180): + yield factory diff --git a/tests/pytests/scenarios/syndic/test_syndic.py b/tests/pytests/scenarios/syndic/test_syndic.py new file mode 100644 index 00000000000..052ff1981de --- /dev/null +++ b/tests/pytests/scenarios/syndic/test_syndic.py @@ -0,0 +1,6 @@ +def test_syndic(salt_cli, minion): + ret = salt_cli.run("test.ping", minion_tgt="*", _timeout=15) + assert ret.data == { + "syndic": True, + "minion": True, + }