From 469dd016a8c949d0f91ad36c285a3252d25a90e0 Mon Sep 17 00:00:00 2001 From: Meni Yakove Date: Tue, 1 Dec 2026 12:07:48 +0200 Subject: [PATCH] test: remove flaky cross-file timestamp assertion in multiprocess rotation test Remove file_ts_bounds cross-file timestamp ordering checks in test_get_logger_with_params_multiprocess_rotation_concurrency. Python logging captures LogRecord.created before MultiProcessRotatingFileHandler acquires its file lock, so concurrent workers can legitimately flush a record a few milliseconds older into a newly rotated file. Deterministic rotation order is already covered by per-worker monotonic msg sequence checks. Fixes #1334 Assisted-by: PI (gemini-4-neon) Signed-off-by: Meni Yakove --- webhook_server/tests/test_helpers.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/webhook_server/tests/test_helpers.py b/webhook_server/tests/test_helpers.py index d9df1923..c570d540 100644 --- a/webhook_server/tests/test_helpers.py +++ b/webhook_server/tests/test_helpers.py @@ -708,26 +708,20 @@ def test_get_logger_with_params_multiprocess_rotation_concurrency(self, tmp_path ordered_files = [*backup_paths, base_log] line_pattern = re.compile(r"^(\S+)\s+.*worker=(\d+)\s+(?:msg|pad)=(\d+)") last_msg_by_worker: dict[int, int] = {} - file_ts_bounds: list[tuple[datetime, datetime]] = [] for log_path in ordered_files: - timestamps: list[datetime] = [] - for line in log_path.read_text(encoding="utf-8").splitlines(): + lines = log_path.read_text(encoding="utf-8").splitlines() + assert lines + for line in lines: match = line_pattern.match(line) assert match is not None, f"Unparseable or interleaved log line in {log_path}: {line!r}" ts_str, worker_str, seq_str = match.groups() - timestamps.append(datetime.fromisoformat(ts_str)) + datetime.fromisoformat(ts_str) if " msg=" in line: w_id = int(worker_str) seq = int(seq_str) assert seq > last_msg_by_worker.get(w_id, -1) last_msg_by_worker[w_id] = seq - assert timestamps - file_ts_bounds.append((min(timestamps), max(timestamps))) - - for earlier, later in zip(file_ts_bounds, file_ts_bounds[1:], strict=False): - assert earlier[0] <= later[0] - assert earlier[1] <= later[1] finally: for worker in workers: if worker.is_alive():