Sha256: 62428034bdcb4b5b1650b7099b4d9901d3d664903d3b25eaa680f597d6f58bcc

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

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

  let(:killer){ described_class.new }

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

    it 'expect right signal order' do
      expect(Kernel).to receive(:system).with('pumactl phased-restart').and_return(true)
      expect(Process).to receive(:kill).with(:KILL, anything).exactly(5).times

      thread = killer.kill(Time.now)
      thread.join

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
worker_killer-1.0.5.213977 spec/killer/puma_spec.rb
worker_killer-1.0.5.213889 spec/killer/puma_spec.rb