Sha256: dbedbd6ad7c4f0b96caecf8118bb0e737636a72adbc5c4640a41848434dc60aa

Contents?: true

Size: 965 Bytes

Versions: 11

Compression:

Stored size: 965 Bytes

Contents

RSpec.describe WorkerKiller::Killer::DelayedJob do
  let(:config) do
    WorkerKiller::Configuration.new.tap do |c|
      c.quit_attempts = 2
      c.term_attempts = 2
    end
  end

  let(:dj){ double }
  subject(:killer){ described_class.new() }

  describe '#kill' do
    context 'with use_quit TRUE' do
      around do |example|
        prev = WorkerKiller.configuration
        WorkerKiller.configuration = config
        example.run
      ensure
        WorkerKiller.configuration = prev
      end

      it 'expect right signal order' do
        expect(dj).to receive(:stop).exactly(4)
        expect(Process).to receive(:kill).with(:TERM, anything).exactly(1).times
        expect(Process).to receive(:kill).with(:KILL, anything).exactly(5).times

        2.times { killer.kill(Time.now, dj: dj) } # 1 QUIT
        2.times { killer.kill(Time.now, dj: dj) } # 1 TERM
        5.times { killer.kill(Time.now, dj: dj) } # 5 KILL
      end
    end
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
worker_killer-1.1.0.223443 spec/killer/delayed_job_spec.rb
worker_killer-1.1.0.214159 spec/killer/delayed_job_spec.rb
worker_killer-1.1.0.214146 spec/killer/delayed_job_spec.rb
worker_killer-1.0.5.213977 spec/killer/delayed_job_spec.rb
worker_killer-1.0.5.213889 spec/killer/delayed_job_spec.rb
worker_killer-1.0.4.189871 spec/killer/delayed_job_spec.rb
worker_killer-1.0.3.189564 spec/killer/delayed_job_spec.rb
worker_killer-1.0.3.189098 spec/killer/delayed_job_spec.rb
worker_killer-1.0.2.187852 spec/killer/delayed_job_spec.rb
worker_killer-1.0.2.187805 spec/killer/delayed_job_spec.rb
worker_killer-1.0.2.187732 spec/killer/delayed_job_spec.rb