Skip to content

Commit a906d55

Browse files
committed
Add test for failure backend being notified from job killed by signal.
1 parent 23b18bf commit a906d55

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/worker_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,5 +689,28 @@ def self.perform( run_time, rescue_time=nil )
689689
end
690690
end
691691
end
692+
693+
class SuicidalJob
694+
@queue = :jobs
695+
696+
def self.perform
697+
Process.kill('KILL', Process.pid)
698+
end
699+
700+
def self.on_failure_store_exception(exc, *args)
701+
@@failure_exception = exc
702+
end
703+
end
704+
705+
it "will notify failure hooks when a job is killed by a signal" do
706+
begin
707+
$TESTING = false
708+
Resque.enqueue(SuicidalJob)
709+
@worker.work(0)
710+
assert_equal Resque::DirtyExit, SuicidalJob.class_variable_get(:@@failure_exception).class
711+
ensure
712+
$TESTING = true
713+
end
714+
end
692715
end
693716
end

0 commit comments

Comments
 (0)