Guest User

Untitled

a guest
Oct 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. # Control Sidekiq mode in specs
  2. before do
  3. Sidekiq::Testing.disable! # will now actually persist to redis
  4. end
  5.  
  6. after do
  7. Sidekiq::Testing.fake! # will push to fake jobs array
  8. end
  9.  
  10. # Retrieve fake jobs
  11. # Tender::AsyncJob::ApplicationExpiry::Worker.jobs.size
  12. #
  13. # Execute fake jobs
  14. # Tender::AsyncJob::ApplicationExpiry::Worker.drain
  15.  
  16. # Clear sidekiq data between examples
  17.  
  18. RSpec.configure do |config|
  19. config.before do
  20. # Clear jobs in fake mode
  21. Sidekiq::Worker.clear_all
  22.  
  23. # Clear real jobs
  24. Sidekiq::RetrySet.new.clear
  25. Sidekiq::ScheduledSet.new.clear
  26.  
  27. # Clear 'Dead' jobs statistics
  28. Sidekiq::DeadSet.new.clear
  29.  
  30. # Clear 'Processed' and 'Failed' jobs statistics
  31. Sidekiq::Stats.new.reset
  32.  
  33. # Clear jobs pushed to queue
  34. Sidekiq::Queue.new.clear
  35. end
  36. end
  37.  
  38. # Cancel sidekiq job
  39. # Uses linear search so might be very slow if queue is large
  40. job = Sidekiq::ScheduledSet.new.find_job([tender_async_job[:jid]])
  41.  
  42. job.delete if job.present?
Add Comment
Please, Sign In to add comment