From 1a9a718a3f9a5b582a4a339a9bb9249c2ca392d7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 6 Nov 2009 19:45:17 -0800 Subject: cleanup worker heartbeat and master deathwatch It turns out neither the EventMachine and Rev classes checked for master death in its heartbeat mechanism. Since we managed to forget the same thing twice, we now have a test case for it and also centralized the code to remove duplication. --- t/t0007-worker-follows-master-to-death.sh | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 t/t0007-worker-follows-master-to-death.sh (limited to 't/t0007-worker-follows-master-to-death.sh') diff --git a/t/t0007-worker-follows-master-to-death.sh b/t/t0007-worker-follows-master-to-death.sh new file mode 100755 index 0000000..ac40277 --- /dev/null +++ b/t/t0007-worker-follows-master-to-death.sh @@ -0,0 +1,50 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 7 "ensure worker follows master to death" + +t_begin "setup" && { + rtmpfiles curl_err curl_out + rainbows_setup + echo timeout 3 >> $unicorn_config + rainbows -D -c $unicorn_config worker-follows-master-to-death.ru + rainbows_wait_start +} + +t_begin "read worker PID" && { + worker_pid=$(curl -sSf http://$listen/pid) + t_info "worker_pid=$worker_pid" +} + +t_begin "start a long sleeping request" && { + curl -sSfv -T- $curl_out 2> $fifo & + curl_pid=$! + t_info "curl_pid=$curl_pid" +} + +t_begin "nuke the master once we're connected" && { + awk -v rainbows_pid=$rainbows_pid ' +{ print $0 } +/100 Continue/ { + print "awk: sending SIGKILL to", rainbows_pid + system("kill -9 "rainbows_pid) +}' < $fifo > $curl_err + wait +} + +t_begin "worker is no longer running" && { + sleep 6 + kill -0 $worker_pid 2> $tmp && false + test -s $tmp +} + +t_begin "sleepy curl request is no longer running" && { + kill -0 $curl_pid 2> $tmp && false + test -s $tmp +} + +t_begin "sleepy curl request completed gracefully" && { + test x$(cat $curl_out) = x$worker_pid + dbgcat curl_err +} + +t_done -- cgit v1.2.3-24-ge0c7