unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 93d8c60cd537c00c7462b5e7eb89e3c044de39e4 1021 bytes (raw)
$ git show v4.4.0:t/t0010-reap-logging.sh	# shows this blob on the CLI

 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
#!/bin/sh
. ./test-lib.sh
t_plan 9 "reap worker logging messages"

t_begin "setup and start" && {
	unicorn_setup
	cat >> $unicorn_config <<EOF
after_fork { |s,w| File.open('$fifo','w') { |f| f.write '.' } }
EOF
	unicorn -c $unicorn_config pid.ru &
	test '.' = $(cat $fifo)
	unicorn_wait_start
}

t_begin "kill 1st worker=0" && {
	pid_1=$(curl http://$listen/)
	kill -9 $pid_1
}

t_begin "wait for 2nd worker to start" && {
	test '.' = $(cat $fifo)
}

t_begin "ensure log of 1st reap is an ERROR" && {
	dbgcat r_err
	grep 'ERROR.*reaped.*worker=0' $r_err | grep $pid_1
	dbgcat r_err
	> $r_err
}

t_begin "kill 2nd worker gracefully" && {
	pid_2=$(curl http://$listen/)
	kill -QUIT $pid_2
}

t_begin "wait for 3rd worker=0 to start " && {
	test '.' = $(cat $fifo)
}

t_begin "ensure log of 2nd reap is a INFO" && {
	grep 'INFO.*reaped.*worker=0' $r_err | grep $pid_2
	> $r_err
}

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

t_begin "check stderr" && {
	check_stderr
}

t_done

git clone https://yhbt.net/unicorn.git