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