[master] 44ab999 Merge, simplify and add more coverage

Federico G. Schwindt fgsch at lodoss.net
Fri Jan 20 22:41:05 CET 2017


commit 44ab9990d0ce1bc01cb38ea9d8f171ef972fec75
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Fri Jan 20 20:31:30 2017 +0000

    Merge, simplify and add more coverage

diff --git a/bin/varnishtest/tests/u00001.vtc b/bin/varnishtest/tests/u00001.vtc
deleted file mode 100644
index b06a315..0000000
--- a/bin/varnishtest/tests/u00001.vtc
+++ /dev/null
@@ -1,43 +0,0 @@
-varnishtest "varnishncsa log file rotation"
-
-server s1 {
-	rxreq
-	expect req.url == "/foo"
-	txresp -status 200
-
-	rxreq
-	expect req.url == "/bar"
-	txresp -status 404
-} -start
-
-varnish v1 -vcl+backend "" -start
-
-shell "varnishncsa -D -P ${tmpdir}/ncsa.pid -n ${v1_name} -w ${tmpdir}/ncsa.log -F %s"
-
-# give varnishncsa enough time to open the VSM
-delay 2
-
-client c1 {
-	txreq -url "/foo"
-	rxresp
-} -run
-
-# give varnishncsa enough time to write
-delay 2
-
-# rotate logs
-shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log >/dev/null 2>&1"
-shell "kill -HUP `cat ${tmpdir}/ncsa.pid`"
-
-client c1 {
-	txreq -url "/bar"
-	rxresp
-} -run
-
-# give varnishncsa enough time to write
-delay 2
-
-shell "kill `cat ${tmpdir}/ncsa.pid`"
-
-shell "grep 200 ${tmpdir}/ncsa.old.log >/dev/null"
-shell "grep 404 ${tmpdir}/ncsa.log >/dev/null"
diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc
index 6737762..4b7eba2 100644
--- a/bin/varnishtest/tests/u00003.vtc
+++ b/bin/varnishtest/tests/u00003.vtc
@@ -1,35 +1,71 @@
-varnishtest "varnishncsa error handling"
+varnishtest "varnishncsa coverage"
 
-server s1 {
+server s1 -repeat 2 {
 	rxreq
 	txresp
 } -start
 
 varnish v1 -vcl+backend {} -start
 
+shell "varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log"
+
 shell -err -expect "Missing -w option" \
-	{varnishncsa -n ${v1_name} -D}
+	{varnishncsa -D}
 shell -err -expect "Unknown format specifier at: %{foo}A" \
-	{varnishncsa -n ${v1_name} -F "%{foo}A"}
+	{varnishncsa -F "%{foo}A"}
 shell -err -expect "Unknown format specifier at: %A" \
-	{varnishncsa -n ${v1_name} -F "%A"}
+	{varnishncsa -F "%A"}
+shell -err -expect "Unknown formatting extension: foo" \
+	{varnishncsa -F "%{foo}x"}
 shell -err -expect "Usage: varnishncsa <options>" \
-	{varnishncsa -n ${v1_name} extra}
+	{varnishncsa extra}
 shell -err -expect "Missing tag in VSL:" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:}x"}
+	{varnishncsa -F "%{VSL:}x"}
 shell -err -expect "Unknown log tag: nonexistent" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:nonexistent}x"}
+	{varnishncsa -F "%{VSL:nonexistent}x"}
 shell -err -expect "Tag not unique: Req" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Req}x"}
+	{varnishncsa -F "%{VSL:Req}x"}
 shell -err -expect "Unknown log tag: Begin[" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin[}x"}
+	{varnishncsa -F "%{VSL:Begin[}x"}
 shell -err -expect "Syntax error: VSL:Begin]" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin]}x"}
+	{varnishncsa -F "%{VSL:Begin]}x"}
 shell -err -expect "Unknown log tag: Begin[a" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin[a}x"}
+	{varnishncsa -F "%{VSL:Begin[a}x"}
 shell -err -expect "Syntax error: VSL:Begin[a]" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin[a]}x"}
+	{varnishncsa -F "%{VSL:Begin[a]}x"}
 shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin[0]}x"}
+	{varnishncsa -F "%{VSL:Begin[0]}x"}
 shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \
-	{varnishncsa -n ${v1_name} -F "%{VSL:Begin[999999999999]}x"}
+	{varnishncsa -F "%{VSL:Begin[999999999999]}x"}
+shell -err -expect "Can't open format file (No such file or directory)" \
+	{varnishncsa -n ${v1_name} -f /nonexistent}
+shell -err -expect "Empty format file" \
+	{varnishncsa -n ${v1_name} -f /dev/null}
+
+delay 1
+
+client c1 {
+	txreq -url /foo
+	rxresp
+} -run
+
+delay 1
+
+shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log >/dev/null 2>&1"
+shell "kill -HUP `cat ${tmpdir}/ncsa.pid`"
+
+client c1 {
+	txreq -url /bar
+	rxresp
+} -run
+
+delay 1
+
+shell "kill `cat ${tmpdir}/ncsa.pid`"
+
+shell "grep -q /foo ${tmpdir}/ncsa.old.log"
+shell "grep -q /bar ${tmpdir}/ncsa.log"
+
+shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format}
+shell -expect "0 miss GMT" \
+	{varnishncsa -n ${v1_name} -d -f ${tmpdir}/format}
diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc
index 5721a2b..8b2861a 100644
--- a/bin/varnishtest/tests/u00006.vtc
+++ b/bin/varnishtest/tests/u00006.vtc
@@ -1,19 +1,20 @@
 varnishtest "varnishlog coverage"
 
-server s1 {
+server s1 -repeat 2 {
 	rxreq
 	txresp
 } -start
 
 varnish v1 -vcl+backend {} -start
 
-process p1 "exec varnishlog -n ${v1_name} -g raw -k 1" -start
-process p2 {
-	exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p2/output -A
-} -start
-process p3 {
-	exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p3/output.bin
+process p1 {
+	exec varnishlog -n ${v1_name} -g raw -k 3 -w ${tmpdir}/vlog -A
 } -start
+shell {
+	exec varnishlog -n ${v1_name} -D -P ${tmpdir}/vlog.pid \
+	    -w ${tmpdir}/vlog.bin
+}
+
 shell -expect "Usage: varnishlog <options>" \
 	"varnishlog -h"
 shell -expect "Copyright (c) 2006 Verdens Gang AS" \
@@ -38,9 +39,31 @@ shell -err -expect {-x: Syntax error in "**"} \
 	{varnishlog -x "**"}
 shell -err -expect {-X: Syntax error in "**"} \
 	{varnishlog -X "**:bar"}
+
 process p1 -wait
-shell {grep -q "0 CLI" ${p1_out}}
-process p2 -wait
-shell {grep -q "0 CLI" ${p2_dir}/output}
-process p3 -wait
-shell -expect "0 CLI" {varnishlog -g raw -r ${p3_dir}/output.bin}
+shell {grep -q "0 CLI" ${tmpdir}/vlog}
+shell -expect "0 CLI" "varnishlog -n ${v1_name} -d -g raw"
+
+client c1 {
+	txreq -url /foo
+	rxresp
+} -run
+
+delay 1
+
+shell "mv ${tmpdir}/vlog.bin ${tmpdir}/vlog.bin~ >/dev/null 2>&1"
+shell "kill -HUP `cat ${tmpdir}/vlog.pid`"
+
+client c1 {
+	txreq -url /bar
+	rxresp
+} -run
+
+delay 1
+
+shell "kill `cat ${tmpdir}/vlog.pid`"
+
+shell -expect "/foo" {
+	varnishlog -r ${tmpdir}/vlog.bin~ -i ReqURL -q "RespStatus == 200"
+}
+shell -expect "/bar" "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL"
diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc
index 444c07c..b1bd0a2 100644
--- a/bin/varnishtest/tests/u00007.vtc
+++ b/bin/varnishtest/tests/u00007.vtc
@@ -8,20 +8,20 @@ server s1 {
 varnish v1 -vcl+backend {} -start
 
 shell -expect "Usage: varnishhist <options>" \
-	"varnishhist -n ${v1_name} -h"
+	"varnishhist -h"
 shell -err -expect "Usage: varnishhist <options>" \
-	"varnishhist -n ${v1_name} extra"
+	"varnishhist extra"
 shell -err -expect "-p: invalid '0'" \
-	"varnishhist -n ${v1_name} -p 0"
+	"varnishhist -p 0"
 shell -err -expect "-B: being able to bend time does not mean we can stop it" \
-	"varnishhist -n ${v1_name} -B 0"
+	"varnishhist -B 0"
 shell -err -expect "-B: being able to bend time does not mean we can make it go backwards" \
-	"varnishhist -n ${v1_name} -B -1"
+	"varnishhist -B -1"
 shell -err -expect "Invalid grouping mode: raw" \
-	"varnishhist -n ${v1_name} -g raw"
+	"varnishhist -g raw"
 shell -err -expect "-P: No such profile 'foo'" \
-	"varnishhist -n ${v1_name} -P foo"
+	"varnishhist -P foo"
 shell -err -expect "-P: 'foo:bar' is not a valid profile name or definition" \
-	"varnishhist -n ${v1_name} -P foo:bar"
+	"varnishhist -P foo:bar"
 shell -err -expect "-P: 'foo:0:0:0' is not a valid tag name" \
-	"varnishhist -n ${v1_name} -P foo:0:0:0"
+	"varnishhist -P foo:0:0:0"



More information about the varnish-commit mailing list