Commit e4637bb6 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Random pass at sanitising and cleaning some tests

parent 038b70fd
...@@ -2,30 +2,24 @@ varnishtest "Test If-None-Match" ...@@ -2,30 +2,24 @@ varnishtest "Test If-None-Match"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/foo" expect req.url == /
txresp -hdr {ETag: "123456789"} \ txresp -hdr {ETag: "123456789"} -bodylen 10
-body "11111\n"
} -start } -start
varnish v1 -vcl+backend { } -start varnish v1 -vcl+backend { } -start
client c1 { client c1 {
txreq -url "/foo" txreq
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 6 expect resp.bodylen == 10
expect resp.http.etag == {"123456789"}
txreq -url "/foo" \ txreq -hdr {If-None-Match: "12345678"}
-hdr {If-None-Match: "12345678"}
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
txreq -url "/foo" \ txreq -hdr {If-None-Match: "123456789"}
-hdr {If-None-Match: "123456789"}
rxresp -no_obj rxresp -no_obj
expect resp.status == 304 expect resp.status == 304
} } -run
client c1 -run
client c1 -run
varnishtest "Client IMS/INM: Test Combination of If-None-Match and If-Modified-Since" varnishtest "Test client If-None-Match and If-Modified-Since together"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/foo" expect req.url == /
txresp -hdr {ETag: "123456789"} \ txresp -hdr {ETag: "123456789"} \
-hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
-body "11111\n" -bodylen 10
} -start } -start
varnish v1 -vcl+backend { } -start varnish v1 -vcl+backend { } -start
client c1 { client c1 {
txreq -url "/foo" txreq
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 6 expect resp.bodylen == 10
expect resp.http.etag == {"123456789"}
txreq -url "/foo" \ txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \
-hdr {If-None-Match: "123456789"}
rxresp -no_obj
expect resp.status == 304
txreq -url "/foo" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
rxresp -no_obj
expect resp.status == 304
txreq -url "/foo" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \
-hdr {If-None-Match: "123456789"} -hdr {If-None-Match: "123456789"}
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
txreq -url "/foo" \ txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr {If-None-Match: "12345678"} -hdr {If-None-Match: "12345678"}
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
txreq -url "/foo" \ txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr {If-None-Match: "123456789"} -hdr {If-None-Match: "123456789"}
rxresp -no_obj rxresp -no_obj
expect resp.status == 304 expect resp.status == 304
} -run
}
client c1 -run
client c1 -run
...@@ -5,7 +5,7 @@ server s1 { ...@@ -5,7 +5,7 @@ server s1 {
txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4
} -start } -start
varnish v1 -arg "-pthread_pools=1" -vcl+backend { varnish v1 -vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_deliver { sub vcl_deliver {
......
varnishtest "Test std.random" varnishtest "Test std.random()"
# needs random generator # needs random generator
random random
server s1 { server s1 {
rxreq rxreq
txresp -proto HTTP/1.0 -nolen -bodylen 9 txresp
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_backend_response { sub vcl_deliver {
set beresp.http.rnd1 = std.random(0,1); set resp.http.rnd1 = std.random(0, 1);
set beresp.http.rnd2 = std.random(0,10); set resp.http.rnd2 = std.random(0, 10);
set beresp.http.rnd3 = std.random(8,10); set resp.http.rnd3 = std.random(8, 10);
set beresp.http.rnd4 = std.random(99,100); set resp.http.rnd4 = std.random(99, 100);
} }
} -start } -start
...@@ -30,5 +30,4 @@ client c1 { ...@@ -30,5 +30,4 @@ client c1 {
expect resp.http.rnd2 == 7.478 expect resp.http.rnd2 == 7.478
expect resp.http.rnd3 == 9.034 expect resp.http.rnd3 == 9.034
expect resp.http.rnd4 == 99.502 expect resp.http.rnd4 == 99.502
expect resp.bodylen == 9
} -run } -run
...@@ -4,29 +4,19 @@ feature topbuild ...@@ -4,29 +4,19 @@ feature topbuild
server s1 { server s1 {
rxreq rxreq
txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 txresp
} -start } -start
varnish v1 -arg "-pthread_pools=1" \ varnish v1 -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \
-arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ -vcl+backend {
-vcl+backend {
import std; import std;
sub vcl_deliver {
set resp.http.foo = std.toupper(resp.http.foo);
set resp.http.bar = std.tolower(resp.http.bar);
std.set_ip_tos(32);
}
} -start } -start
client c1 { varnish v1 -cliok "param.set vmod_dir /nonexistent"
txreq -url "/bar"
rxresp varnish v1 -errvcl {No such file or directory} {
expect resp.status == 200 import std;
expect resp.bodylen == "4" }
expect resp.http.foo == "BAR"
expect resp.http.bar == "foo"
} -run
varnish v1 -errvcl {Expected 'from path ...'} { varnish v1 -errvcl {Expected 'from path ...'} {
import std to; import std to;
......
...@@ -13,9 +13,7 @@ server s1 { ...@@ -13,9 +13,7 @@ server s1 {
} }
} -start } -start
varnish v1 \ varnish v1 -vcl+backend {
-arg "-pthread_pools=1" \
-vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_deliver { sub vcl_deliver {
......
varnishtest "test vmod_std.duration conversion" varnishtest "Test std.duration()"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/1" txresp
txresp -bodylen 1
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_recv {
set req.ttl = 1000000s + std.duration(req.http.ttl, 1s);
}
sub vcl_deliver { sub vcl_deliver {
set resp.http.ttl = (req.ttl + 1s); set resp.http.ttl = std.duration(req.http.ttl, 1s) + 1000000s;
} }
} -start } -start
client c1 { client c1 {
txreq -url "/1" -hdr "ttl: 10ms " txreq -hdr "ttl: 10ms"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000000.010
expect resp.http.ttl == 1000001.010
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 10s " txreq -hdr "ttl: 10s"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000010.000
expect resp.http.ttl == 1000011.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 10m " txreq -hdr "ttl: 10m"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000600.000
expect resp.http.ttl == 1000601.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 10h " txreq -hdr "ttl: 10h"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1036000.000
expect resp.http.ttl == 1036001.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 10d " txreq -hdr "ttl: 10d"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1864000.000
expect resp.http.ttl == 1864001.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 10w " txreq -hdr "ttl: 10w"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 7048000.000
expect resp.http.ttl == 7048001.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: -100s " txreq -hdr "ttl: 1y"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 32536000.000
expect resp.http.ttl == 999901.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: s " txreq -hdr "ttl: -100s"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 999900.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 3wx " txreq -hdr "ttl: s"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: -inf " txreq -hdr "ttl: 3wx"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 2x " txreq -hdr "ttl: -inf"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 2h x " txreq -hdr "ttl: 2x"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 100" txreq -hdr "ttl: 2h x"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 1000002.000
expect resp.bodylen == 1
txreq -url "/1" -hdr "ttl: 1y" txreq -hdr "ttl: 100"
rxresp rxresp
expect resp.status == 200 expect resp.http.ttl == 1000001.000
expect resp.http.ttl == 32536001.000
expect resp.bodylen == 1
} -run } -run
...@@ -2,14 +2,9 @@ varnishtest "test vmod_std.collect()" ...@@ -2,14 +2,9 @@ varnishtest "test vmod_std.collect()"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/1"
expect req.http.foo == "1, 2" expect req.http.foo == "1, 2"
txresp -hdr "bar: a" -hdr "bar: b" -bodylen 1 expect req.http.baz == "3, 4"
txresp -hdr "bar: a" -hdr "bar: b" -hdr "qux: c" -hdr "qux: d"
rxreq
expect req.url == "/2"
expect req.http.baz == "1, 2"
txresp -hdr "qux: a" -hdr "qux: b" -bodylen 1
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
...@@ -30,15 +25,8 @@ varnish v1 -vcl+backend { ...@@ -30,15 +25,8 @@ varnish v1 -vcl+backend {
} -start } -start
client c1 { client c1 {
txreq -url "/1" -hdr "Foo: 1" -hdr "Foo: 2" txreq -hdr "Foo: 1" -hdr "Foo: 2" -hdr "Baz: 3" -hdr "Baz: 4"
rxresp rxresp
expect resp.http.bar == "a, b" expect resp.http.bar == "a, b"
expect resp.status == 200 expect resp.http.qux == "c, d"
expect resp.bodylen == 1
txreq -url "/2" -hdr "Baz: 1" -hdr "Baz: 2"
rxresp
expect resp.http.qux == "a, b"
expect resp.status == 200
expect resp.bodylen == 1
} -run } -run
varnishtest "test vmod_std.integer conversion" varnishtest "Test std.integer()"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/1" txresp
txresp -bodylen 1
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_deliver { sub vcl_deliver {
set resp.http.biggerthanzero = (std.integer(req.http.foo,0) > 0); set resp.http.gtzero = (std.integer(req.http.foo, 0) > 0);
set resp.http.smallerthanzero = (std.integer(req.http.foo,0) < 0); set resp.http.ltzero = (std.integer(req.http.foo, 0) < 0);
set resp.http.iszero = (std.integer(req.http.foo,0) == 0); set resp.http.iszero = (std.integer(req.http.foo, 0) == 0);
set resp.http.converted = std.integer(req.http.foo,0); set resp.http.converted = std.integer(req.http.foo, 0);
} }
} -start } -start
client c1 { client c1 {
txreq -url "/1" -hdr "foo: 1" txreq -hdr "foo: 1"
rxresp rxresp
expect resp.status == 200 expect resp.http.gtzero == true
expect resp.http.biggerthanzero == true expect resp.http.ltzero == false
expect resp.http.smallerthanzero == false
expect resp.http.iszero == false expect resp.http.iszero == false
expect resp.http.converted == 1 expect resp.http.converted == 1
txreq -url "/1" -hdr "foo: -1" txreq -hdr "foo: -1"
rxresp rxresp
expect resp.status == 200 expect resp.http.gtzero == false
expect resp.http.biggerthanzero == false expect resp.http.ltzero == true
expect resp.http.smallerthanzero == true
expect resp.http.iszero == false expect resp.http.iszero == false
expect resp.http.converted == -1 expect resp.http.converted == -1
txreq -url "/1" txreq -hdr "foo: 0"
rxresp rxresp
expect resp.status == 200 expect resp.http.gtzero == false
expect resp.http.biggerthanzero == false expect resp.http.ltzero == false
expect resp.http.smallerthanzero == false
expect resp.http.iszero == true expect resp.http.iszero == true
expect resp.http.converted == 0 expect resp.http.converted == 0
txreq -url "/1" -hdr "foo: bar" txreq -hdr "foo: bar"
rxresp rxresp
expect resp.status == 200 expect resp.http.gtzero == false
expect resp.http.biggerthanzero == false expect resp.http.ltzero == false
expect resp.http.smallerthanzero == false
expect resp.http.iszero == true expect resp.http.iszero == true
expect resp.http.converted == 0 expect resp.http.converted == 0
} -run } -run
varnishtest "Test std.ip" varnishtest "Test std.ip()"
server s1 { server s1 {
rxreq rxreq
txresp -body "1" txresp
rxreq
txresp -body "22"
} -start } -start
varnish v1 -vcl+backend {
varnish v1 -arg "-Wpoll" -vcl+backend {
import ${vmod_std}; import ${vmod_std};
sub vcl_deliver { sub vcl_deliver {
set resp.http.foo0 = std.ip("8.8.8.*", client.ip); set resp.http.foo0 = std.ip("8.8.8.*", client.ip);
set resp.http.foo1 = std.ip("9.9.9.*", server.ip); set resp.http.foo1 = std.ip("9.9.9.*", server.ip);
...@@ -22,16 +19,12 @@ varnish v1 -arg "-Wpoll" -vcl+backend { ...@@ -22,16 +19,12 @@ varnish v1 -arg "-Wpoll" -vcl+backend {
} -start } -start
client c1 { client c1 {
txreq -url "/foo1" txreq
rxresp rxresp
expect resp.bodylen == 1
expect resp.http.foo0 == "127.0.0.1" expect resp.http.foo0 == "127.0.0.1"
expect resp.http.foo1 == "127.0.0.1" expect resp.http.foo1 == "127.0.0.1"
expect resp.http.foo2 == "127.0.0.2" expect resp.http.foo2 == "127.0.0.2"
expect resp.http.foo3 == "1.2.3.5" expect resp.http.foo3 == "1.2.3.5"
expect resp.http.foo4 == "2001:db8::" expect resp.http.foo4 == "2001:db8::"
expect resp.http.foo5 == "::1" expect resp.http.foo5 == "::1"
txreq -url "/foo2"
rxresp
expect resp.bodylen == 2
} -run } -run
varnishtest "Timestamps from std vmod" varnishtest "Test std.timestamp()"
server s1 { server s1 {
rxreq rxreq
...@@ -38,7 +38,6 @@ logexpect l1 -v v1 -g request { ...@@ -38,7 +38,6 @@ logexpect l1 -v v1 -g request {
client c1 { client c1 {
txreq txreq
rxresp rxresp
expect resp.status == 200
} -run } -run
logexpect l1 -wait logexpect l1 -wait
...@@ -2,7 +2,7 @@ varnishtest "Check we ignore a zero C-L with a 204" ...@@ -2,7 +2,7 @@ varnishtest "Check we ignore a zero C-L with a 204"
server s1 { server s1 {
rxreq rxreq
txresp -status 204 -nolen -hdr "Content-Length: 0" txresp -status 204
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
......
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