From 84b4e96db265946ed40364eb9ed90fcfb544cea9 Mon Sep 17 00:00:00 2001 From: Max Arnold Date: Tue, 20 Feb 2024 10:20:27 +0700 Subject: [PATCH] Add integration test --- changelog/66095.fixed.md | 2 +- tests/pytests/integration/cli/test_salt.py | 26 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/changelog/66095.fixed.md b/changelog/66095.fixed.md index 42823db5738..c82f646aed2 100644 --- a/changelog/66095.fixed.md +++ b/changelog/66095.fixed.md @@ -1 +1 @@ -Make sure the root minion process handles SIGUSR1 and emits a traceback like the child minion processes +Make sure the root minion process handles SIGUSR1 and emits a traceback like it's child processes diff --git a/tests/pytests/integration/cli/test_salt.py b/tests/pytests/integration/cli/test_salt.py index 37925160ca6..90e3eed6d78 100644 --- a/tests/pytests/integration/cli/test_salt.py +++ b/tests/pytests/integration/cli/test_salt.py @@ -2,6 +2,7 @@ :codeauthor: Thayne Harbaugh (tharbaug@adobe.com) """ +import glob import logging import os import shutil @@ -276,3 +277,28 @@ def test_minion_65400(salt_cli, salt_minion, salt_minion_2, salt_master): for minion_id in ret.data: assert ret.data[minion_id] != "Error: test.configurable_test_state" assert isinstance(ret.data[minion_id], dict) + + +@pytest.mark.skip_on_windows(reason="Windows does not support SIGUSR1") +def test_sigusr1_handler(salt_master, salt_minion): + """ + Ensure SIGUSR1 handler works. + + Refer to https://docs.saltproject.io/en/latest/topics/troubleshooting/minion.html#live-python-debug-output for more details. + """ + tb_glob = os.path.join(tempfile.gettempdir(), "salt-debug-*.log") + tracebacks_before = glob.glob(tb_glob) + os.kill(salt_minion.pid, signal.SIGUSR1) + for i in range(10): + if len(glob.glob(tb_glob)) - len(tracebacks_before) == 1: + break + time.sleep(1) + + os.kill(salt_master.pid, signal.SIGUSR1) + for i in range(10): + if len(glob.glob(tb_glob)) - len(tracebacks_before) == 2: + break + time.sleep(1) + + tracebacks_after = glob.glob(tb_glob) + assert len(tracebacks_after) - len(tracebacks_before) == 2