mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 01:57:15 +08:00
DEV: fix flaky spec (#29972)
Spec was flaky cause work could still be in pipeline after the defer length is 0. Our length denotes the backlog, not the in progress count. This adds a mechanism for gracefully stopping the queue and avoids wait_for callse
This commit is contained in:
@ -28,7 +28,7 @@ RSpec.describe Scheduler::Defer do
|
||||
@defer.later("second") {}
|
||||
@defer.later("bad") { raise "boom" }
|
||||
|
||||
wait_for(200) { @defer.length == 0 }
|
||||
@defer.stop!(finish_work: true)
|
||||
|
||||
stats = Hash[@defer.stats]
|
||||
|
||||
@ -105,11 +105,8 @@ RSpec.describe Scheduler::Defer do
|
||||
|
||||
it "can queue jobs properly" do
|
||||
s = nil
|
||||
|
||||
@defer.later { s = "good" }
|
||||
|
||||
wait_for(1000) { s == "good" }
|
||||
|
||||
@defer.stop!(finish_work: true)
|
||||
expect(s).to eq("good")
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user