Sha256: b50e89b39dcc0856233af4d666cc7ff9ec6dbac110eb82d9a09da25983fe5815

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

#!/bin/sh
. ./test-lib.sh
t_plan 5 "before murder is called only once"

t_begin "setup and start" && {
	unicorn_setup
	cat >> $unicorn_config <<EOF
timeout 5
after_fork { |s,w| File.open('$fifo','w') { |f| f.write '.' } }
class Unicorn::HttpServer
  alias_method :kill_worker_always, :kill_worker
  def kill_worker(signal, wpid)
    @iteration ||= 0
    \$stderr.puts "kill_worker #{signal} #{wpid} #{@iteration}"
    kill_worker_always(signal, wpid) if @iteration > 0
    @iteration += 1
  end
end
before_murder do |s, w, p| 
  \$stderr.puts "before murder called:"
end
EOF
	unicorn -c $unicorn_config before_murder.ru &
	test '.' = $(cat $fifo)
	unicorn_wait_start
}

t_begin "start worker=0" && {
	pid=$(curl http://$listen/) || true
}

t_begin "ensure before murder log is present once and killing is present twice" && {
	dbgcat r_err
	grep 'before murder called:' $r_err 
  test 1 -eq $(grep "before murder called:" $r_err | count_lines)
  test 2 -eq $(grep timeout $r_err | grep killing | count_lines)
  test 2 -eq $(grep "kill_worker KILL" $r_err | count_lines)
	dbgcat r_err
	> $r_err
}

t_begin "killing succeeds" && {
  kill $unicorn_pid
  wait
  kill -0 $unicorn_pid && false
}

t_begin "check stderr" && {
	check_stderr
}

t_done

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
unicorn-shopify-5.3.0 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.6 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.5 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.4 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.3 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.2 t/t0024-before-murder_once.sh
unicorn-shopify-5.2.0.1 t/t0024-before-murder_once.sh
unicorn-shopify-4.8.2.5.25 t/t0024-before-murder_once.sh
unicorn-shopify-4.8.2.5.24 t/t0024-before-murder_once.sh
unicorn-shopify-4.8.2.5.23 t/t0024-before-murder_once.sh