Skip to content

The agent that grows with you

test(cron): the heartbeat grace test also pins that a failed renewal preceded cancellation

teknium1e33693c93227
diff --git a/tests/cron/test_script_claim_heartbeat.py b/tests/cron/test_script_claim_heartbeat.py
index 1b6d7f74d70..854f0f4bf3e 100644
--- a/tests/cron/test_script_claim_heartbeat.py
+++ b/tests/cron/test_script_claim_heartbeat.py
@@ -643,7 +643,11 @@ def test_heartbeat_thread_start_failure_does_not_start_execution(monkeypatch):
def test_repeated_heartbeat_errors_cancel_after_bounded_grace(monkeypatch):
- """Store uncertainty cannot let a run outlive its last confirmed lease forever."""
+ """Store uncertainty cannot let a run outlive its last confirmed lease forever.
+
+ The contract is elapsed-time based (grace since the last confirmed renewal), not a renewal
+ count: on a slow host the first wake can land after the grace, so cancellation after a single
+ failed renewal is correct (#111471). Assert the contract, never a minimum attempt count."""
import cron.scheduler as scheduler
from cron import scheduler_script as sched_script
@@ -674,6 +678,7 @@ def test_repeated_heartbeat_errors_cancel_after_bounded_grace(monkeypatch):
monkeypatch.setattr(scheduler, "_FIRE_CLAIM_HEARTBEAT_GRACE_SECONDS", 0.03)
assert scheduler.run_one_job(job) is True
+ assert calls >= 2, "cancellation must follow at least one failed renewal"
assert cancellation_after[0] >= scheduler._FIRE_CLAIM_HEARTBEAT_GRACE_SECONDS