Skip to content

Commit c2c4466

Browse files
lukas8219claude
andcommitted
Fix flaky ack_count assertion in prometheus spec
Use synchronous basic_get instead of async subscribe to avoid a race where server-side ack processing hasn't completed before metrics are fetched. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4aa0a98 commit c2c4466

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

spec/api/prometheus_spec.cr

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,12 @@ describe LavinMQ::HTTP::PrometheusController do
223223
# Publish 2 messages
224224
2.times { q.publish "test message" }
225225

226-
# Consume and ack both via subscribe
227-
delivered_count = 0
228-
q.subscribe(no_ack: false) do |delivery|
229-
delivered_count += 1
230-
delivery.ack
226+
# Consume and ack both via basic_get (synchronous)
227+
2.times do
228+
msg = q.get(no_ack: false)
229+
msg.should_not be_nil
230+
msg.try &.ack
231231
end
232-
wait_for { delivered_count == 2 }
233232

234233
raw = http.get("/metrics/detailed?family=queue_coarse_metrics").body
235234
parsed = PrometheusSpecHelper.parse_prometheus(raw)

0 commit comments

Comments
 (0)