Sha256: 11ad8732341f665c5a95d00d6712181f5fc954f013e5509778d8b877d891dad2

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
require_relative 'helper'
require 'sidekiq/manager'

class TestManager < Sidekiq::Test

  describe 'manager' do
    before do
      Sidekiq.redis {|c| c.flushdb }
    end

    def new_manager(opts)
      Sidekiq::Manager.new(opts)
    end

    it 'creates N processor instances' do
      mgr = new_manager(options)
      assert_equal options[:concurrency], mgr.workers.size
    end

    it 'shuts down the system' do
      mgr = new_manager(options)
      mgr.stop(Time.now)
    end

    it 'throws away dead processors' do
      mgr = new_manager(options)
      init_size = mgr.workers.size
      processor = mgr.workers.first
      begin
        mgr.processor_died(processor, 'ignored')

        assert_equal init_size, mgr.workers.size
        refute mgr.workers.include?(processor)
      ensure
        mgr.workers.each {|p| p.terminate(true) }
      end
    end

    it 'does not support invalid concurrency' do
      assert_raises(ArgumentError) { new_manager(concurrency: 0) }
      assert_raises(ArgumentError) { new_manager(concurrency: -1) }
    end

    def options
      { :concurrency => 3, :queues => ['default'] }
    end

  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
sidekiq-5.0.0.beta1 test/test_manager.rb
sidekiq-4.2.9 test/test_manager.rb
sidekiq-4.2.8 test/test_manager.rb
sidekiq-4.2.7 test/test_manager.rb
sidekiq-4.2.6 test/test_manager.rb
sidekiq-4.2.5 test/test_manager.rb
sidekiq-4.2.4 test/test_manager.rb
sidekiq-4.2.3 test/test_manager.rb
sidekiq-4.2.2 test/test_manager.rb
sidekiq-4.2.1 test/test_manager.rb
sidekiq-4.2.0 test/test_manager.rb
sidekiq-4.1.4 test/test_manager.rb
sidekiq-4.1.3 test/test_manager.rb
sr-sidekiq-4.1.6 test/test_manager.rb
sidekiq-4.1.2 test/test_manager.rb