fix(execution): cancel SQL nullable type error, KIS child cancel detection, worker exception logging
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
2b412fd786
commit
f0ac909958
@@ -0,0 +1,53 @@
|
||||
"""Regression: execution loop exceptions must be logged, not silently swallowed.
|
||||
|
||||
dcy-031 / issue #81: exceptions from execution.run_once() were silently ignored
|
||||
via bare `continue`, making it impossible to observe repository or adapter errors.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_execution_loop_logs_exception(caplog):
|
||||
"""When execution.run_once() raises, the error is logged and the loop continues."""
|
||||
import trex_core.runtime.daemon as daemon_mod
|
||||
|
||||
call_count = 0
|
||||
stop_event = threading.Event()
|
||||
|
||||
class _FakeExecution:
|
||||
def run_once(self):
|
||||
nonlocal call_count
|
||||
call_count += 1
|
||||
if call_count == 1:
|
||||
raise RuntimeError("simulated repo error: IndeterminateDatatype")
|
||||
stop_event.set()
|
||||
|
||||
class _FakePublisher:
|
||||
def keepalive_tick(self):
|
||||
pass
|
||||
|
||||
class _FakeConfig:
|
||||
execution_interval_sec = 0.001
|
||||
|
||||
# Build a minimal stub Daemon without invoking its real __init__, so we can
|
||||
# inject only the attributes _execution_loop reads.
|
||||
daemon = object.__new__(daemon_mod.Daemon)
|
||||
daemon.stop = stop_event
|
||||
daemon.config = _FakeConfig()
|
||||
daemon.event_publisher = _FakePublisher()
|
||||
daemon.execution = _FakeExecution()
|
||||
|
||||
with caplog.at_level(logging.ERROR, logger="trex_core.runtime.daemon"):
|
||||
t = threading.Thread(target=daemon._execution_loop, daemon=True)
|
||||
t.start()
|
||||
t.join(timeout=2.0)
|
||||
|
||||
assert not t.is_alive(), "execution loop did not exit cleanly"
|
||||
assert any(
|
||||
"execution loop error" in r.message for r in caplog.records
|
||||
), f"expected 'execution loop error' log, got: {[r.message for r in caplog.records]}"
|
||||
Reference in New Issue
Block a user