Skip to content

Commit

Permalink
Random pass at sanitising and cleaning some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch committed Dec 11, 2015
1 parent 038b70f commit e4637bb
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 192 deletions.
22 changes: 8 additions & 14 deletions bin/varnishtest/tests/c00025.vtc
Expand Up @@ -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
39 changes: 11 additions & 28 deletions bin/varnishtest/tests/c00026.vtc
@@ -1,51 +1,34 @@
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
2 changes: 1 addition & 1 deletion bin/varnishtest/tests/m00001.vtc
Expand Up @@ -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 {
Expand Down
15 changes: 7 additions & 8 deletions bin/varnishtest/tests/m00002.vtc
@@ -1,21 +1,21 @@
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

Expand All @@ -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
26 changes: 8 additions & 18 deletions bin/varnishtest/tests/m00003.vtc
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions bin/varnishtest/tests/m00004.vtc
Expand Up @@ -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 {
Expand Down
96 changes: 31 additions & 65 deletions bin/varnishtest/tests/m00005.vtc
@@ -1,106 +1,72 @@
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
20 changes: 4 additions & 16 deletions bin/varnishtest/tests/m00006.vtc
Expand Up @@ -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 {
Expand All @@ -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

0 comments on commit e4637bb

Please sign in to comment.