breamware / sidekiq-batch

Sidekiq Batch Jobs Implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RSpec testing and Stats not updating

lerxcl opened this issue · comments

Here is my block of code:

it "has the jobs completed" do |example|
  b = Sidekiq::Batch.new
  b.jobs do
    3.times {Sidekiq::Worker.perform_async(Time.now.to_i,nil)}
  end
  Sidekiq::Worker.perform_one
  status = Sidekiq::Batch::Status.new(b.bid)
end

Here is my status output:
#<Sidekiq::Batch::Status:0x000000010c682808 @bid="4tR00OKDnnKWdA", @completed=0, @failures=0, @pending=3, @props={"created_at"=>"1675329197.732366", "callbacks"=>"{}", "pending"=>"3", "total"=>"3"}, @total=3>

For pending, it is still stuck at 3, where it should have been 2 from perform_one, where it will execute and finish the 1st job in the batch.

I have also used the flag stub_batches: false to use a real Sidekiq Worker to execute these dummy jobs.
May I know how is the Status for pending calculated?
Thank you!

Hi, i am facing a similar issue with Rspec in my tests. Do you have any suggestions or guides on how to do it?