test(issue-18): measure the wall-clock close on the record and widen the loop worker's wall clock

Both tests ran against the public broker with second-scale budgets: the
error publish after the close can take 10-20 s, and a worker's `started`
must land before a 12 s wall clock. Assert the close time from the record's
updated_at and give the loop scenario a 30 s wall clock.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
GodopuandClaude Fable 5.1 committed 2026-09-13 19:56:37 +09:00
1 parent 0550320590
commit d09c1627ce
2 files changed
+13 -6

No files matched your search

+8 -3
View File
@@ -503,9 +503,14 @@ def test_wrapper_idle_grace_never_outlives_the_wall_clock(tmp_path):
# The heartbeats were honoured: the job was not closed after the first idle
# window, it stayed open up to the wall clock ...
assert elapsed >= timeout_s - 1, f"closed before the wall clock: {elapsed:.1f}s\n{stderr}"
# ... and not a moment past it beyond closing and publishing the error
# (the error publish alone can take ~10 s against the public broker).
assert elapsed <= timeout_s + 15, f"idle grace outlived --timeout {timeout_s}s: {elapsed:.1f}s\n{stderr}"
# ... and the close itself landed within the wall clock plus a small margin.
# Measured on the record's own close time: the error publish that follows
# the close can take 10-20 s against the public broker and is not what
# this test is about.
import calendar
closed_at = calendar.timegm(time.strptime(job_data["updated_at"], "%Y-%m-%dT%H:%M:%SZ"))
close_delay = closed_at - started
assert close_delay <= timeout_s + 8, f"idle grace outlived --timeout {timeout_s}s: closed after {close_delay:.0f}s\n{stderr}"
# ---------------------------------------------------------------------------