[master] c607e9b1a vtc: Drive-by redesign of c55
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Feb 1 06:33:07 UTC 2023
commit c607e9b1a443a03481fe23ed6fa78941a01801a3
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Feb 1 07:11:26 2023 +0100
vtc: Drive-by redesign of c55
There's no point checking that a resp header is unset when we don't
rxresp in the first place... There were other things that could be
simplified.
diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc
index 6e97e1d40..e5609f35d 100644
--- a/bin/varnishtest/tests/c00055.vtc
+++ b/bin/varnishtest/tests/c00055.vtc
@@ -4,7 +4,10 @@ server s1 {
rxreq
expect req.bodylen == 3
txresp -hdr "Connection: close" -hdr "Foo: BAR" -body "1234"
+
+ expect_close
accept
+
rxreq
expect req.bodylen == 3
txresp -hdr "Foo: Foo" -body "56"
@@ -14,22 +17,19 @@ varnish v1 -vcl+backend {
import std;
sub vcl_recv {
- if (req.url == "/wrong-sub") {
- return (pass);
- }
- if (std.cache_req_body(1KB)) {
- set req.http.stored = true;
- } else {
- set req.http.stored = false;
+ if (req.url != "/wrong-sub") {
+ set req.http.stored = std.cache_req_body(1KB);
}
return (pass);
}
+
sub vcl_deliver {
if (resp.http.foo == "BAR") {
return (restart);
}
set resp.http.stored = req.http.stored;
}
+
sub vcl_backend_fetch {
if (bereq.url == "/wrong-sub") {
if (std.cache_req_body(1KB)) {
@@ -41,12 +41,6 @@ varnish v1 -vcl+backend {
}
} -start
-# check log for the aborted POST
-logexpect l1 -v v1 {
- expect * 1006 Begin
- expect * = FetchError "^straight insufficient bytes"
-} -start
-
varnish v1 -cliok "param.set debug +syncvsl"
client c1 {
@@ -57,38 +51,46 @@ client c1 {
expect resp.http.stored == true
} -run
-delay .1
+# check log for the aborted POST
+logexpect l1 -v v1 {
+ expect * 1006 Begin
+ expect * = FetchError "^straight insufficient bytes"
+} -start
-client c1 {
- txreq -req POST -nolen -hdr "Content-Length: 52"
- delay .3
- expect resp.http.stored == <undef>
+client c2 {
+ txreq -req POST -hdr "Content-Length: 52"
+} -run
+
+logexpect l1 -wait
+
+# wrong calling context
+client c3 {
+ txreq -url "/wrong-sub"
+ rxresp
+ expect resp.status == 503
} -run
delay .1
+varnish v1 -expect MGT.child_died == 0
+
+# no req body
server s1 {
rxreq
txresp
} -start
-client c1 {
- txreq -url "/wrong-sub"
- rxresp
- expect resp.status == 503
-} -run
-
-client c1 {
- txreq -url "/is_varnish_still_running"
+client c4 {
+ txreq
rxresp
expect resp.status == 200
expect resp.http.stored == true
} -run
-client c2 {
- txreq -req POST -nolen -hdr "Content-Length: 1025"
- expect_close
- expect resp.http.stored == <undef>
+# req body overflow
+client c5 {
+ txreq -req POST -hdr "Content-Length: 1025"
+ expect_close
} -run
varnish v1 -errvcl {req.body can only be cached in vcl_recv} {
@@ -100,6 +102,3 @@ varnish v1 -errvcl {req.body can only be cached in vcl_recv} {
}
}
}
-
-varnish v1 -stop
-logexpect l1 -wait
More information about the varnish-commit
mailing list