[master] 8583f91 More coverage and fixes

Federico G. Schwindt fgsch at lodoss.net
Sun Apr 16 09:50:05 CEST 2017


commit 8583f91d99bd28aa99e4d354f4119ccf510a3e89
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sun Apr 16 08:48:55 2017 +0100

    More coverage and fixes

diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc
index adac521..b3559bb 100644
--- a/bin/varnishtest/tests/u00003.vtc
+++ b/bin/varnishtest/tests/u00003.vtc
@@ -7,8 +7,15 @@ server s1 -repeat 2 {
 
 varnish v1 -vcl+backend {
 	import std;
-	sub vcl_backend_fetch {
-		std.log("foo:qux");
+
+	sub vcl_recv {
+		if (req.url == "/2") {
+			return (pipe);
+		}
+	}
+
+	sub vcl_miss {
+		std.log("quux:quuz");
 	}
 } -start
 
@@ -20,7 +27,9 @@ shell {
 delay 1
 
 client c1 {
-	txreq -url /foo
+	txreq -url /1?foo=bar -hdr "baz: qux"
+	rxresp
+	txreq -url /1?foo=bar
 	rxresp
 } -run
 
@@ -30,7 +39,7 @@ shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log"
 shell "kill -HUP `cat ${tmpdir}/ncsa.pid`"
 
 client c1 {
-	txreq -url /bar
+	txreq -url /2
 	rxresp
 } -run
 
@@ -38,9 +47,13 @@ delay 1
 
 shell "kill `cat ${tmpdir}/ncsa.pid`"
 
-shell "grep -q /foo ${tmpdir}/ncsa.old.log"
-shell "grep -q /bar ${tmpdir}/ncsa.log"
+# default formatter and rotation
+shell -match {127.0.0.1 - - \[../.../20[1-9][0-9]:..:..:.. \+....\] (?#
+)"GET http://localhost/1\?foo=bar HTTP/1.1" 200 0 "-" "-"} \
+	"cat ${tmpdir}/ncsa.old.log"
+shell "grep -q /2 ${tmpdir}/ncsa.log"
 
+# command line
 shell -expect "Usage: varnishncsa <options>" \
 	"varnishncsa -h"
 shell -expect "Copyright (c) 2006 Verdens Gang AS" \
@@ -51,10 +64,10 @@ shell -err -expect "Unknown format specifier at: %{foo}A" \
 	{varnishncsa -F "%{foo}A"}
 shell -err -expect "Unknown format specifier at: %A" \
 	{varnishncsa -F "%A"}
+shell -err -expect "Unmatched bracket at: %{foo" \
+	"varnishncsa -F %{foo"
 shell -err -expect "Unknown formatting extension: foo" \
 	{varnishncsa -F "%{foo}x"}
-shell -err -expect "Usage: varnishncsa <options>" \
-	{varnishncsa extra}
 shell -err -expect "Missing tag in VSL:" \
 	{varnishncsa -F "%{VSL:}x"}
 shell -err -expect "Unknown log tag: nonexistent" \
@@ -69,9 +82,11 @@ shell -err -expect "Unknown log tag: Begin[a" \
 	{varnishncsa -F "%{VSL:Begin[a}x"}
 shell -err -expect "Syntax error: VSL:Begin[a]" \
 	{varnishncsa -F "%{VSL:Begin[a]}x"}
-shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \
+shell -err -match {Syntax error. (?#
+)Field specifier must be positive: Begin\[0\]} \
 	{varnishncsa -F "%{VSL:Begin[0]}x"}
-shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \
+shell -err -match {Field specifier 999999999999 for the tag (?#
+)VSL:Begin\[999999999999\] is probably too high} \
 	{varnishncsa -F "%{VSL:Begin[999999999999]}x"}
 shell -err -expect "Can't open format file (No such file or directory)" \
 	{varnishncsa -f /nonexistent/file}
@@ -81,11 +96,36 @@ shell -err -expect "Empty format file" \
 # directory but happily works in FreeBSD.
 #shell -err -expect "Can't read format from file (Is a directory)" \
 #	{varnishncsa -f ${tmpdir}}
+shell -err -expect "Invalid grouping mode: session" \
+	{varnishncsa -g session}
+shell -err -expect "Can't open output file (No such file or directory)" \
+	{varnishncsa -w /nonexistent/file}
+shell -err -expect "Usage: varnishncsa <options>" \
+	{varnishncsa extra}
 
-shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %{VCL_Log:foo}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format}
-shell -match "^req 1000 rxreq 1001  [0-9]+ 0 miss [A-Z]{3,}" \
+# -f and standard formatters
+shell {echo "%b %D %H %h %I %{baz}i %l %m %{Age}o %O %q %s %t %{%Y}t \
+%T %U %u" > ${tmpdir}/format}
+shell -match {^\d+ \d+ HTTP/1.1 127.0.0.1 \d+ qux - GET 0 \d+ (?#
+)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 -
+\d+ \d+ HTTP/1.1 127.0.0.1 \d+ - - GET 0 \d+ (?#
+)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 -
+- \d+ HTTP/1.1 127.0.0.1 \d+ - - GET - \d+ (?#
+) - \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /2 -$} \
 	{varnishncsa -n ${v1_name} -d -f ${tmpdir}/format}
-shell -match "^bereq 1001 fetch 1002 qux [0-9]+ 0 - [A-Z]{3,}" \
-	{varnishncsa -n ${v1_name} -d -f ${tmpdir}/format -b}
-shell -match "\d{10}\.\d{6} \d\.\d{6} \d\.\d{6} - \d{10}\.\d{6}" \
-	{varnishncsa -n ${v1_name} -d -F "%{VSL:Timestamp:Resp}x %{VSL:Timestamp:foo}x %{VSL:Timestamp:Resp[2]}x"}
+
+# extended variables
+shell -match {^\d+.\d{6} miss miss c 1001 quuz
+\d+.\d{6} hit hit c 1003\s
+\d+.\d{6} miss pipe c 1005\s$} \
+	{varnishncsa -n ${v1_name} -d -F "%{Varnish:time_firstbyte}x \
+%{Varnish:hitmiss}x %{Varnish:handling}x %{Varnish:side}x \
+%{Varnish:vxid}x %{VCL_Log:quux}x"}
+
+# %{VSL:..}x
+shell -match {^req (\d+) rxreq \1 \d{10}\.\d{6} (\d+\.\d{6}) \d+\.\d{6} \2 -
+req (\d+) rxreq \3 \d{10}\.\d{6} (\d+\.\d{6}) \d+\.\d{6} \4 -
+req (\d+) rxreq \5 - - -$} \
+	{varnishncsa -n ${v1_name} -d -F "%{VSL:Begin}x \
+%{VSL:Begin[2]}x %{VSL:Timestamp:Resp}x \
+%{VSL:Timestamp:Resp[2]}x %{VSL:Timestamp:foo}x"}



More information about the varnish-commit mailing list