test(agent): drain the log queue before reading errors.log in the config-load warning test
errors.log is written by the logging QueueListener thread, so the file can lag the caplog records the test just asserted on. On a loaded runner the read saw only the first warning, or no file at all, and failed main CI after #144257. Drain the queue with hermes_logging.flush_log_queue() first, like the other log-file tests do. Hammered 24 runs each: origin/main 4 failures, this change 0.
This commit is contained in:
@@ -6,6 +6,8 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
import hermes_logging
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def make_agent(monkeypatch):
|
||||
@@ -134,6 +136,8 @@ def test_config_failure_warns_without_exposing_values_and_preserves_defaults(
|
||||
"sections": "memory",
|
||||
}
|
||||
messages = [record.getMessage() for record in warnings]
|
||||
# errors.log is written by the logging QueueListener thread: drain it before reading the file.
|
||||
hermes_logging.flush_log_queue()
|
||||
persisted = (home / "logs" / "errors.log").read_text(encoding="utf-8-sig")
|
||||
for scope in affected:
|
||||
assert any(expected_sections[scope] in message for message in messages)
|
||||
|
||||
Reference in New Issue
Block a user