Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent time-based failure in delayed sidekiq spec #947

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Bugs Fixed

* [#947](https://github.com/toptal/chewy/pull/947): Fix intermittent time-based failure in delayed sidekiq spec. ([@mjankowski][])

## 7.5.1 (2024-01-30)

### New Features
Expand Down
7 changes: 6 additions & 1 deletion spec/chewy/strategy/delayed_sidekiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
expect(Sidekiq::Client).to receive(:push).with(
hash_including(
'queue' => 'chewy',
'at' => (Time.current.to_i.ceil(-1) + 2.seconds).to_i,
'at' => expected_at_time.to_i,
'class' => Chewy::Strategy::DelayedSidekiq::Worker,
'args' => ['CitiesIndex', an_instance_of(Integer)]
)
Expand All @@ -62,6 +62,11 @@
end
end
end

def expected_at_time
target = described_class::Scheduler::DEFAULT_LATENCY.seconds.from_now.to_i
target - (target % described_class::Scheduler::DEFAULT_LATENCY) + described_class::Scheduler::DEFAULT_MARGIN.seconds
end
end

context 'with custom config' do
Expand Down