Rename the container-side logging module decnet_logging → syslog_bridge (canonical at templates/syslog_bridge.py, synced into each template by the deployer). Drop the stale per-template copies; setuptools find was picking them up anyway. Swap useradd/USER/chown "decnet" for "logrelay" so no obvious token appears in the rendered container image. Apply the same cloaking pattern to the telnet template that SSH got: syslog pipe moves to /run/systemd/journal/syslog-relay and the relay is cat'd via exec -a "systemd-journal-fwd". rsyslog.d conf rename 99-decnet.conf → 50-journal-forward.conf. SSH capture script: /var/decnet/captured → /var/lib/systemd/coredump (real systemd path), logger tag decnet-capture → systemd-journal. Compose volume updated to match the new in-container quarantine path. SD element ID shifts decnet@55555 → relay@55555; synced across collector, parser, sniffer, prober, formatter, tests, and docs so the host-side pipeline still matches what containers emit.
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""
|
|
Shared helpers for binary-protocol service tests.
|
|
"""
|
|
|
|
import os
|
|
import threading
|
|
from types import ModuleType
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
from hypothesis import HealthCheck
|
|
|
|
|
|
_FUZZ_SETTINGS = dict(
|
|
max_examples=int(os.environ.get("HYPOTHESIS_MAX_EXAMPLES", "200")),
|
|
deadline=2000,
|
|
suppress_health_check=[HealthCheck.function_scoped_fixture],
|
|
)
|
|
|
|
|
|
def make_fake_syslog_bridge() -> ModuleType:
|
|
mod = ModuleType("syslog_bridge")
|
|
mod.syslog_line = MagicMock(return_value="")
|
|
mod.write_syslog_file = MagicMock()
|
|
mod.forward_syslog = MagicMock()
|
|
mod.SEVERITY_WARNING = 4
|
|
mod.SEVERITY_INFO = 6
|
|
return mod
|
|
|
|
|
|
def run_with_timeout(fn, *args, timeout: float = 2.0) -> None:
|
|
"""Run fn(*args) in a daemon thread. pytest.fail if it doesn't return in time."""
|
|
exc_box: list[BaseException] = []
|
|
|
|
def _target():
|
|
try:
|
|
fn(*args)
|
|
except Exception as e:
|
|
exc_box.append(e)
|
|
|
|
t = threading.Thread(target=_target, daemon=True)
|
|
t.start()
|
|
t.join(timeout)
|
|
if t.is_alive():
|
|
pytest.fail(f"data_received hung for >{timeout}s — likely infinite loop")
|
|
if exc_box:
|
|
raise exc_box[0]
|