File: signal_test.rb

package info (click to toggle)
ruby-clockwork 4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 352 kB
  • sloc: ruby: 1,670; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require "minitest/autorun"
require 'mocha/minitest'
require 'fileutils'

describe "SignalTest" do
  before do
    @command = File.expand_path('../../bin/clockwork', __FILE__)
    @sample = File.expand_path('../samples/signal_test.rb', __FILE__)
    @logfile = File.expand_path('../tmp/signal_test.log', __FILE__)
    if ENV['ADTTMP']
      @command     = '/usr/bin/clockwork'
      @logfile = "/#{ENV['ADTTMP']}/signal_test.log"
    end
    FileUtils.mkdir_p(File.dirname(@logfile))
    @pid = spawn(@command, @sample)
    until File.exist?(@logfile)
      sleep 0.1
    end
  end

  after do
    FileUtils.rm_r(File.dirname(@logfile))
  end

  it 'should gracefully shutdown with SIGTERM' do
    Process.kill(:TERM, @pid)
    sleep 0.2
    assert_equal 'done', File.read(@logfile)
  end

  it 'should forcely shutdown with SIGINT' do
    Process.kill(:INT, @pid)
    sleep 0.2
    assert_equal 'start', File.read(@logfile)
  end
end