From 4d362c999f63148a195bc24545633d21fec36e6c Mon Sep 17 00:00:00 2001 From: Keith Rarick Date: Thu, 15 Oct 2009 19:32:59 -0700 Subject: [PATCH] Test case for binlog read bug. --- sh-tests/binlog-read.sh | 105 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 sh-tests/binlog-read.sh diff --git a/sh-tests/binlog-read.sh b/sh-tests/binlog-read.sh new file mode 100755 index 00000000..efd64147 --- /dev/null +++ b/sh-tests/binlog-read.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +server=localhost +port=11400 +tmpdir="$TMPDIR" +test -z "$tmpdir" && tmpdir=/tmp +out1="${tmpdir}/bnch$$.1" +out2="${tmpdir}/bnch$$.2" +logdir="${tmpdir}/bnch$$.d" +nc='nc -q 1' +nc -q 1 2>&1 | grep -q option && nc='nc -w 1' # workaround for older netcat + +killbeanstalkd() { + { + test -z "$bpid" || kill -9 $bpid + /bin/true # Somehow this gets rid of an unnessary shell message. + } >/dev/null 2>&1 + bpid= +} + +cleanup() { + killbeanstalkd + rm -rf "$logdir" "$out1" "$out2" +} + +catch() { + echo '' Interrupted + exit 3 +} + +trap cleanup EXIT +trap catch HUP INT QUIT TERM + +if [ ! -x ./beanstalkd ]; then + echo "Executable ./beanstalkd not found; do you need to compile first?" + exit 2 +fi + +mkdir -p $logdir + +./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null & +bpid=$! + +sleep .1 +if ! ps -p $bpid >/dev/null; then + echo "Could not start beanstalkd for testing (possibly port $port is taken)" + exit 2 +fi + +$nc $server $port < "$out1" +use test +put 0 0 120 4 +test +put 0 0 120 4 +tes1 +watch test +reserve +release 1 1 1 +reserve +delete 2 +quit +EOF + +diff - "$out1" </dev/null 2>/dev/null & +bpid=$! + +sleep .1 +if ! ps -p $bpid >/dev/null; then + echo "Could not start beanstalkd for testing (possibly port $port is taken)" + exit 2 +fi + +$nc $server $port < "$out2" +watch test +reserve +delete 1 +delete 2 +EOF + +diff - "$out2" <