You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably easiest to demonstrate with a failing test:
test 'sidekiq_uniqueness after clearing jobs' do
MyWorker.jobs.clear
assert_equal 0, MyWorker.jobs.size
MyWorker.perform_async
assert_equal 1, MyWorker.jobs.size
MyWorker.jobs.clear
assert_equal 0, MyWorker.jobs.size
MyWorker.perform_async
assert_equal 1, MyWorker.jobs.size
end
To break this down:
Any jobs for class MyWorker are removed from the queue. There are now 0 jobs in the queue.
I enqueue a job for class MyWorker. Now there's one job in the queue for that class.
I clear the jobs again so I can test another assertion. There are now 0 jobs in the queue.
I enqueue another job with the same class/parameters as in step 2. I would expect the queue to now have 1 job in it, because the previous job got cleared away.
MyWorker is unique until_executed. But with MyClass.jobs.clear, it's removed from the queue without being executed. It seems like the subsequent job is not being enqueued because it's a duplicate (not unique) relative to the one that got cleared away.
My assumption would be that, if you wanted to simulate the previous job being executed, you would use MyClass.drain. So if you're using MyClass.jobs.clear, which doesn't perform the job at all, and doesn't satisfy the until_executed condition, you're resetting the queue, and it should act as if the previous job was never there.
The text was updated successfully, but these errors were encountered:
This is probably easiest to demonstrate with a failing test:
To break this down:
MyWorker is unique until_executed. But with MyClass.jobs.clear, it's removed from the queue without being executed. It seems like the subsequent job is not being enqueued because it's a duplicate (not unique) relative to the one that got cleared away.
My assumption would be that, if you wanted to simulate the previous job being executed, you would use MyClass.drain. So if you're using MyClass.jobs.clear, which doesn't perform the job at all, and doesn't satisfy the until_executed condition, you're resetting the queue, and it should act as if the previous job was never there.
The text was updated successfully, but these errors were encountered: