[master] bd007e8 Forgot to git add this one some days ago
Poul-Henning Kamp
phk at varnish-cache.org
Thu Mar 24 10:45:00 CET 2011
commit bd007e8310e557eb828dbc4ab6e579dfc958d344
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Mar 22 12:50:48 2011 +0000
Forgot to git add this one some days ago
diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc
new file mode 100644
index 0000000..80dfb74
--- /dev/null
+++ b/bin/varnishtest/tests/m00005.vtc
@@ -0,0 +1,90 @@
+# $Id$
+
+test "test vmod_std.duration conversion"
+
+server s1 {
+ rxreq
+ expect req.url == "/1"
+ txresp -bodylen 1
+
+} -start
+
+varnish v1 -vcl+backend {
+ import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
+
+ sub vcl_recv {
+ set req.ttl = 1000000s + std.duration(req.http.ttl, 1s);
+ }
+ sub vcl_deliver {
+ set resp.http.ttl = (req.ttl + 1s);
+ }
+} -start
+
+client c1 {
+ txreq -url "/1" -hdr "ttl: 10s "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000011.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 10m "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000601.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 10h "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1036001.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 10d "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1864001.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 10w "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 7048001.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: -100s "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 999901.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: s "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000002.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 3wx "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000002.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: -inf "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000002.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 2x "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000002.000
+ expect resp.bodylen == 1
+
+ txreq -url "/1" -hdr "ttl: 2h x "
+ rxresp
+ expect resp.status == 200
+ expect resp.http.ttl == 1000002.000
+ expect resp.bodylen == 1
+
+} -run
More information about the varnish-commit
mailing list