🐛 Fix flaky heartbeat throttle test on same-millisecond writes

Submit and heartbeat can land in the same millisecond, which made
the strict modified-at > created-at assertion fail intermittently.
Backdate modified-at before the first heartbeat so the write is
always observable, keeping the strict comparison.

AI-assisted-by: muse-spark-1.3-contributor
This commit is contained in:
Andrey Antukh committed 2026-09-17 20:34:08 +02:00
1 parent 0739148a20
commit 381eec07e2
1 file changed
+4
+4
View File
@@ -256,6 +256,10 @@
::jobs/params (make-params)})]
(t/testing "first heartbeat writes"
;; Backdate modified-at: submit and heartbeat can land in the same
;; millisecond, which would make a strict > assertion flaky.
(th/db-update! :job {:modified-at (ct/in-past {:seconds 5})}
{:id job-id})
(jobs/heartbeat! cfg job-id)
(let [row (jobs/get-job cfg job-id)]
(t/is (> (inst-ms (:modified-at row)) (inst-ms (:created-at row))))))