Skip to content

Commit

Permalink
fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankithads committed Jul 3, 2024
1 parent fa362d4 commit c5c9714
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions spec/lib/que/locker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ def expect_to_lock_with(cursor:)
context "with non-zero cursor expiry" do
let(:cursor_expiry) { 5 }

before { allow(locker).to receive(:monotonic_now) { @epoch } }

before do
# we need this to avoid flakiness during resetting the cursor
locker.instance_variable_get(:@queue_expires_at)[queue] = Process.clock_gettime(Process::CLOCK_MONOTONIC) + cursor_expiry
allow(locker).to receive(:monotonic_now) { @epoch }
end
# This test simulates the repeated locking of jobs. We're trying to prove that
# the locker will use the previous jobs ID as a cursor until the expiry has
# elapsed, after which we'll reset.
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/que/middleware/queue_collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe Que::Middleware::QueueCollector do
subject(:collector) { described_class.new(->(_env) { nil }, options) }
let(:options) { {} }
let(:options) { {refresh_interval: 1.second} }
let(:now) { postgres_now }
let(:due_now_delay) { 1000.0 }
let(:due_later_than_now_delay) { due_now_delay / 2 }
Expand Down

0 comments on commit c5c9714

Please sign in to comment.