You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: remove flaky cross-file timestamp ordering assertion in multiprocess rotation test #1334
TestHelpers.test_get_logger_with_params_multiprocess_rotation_concurrency in webhook_server/tests/test_helpers.py fails intermittently under parallel CI runs (observed in PR #1333, check run 142150288731):
In webhook_server/tests/test_helpers.py:711-730, the test collects (min(timestamps), max(timestamps)) per rotated log file (file_ts_bounds) and asserts strict ordering across consecutive files:
Python's logging module captures LogRecord.created before MultiProcessRotatingFileHandler acquires its inter-process file lock and performs writes or rollovers. With 4 forked workers logging concurrently, one worker can construct a record, wait on the file lock while another worker constructs a newer record and rotates the file, and then flush its slightly older timestamp (here 2.8 ms older) into the newly rotated file.
Cross-file millisecond/microsecond timestamp ordering is not guaranteed across OS-scheduled processes, and the check is redundant because the same loop already verifies deterministic rotation order via per-worker sequence numbers (assert seq > last_msg_by_worker.get(w_id, -1)).
Proposed fix
Update test_get_logger_with_params_multiprocess_rotation_concurrency in webhook_server/tests/test_helpers.py:
Remove timestamps, file_ts_bounds, and the cross-file earlier[0] <= later[0] / earlier[1] <= later[1] assertions.
Keep non-empty file checks (assert lines), line format parsing (line_pattern), ISO-8601 timestamp parsing (datetime.fromisoformat(ts_str)), per-worker monotonic sequence checks across rotated files, backup size checks, and final marker checks.
Done
Remove cross-file file_ts_bounds timestamp assertions in webhook_server/tests/test_helpers.py
Verify uvx prek run --all-files and uvx tox pass
Run test_get_logger_with_params_multiprocess_rotation_concurrency repeatedly to confirm stability
Activity