Skip to content
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

Integration testing problems #26

Open
karloscodes opened this issue Jun 25, 2014 · 3 comments
Open

Integration testing problems #26

karloscodes opened this issue Jun 25, 2014 · 3 comments

Comments

@karloscodes
Copy link

Question: I have set Sidekiq::Testing.inline! under spec_helper for my integration tests, is there anything similar on superworkers? I need to run workers and wait for they to finish in order to perform some asserts, how can this be achieved?

@HParker
Copy link

HParker commented May 14, 2015

Running into the same kind of issue now. Did you find a solution that works for you?

@skwp
Copy link

skwp commented Sep 3, 2015

This is not particularly elegant, but you can override the Superworker in your own project like this (put this in spec_helper or some required file from there):

module Sidekiq
  module Superworker
    class SuperjobProcessor
      def self.create(superjob_id, superworker_class_name, args, subjobs, options={})
        if Sidekiq::Testing.inline?
          subjobs.each do |subjob|
            SubjobProcessor.enqueue(subjob)
          end
        else
          super
        end
      end
    end
  end
end

@m-pod
Copy link

m-pod commented Jan 29, 2016

With batched workers this worked for me by monkey_patching it in spec_helper like @skwp proposed:

require 'sidekiq-superworker'
module Sidekiq
  module Superworker
    class SuperjobProcessor
      def self.create(superjob_id, superworker_class_name, args, subjobs, options={})
        if Sidekiq::Testing.inline?
          subjobs.each do |subjob|
            SubjobProcessor.enqueue(subjob) unless subjob.subworker_class == 'batch_child'
          end 
        else
          super
        end 
      end 
    end 
  end 
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants