test(cron): stabilize heartbeat grace assertion
This commit is contained in:
@@ -647,17 +647,21 @@ def test_repeated_heartbeat_errors_cancel_after_bounded_grace(monkeypatch):
|
||||
import cron.scheduler as scheduler
|
||||
from cron import scheduler_script as sched_script
|
||||
|
||||
last_confirmed_at = []
|
||||
cancellation_after = []
|
||||
calls = 0
|
||||
|
||||
def heartbeat(*_args, **_kwargs):
|
||||
nonlocal calls
|
||||
calls += 1
|
||||
if calls == 1:
|
||||
last_confirmed_at.append(time.monotonic())
|
||||
return True
|
||||
raise OSError("store unavailable")
|
||||
|
||||
def run_body(_job, **kwargs):
|
||||
assert kwargs["fire_claim_lost"].wait(timeout=0.5)
|
||||
cancellation_after.append(time.monotonic() - last_confirmed_at[0])
|
||||
return True
|
||||
|
||||
job = {
|
||||
@@ -670,7 +674,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 >= 3
|
||||
assert cancellation_after[0] >= scheduler._FIRE_CLAIM_HEARTBEAT_GRACE_SECONDS
|
||||
|
||||
|
||||
def test_terminal_owner_cas_failure_marks_ledger_ownership_lost(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user