-
-
Notifications
You must be signed in to change notification settings - Fork 277
Use sidekiq/testing Worker.clear
API in sidekiq_unique_jobs/testing
#713
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
Use sidekiq/testing Worker.clear
API in sidekiq_unique_jobs/testing
#713
Conversation
Instead of reimplementing the logic, we use the upstream `Worker.clear` API in the `sidekiq_unique_jobs/testing` `Worker.clear` overwrite. This fixes an issue that causes an infinite loop in `drain_all` after calling `clear` on a worker class that has it's queue name defined as a symbol. Because `sidekiq/testing` uses strings as the keys for the internal state tracking calling `Sidekiq::Queues[queue].clear` cleared a queue that never contained a job, while leaving jobs in the "string-indexed" queue. This only actually works after [this][1] is merged into `sidekiq` until then the old behaviour remains the same (clearing workers with their queue name defined as strings is fine). [1]: sidekiq/sidekiq#5352
119c643
to
68872b2
Compare
@dsander @mhenrixon I think this change may have introduced very noisy logging into all test runs: (This rspec test is completely unrelated to jobs and sidekiq-unique-jobs.) Is that possible? |
@fotinakis Unsure, are you maybe using |
@dsander interesting — yes, apparently we are doing this in our main spec_helper: config.before(:each) { Sidekiq::Worker.clear_all } I've disabled the sidekiq-unique-jobs logger in tests as a workaround for now. I'm not sure if you'd consider this a common flow/bug or not, so will just silence it on our end for now. |
@fotinakis I don't think it is a bug, before this change the |
FYI that many more people may encounter this noisy logging once this is released — apparently calling |
FWIW we don't see it in our test suite, but that might be because of the log level. I'd need to double check if we have set it to |
Actually @fotinakis the reason for why you see this now is most likely that it wasn't working before. I agree on bumping the log level. Rails for example almost completely turn off logging manually enabled in the test environment. I think it is valuable information that keys are being deleted and since I don't know how to check what environment your code is running in I'd rather leave that to the user. Please let me know if you differ in opinion and or have any solutions to this that I haven't thought of. |
Instead of reimplementing the logic, we use the upstream
Worker.clear
APIin the
sidekiq_unique_jobs/testing
Worker.clear
overwrite.This fixes an issue that causes an infinite loop in
drain_all
aftercalling
clear
on a worker class that has it's queue name defined as asymbol. Because
sidekiq/testing
uses strings as the keys for theinternal state tracking calling
Sidekiq::Queues[queue].clear
cleared aqueue that never contained a job, while leaving jobs in the
"string-indexed" queue.
This only actually works after this is merged into
sidekiq
untilthen the old behaviour remains the same (clearing workers with their
queue name defined as strings is fine).