forked from saltstack/pytest-salt-factories
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZMQ needs to reconnect on forked processes(follow up to saltstack#64)
- Loading branch information
Showing
6 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ZMQ needs to reconnect on forked processes or else Salt's own multiprocessing log forwarding log records won't be logged by the ``ZMQHandler`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import logging | ||
|
||
import pytest | ||
|
||
from saltfactories.utils import random_string | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def master(salt_factories): | ||
factory = salt_factories.salt_master_daemon(random_string("master-")) | ||
with factory.started(): | ||
yield factory | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def minion(master): | ||
factory = master.salt_minion_daemon(random_string("minion-")) | ||
with factory.started(): | ||
yield factory | ||
|
||
|
||
@pytest.fixture | ||
def salt_cli(master): | ||
return master.get_salt_cli() | ||
|
||
|
||
def test_logs_forwarded_from_sub_processes(salt_cli, minion, caplog): | ||
assert minion.is_running() | ||
|
||
with caplog.at_level(logging.DEBUG): | ||
ret = salt_cli.run("test.ping", minion_tgt=minion.id) | ||
assert ret.exitcode == 0, ret | ||
assert ret.json is True | ||
|
||
non_main_processes_count = 0 | ||
for record in caplog.records: | ||
if record.processName != "MainProcess": | ||
non_main_processes_count += 1 | ||
|
||
# We should see at least a log record from the MWorker and ProcessPayload processes | ||
assert non_main_processes_count >= 2 |