I need to test a worker on Rspec, to Find how many times the same worker being called again and again in recursive manner. Eg:
Class Myworker
def perform(id)
model = Mymodel.find(id)
associated_records = Mymodel.users.limit(1000)
associated_records.each(&:destroy)
if Mymodel.users.exists?
Myworker.perform_async(id)
end
end
end
i need to write rpsec for this to count how many times this iteration happend,
i have tried to stub the worker, and incrementing counter, since i'm stubbing the worker it doesn't execute the same worker again and i'm struck with counter 1 as final value. How to find how many times the worker being called recursively in RSPEC.
You are right that when deleting huge amounts of database records, then the job will need more time and ultimately delay other background jobs.
But that should really be an issue because usually you will have multiple workers running at the same time anyway. And when you still have issues with multiple huge jobs delaying more important jobs, then you should think about having multiple queues with different priorities.
When you have multiple priority queues configured in Sidekiq then you can change your job to run on a low priority queue and not block the critical or default queue like this: