Commit 24472cf7 authored by Geoff Simmons's avatar Geoff Simmons

varnishevent: more testing against the output of varnishncsa

parent d242c32c
......@@ -3,31 +3,64 @@
# Outputs of varnishevent and varnishncsa for client formats are
# identical, except that varnishevent emits empty strings for data
# from headers that are empty, and varnishnca emits a '-'.
#
# Unfortunately an exact comparison cannot be made, because
# varnishncsa seems to have some errors (URL entries apparently not
# always cleanly cleared). So we check that the nummber of diff hunks
# is not greater than a threshold.
echo
echo "TEST: $0"
echo "... testing (near) equivalence of output with varnishncsa"
TMP=${TMPDIR:-/tmp}
EVENT="../varnishevent"
NCSA="../../varnishncsa/varnishncsa"
EVENT_CKSUM=$( $EVENT -r varnish.binlog | sed 's/-//g' | cksum)
NCSA_CKSUM=$( $NCSA -r varnish.binlog | sed 's/-//g' | cksum)
EVENT_LOG=$TMP/event.log
NCSA_LOG=$TMP/ncsa.log
if [ "$EVENT_CKSUM" != "$NCSA_CKSUM" ]; then
echo "ERROR: cksums of no-arg varnishevent and varnishncsa differ"
echo "varnishevent cksum = $EVENT_CKSUM"
echo "varnishncsa cksum = $NCSA_CKSUM"
DIFF_CMD="diff -U 0 $EVENT_LOG $NCSA_LOG"
HUNK_THRESH=1
$EVENT -r varnish.binlog | sed 's/-//g' > $EVENT_LOG
$NCSA -r varnish.binlog | sed 's/-//g' > $NCSA_LOG
HUNKS=$($DIFF_CMD | grep ^@ | wc -l)
rm $EVENT_LOG
rm $NCSA_LOG
if [ "$HUNKS" -gt "$HUNK_THRESH" ]; then
echo "ERROR: outputs of no-arg varnishevent and varnishncsa differ"
echo "$HUNKS diff hunks"
exit 1
fi
$EVENT -r varnish.binlog -f | sed 's/-//g' > $EVENT_LOG
$NCSA -r varnish.binlog -f | sed 's/-//g' > $NCSA_LOG
HUNKS=$($DIFF_CMD | grep ^@ | wc -l)
rm $EVENT_LOG
rm $NCSA_LOG
if [ "$HUNKS" -gt "$HUNK_THRESH" ]; then
echo "ERROR: outputs of varnishevent/varnishncsa -f differ"
echo "$HUNKS diff hunks"
exit 1
fi
EVENT_CKSUM=$( $EVENT -r varnish.binlog -f | sed 's/-//g' | cksum)
NCSA_CKSUM=$( $NCSA -r varnish.binlog -f | sed 's/-//g' | cksum)
FORMAT="%b %H %h %{Host}i %{User-Agent}i %{Accept-Ranges}o %{Age}o %{Connection}o %{Content-Length}o %{Content-Type}o %{Date}o %{ETag}o %{Last-Modified}o %{Server}o %{Transfer-Encoding}o %{Vary}o %{Via}o %{X-Varnish}o %l %m %q %r %s %t %{%F-%T}t %U %u %{Varnish:time_firstbyte}x %{Varnish:hitmiss}x %{Varnish:handling}x %{VCL_Log:xid}x"
$EVENT -r varnish.binlog -F $FORMAT | sed 's/-//g' > $EVENT_LOG
$NCSA -r varnish.binlog -F $FORMAT | sed 's/-//g' > $NCSA_LOG
HUNKS=$($DIFF_CMD | grep ^@ | wc -l)
rm $EVENT_LOG
rm $NCSA_LOG
if [ "$EVENT_CKSUM" != "$NCSA_CKSUM" ]; then
echo "ERROR: cksums of no-arg varnishevent/varnishncsa -f differ"
echo "varnishevent cksum = $EVENT_CKSUM"
echo "varnishncsa cksum = $NCSA_CKSUM"
if [ "$HUNKS" -gt "$HUNK_THRESH" ]; then
echo "ERROR: outputs of varnishevent/varnishncsa -F differ"
echo "$HUNKS diff hunks"
exit 1
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment