[4.0] 2eddf20 Rewrite test-cases to not use req.backend

Poul-Henning Kamp phk at FreeBSD.org
Thu Mar 13 10:24:23 CET 2014


commit 2eddf20ca7dffe58e94144982c5be403b7224de4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 5 09:32:26 2014 +0000

    Rewrite test-cases to not use req.backend

diff --git a/bin/varnishtest/tests/b00026.vtc b/bin/varnishtest/tests/b00026.vtc
index b094b0a..2f5915f 100644
--- a/bin/varnishtest/tests/b00026.vtc
+++ b/bin/varnishtest/tests/b00026.vtc
@@ -29,13 +29,16 @@ varnish v1 -vcl {
 
 	sub vcl_recv {
 		if (req.url  == "from_backend") {
-			set req.backend = b1;
 			return(pass);
 		}
-		set req.backend = b2;
 	}
 	sub vcl_backend_fetch {
 		set bereq.first_byte_timeout = 2s;
+		if (bereq.url  == "from_backend") {
+			set bereq.backend = b1;
+		} else {
+			set bereq.backend = b2;
+		}
 	}
 } -start
 varnish v1 -cliok "param.set first_byte_timeout 0.5"
diff --git a/bin/varnishtest/tests/c00009.vtc b/bin/varnishtest/tests/c00009.vtc
index 3d43334..7931e81 100644
--- a/bin/varnishtest/tests/c00009.vtc
+++ b/bin/varnishtest/tests/c00009.vtc
@@ -14,10 +14,13 @@ server s2 {
 
 varnish v1 -vcl+backend {
 	sub vcl_recv {
-		if (req.restarts == 0) {
-			set req.backend = s1;
+		set req.http.restarts = req.restarts;
+	}
+	sub vcl_backend_fetch {
+		if (bereq.http.restarts == "0") {
+			set bereq.backend = s1;
 		} else {
-			set req.backend = s2;
+			set bereq.backend = s2;
 		}
 	}
 
diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc
index 4f8a0ff..91abe45 100644
--- a/bin/varnishtest/tests/c00028.vtc
+++ b/bin/varnishtest/tests/c00028.vtc
@@ -5,8 +5,8 @@ varnish v1 -vcl {
 		.host = "${bad_ip}"; .port = "9090";
 	}
 
-	sub vcl_recv {
-	    set req.backend = bad;
+	sub vcl_backend_fetch {
+	    set bereq.backend = bad;
 	}
 	sub vcl_error {
 	    return (restart);
diff --git a/bin/varnishtest/tests/c00038.vtc b/bin/varnishtest/tests/c00038.vtc
index 0764e85..e9402b6 100644
--- a/bin/varnishtest/tests/c00038.vtc
+++ b/bin/varnishtest/tests/c00038.vtc
@@ -17,11 +17,13 @@ varnish v1 -vcl+backend {
 		if (req.http.x-ignorebusy == "1") {
 			set req.hash_ignore_busy = true;
 		}
-		if (req.http.x-client == "1") {
-			set req.backend = s1;
+	}
+	sub vcl_backend_fetch {
+		if (bereq.http.x-client == "1") {
+			set bereq.backend = s1;
 		}
-		if (req.http.x-client == "2") {
-			set req.backend = s2;
+		if (bereq.http.x-client == "2") {
+			set bereq.backend = s2;
 		}
 	}
 } -start
diff --git a/bin/varnishtest/tests/c00043.vtc b/bin/varnishtest/tests/c00043.vtc
index 46cc4e1..0960621 100644
--- a/bin/varnishtest/tests/c00043.vtc
+++ b/bin/varnishtest/tests/c00043.vtc
@@ -16,9 +16,9 @@ server s2 {
 } -start
 
 varnish v1 -vcl+backend {
-	sub vcl_recv {
-		if (req.http.bar) {
-			set req.backend = s2;
+	sub vcl_backend_fetch {
+		if (bereq.http.bar) {
+			set bereq.backend = s2;
 		}
 	}
 } -start
diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc
index 79382fc..759a0f4 100644
--- a/bin/varnishtest/tests/e00006.vtc
+++ b/bin/varnishtest/tests/e00006.vtc
@@ -22,11 +22,11 @@ server s2 {
 } -start
 
 varnish v1 -vcl+backend {
-	sub vcl_recv {
-		if (req.http.host == "bozz") {
-			set req.backend = s2;
+	sub vcl_backend_fetch {
+		if (bereq.http.host == "bozz") {
+			set bereq.backend = s2;
 		} else {
-			set req.backend = s1;
+			set bereq.backend = s1;
 		}
 	}
 	sub vcl_backend_response {
diff --git a/bin/varnishtest/tests/m00009.vtc b/bin/varnishtest/tests/m00009.vtc
index 4e97863..7fbeec1 100644
--- a/bin/varnishtest/tests/m00009.vtc
+++ b/bin/varnishtest/tests/m00009.vtc
@@ -34,8 +34,8 @@ varnish v1 -vcl+backend {
 		rr.add_backend(s4);
 	}
 
-	sub vcl_recv {
-		set req.backend = rr.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = rr.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/m00010.vtc b/bin/varnishtest/tests/m00010.vtc
index db2a07f..9d8ba1d 100644
--- a/bin/varnishtest/tests/m00010.vtc
+++ b/bin/varnishtest/tests/m00010.vtc
@@ -47,8 +47,8 @@ varnish v1 -vcl+backend {
 		rr3.add_backend(rr2.backend());
 	}
 
-	sub vcl_recv {
-		set req.backend = rr3.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = rr3.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/r00255.vtc b/bin/varnishtest/tests/r00255.vtc
index 1aedcc1..27b2bc8 100644
--- a/bin/varnishtest/tests/r00255.vtc
+++ b/bin/varnishtest/tests/r00255.vtc
@@ -10,7 +10,11 @@ server s1 {
 	    -body "012345\n"
 } -start
 
-varnish v1 -vcl+backend { sub vcl_recv {set req.backend = s1;} } -start
+varnish v1 -vcl+backend {
+	sub vcl_backend_fetch {
+		set bereq.backend = s1;
+	}
+} -start
 
 client c1 {
 	txreq -url "/"
diff --git a/bin/varnishtest/tests/r00263.vtc b/bin/varnishtest/tests/r00263.vtc
index 39f1ef5..c9036d5 100644
--- a/bin/varnishtest/tests/r00263.vtc
+++ b/bin/varnishtest/tests/r00263.vtc
@@ -16,8 +16,8 @@ varnish v1  -vcl {
 		cluster.add_backend(node3, 1);
 	}
 
-	sub vcl_recv {
-		set req.backend = cluster.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = cluster.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/r00306.vtc b/bin/varnishtest/tests/r00306.vtc
index 9e85b25..0d4c465 100644
--- a/bin/varnishtest/tests/r00306.vtc
+++ b/bin/varnishtest/tests/r00306.vtc
@@ -33,8 +33,8 @@ varnish v1 -vcl {
 		foo.add_backend(s2, 1);
 	}
 
-	sub vcl_recv {
-		set req.backend = foo.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = foo.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/r00433.vtc b/bin/varnishtest/tests/r00433.vtc
index 01462d4..494d8a8 100644
--- a/bin/varnishtest/tests/r00433.vtc
+++ b/bin/varnishtest/tests/r00433.vtc
@@ -23,11 +23,11 @@ server s2 {
 } -start
 
 varnish v1 -vcl+backend {
-	sub vcl_recv {
-		if (req.url == "/foo") {
-			set req.backend = s1;
+	sub vcl_backend_fetch {
+		if (bereq.url == "/foo") {
+			set bereq.backend = s1;
 		} else {
-			set req.backend = s2;
+			set bereq.backend = s2;
 		}
 	}
 
diff --git a/bin/varnishtest/tests/r00722.vtc b/bin/varnishtest/tests/r00722.vtc
index ef7268c..739b8f0 100644
--- a/bin/varnishtest/tests/r00722.vtc
+++ b/bin/varnishtest/tests/r00722.vtc
@@ -22,8 +22,8 @@ varnish v1 -vcl+backend {
 		foo.add_backend(b2, 1);
 		foo.add_backend(b3, 1);
 	}
-	sub vcl_recv {
-		set req.backend = foo.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = foo.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc
index 2b3a9e0..04aa7c6 100644
--- a/bin/varnishtest/tests/r00916.vtc
+++ b/bin/varnishtest/tests/r00916.vtc
@@ -10,8 +10,8 @@ varnish v1 -errvcl {Symbol not found: 's-1' (expected type BACKEND)} {
 	sub s1 {
 	}
 	sub vcl_backend_response {
-	    if (req.backend == s-1){
-		set req.backend = s-1;
+	    if (bereq.backend == s-1){
+		set bereq.backend = s-1;
 	    }
 	}
 }
diff --git a/bin/varnishtest/tests/r01073.vtc b/bin/varnishtest/tests/r01073.vtc
index 58d8ae6..3e0c44e 100644
--- a/bin/varnishtest/tests/r01073.vtc
+++ b/bin/varnishtest/tests/r01073.vtc
@@ -19,11 +19,13 @@ varnish v1 -vcl+backend {
 		if (req.http.x-hash-always-miss == "1") {
 			set req.hash_always_miss = true;
 		}
-		if (req.http.x-client == "1") {
-			set req.backend = s1;
+	}
+	sub vcl_backend_fetch {
+		if (bereq.http.x-client == "1") {
+			set bereq.backend = s1;
 		}
-		if (req.http.x-client == "2") {
-			set req.backend = s2;
+		if (bereq.http.x-client == "2") {
+			set bereq.backend = s2;
 		}
 	}
 } -start
diff --git a/bin/varnishtest/tests/r01144.vtc b/bin/varnishtest/tests/r01144.vtc
index dcd1505..284c848 100644
--- a/bin/varnishtest/tests/r01144.vtc
+++ b/bin/varnishtest/tests/r01144.vtc
@@ -11,9 +11,9 @@ varnish v1 -vcl+backend {
 		.host = "127.0.0.1";
 		.port = "54321";
 	}
-	sub vcl_recv {
-		if (req.url == "never") {
-			set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210;
+	sub vcl_backend_fetch {
+		if (bereq.url == "never") {
+			set bereq.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210;
 		}
 	}
 } -start
@@ -30,9 +30,9 @@ varnish v1 -errvcl {Expected ID got '0'} {
 		.host = "127.0.0.1";
 		.port = "54321";
 	}
-	sub vcl_recv {
-		if (req.url == "never") {
-			set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210;
+	sub vcl_backend_fetch {
+		if (bereq.url == "never") {
+			set bereq.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210;
 		}
 	}
 }
diff --git a/bin/varnishtest/tests/r01164.vtc b/bin/varnishtest/tests/r01164.vtc
index b9072e1..2951482 100644
--- a/bin/varnishtest/tests/r01164.vtc
+++ b/bin/varnishtest/tests/r01164.vtc
@@ -5,8 +5,8 @@ varnish v1 -vcl {
 		.host = "127.0.0.1";
 	}
 
-	sub vcl_recv {
-		set req.backend = storage_foo;
+	sub vcl_backend_fetch {
+		set bereq.backend = storage_foo;
 	}
 }
 
@@ -15,8 +15,8 @@ varnish v1 -vcl {
 		.host = "127.0.0.1";
 	}
 
-	sub vcl_recv {
-		set req.backend = storagefoo;
+	sub vcl_backend_fetch {
+		set bereq.backend = storagefoo;
 	}
 }
 
diff --git a/bin/varnishtest/tests/v00007.vtc b/bin/varnishtest/tests/v00007.vtc
index 313d970..196f92e 100644
--- a/bin/varnishtest/tests/v00007.vtc
+++ b/bin/varnishtest/tests/v00007.vtc
@@ -16,8 +16,8 @@ varnish v1 -vcl+backend {
 		foo.add_backend(s1, 1);
 	}
 
-	sub vcl_recv {
-		set req.backend = foo.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = foo.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/v00009.vtc b/bin/varnishtest/tests/v00009.vtc
index a356a51..af925fb 100644
--- a/bin/varnishtest/tests/v00009.vtc
+++ b/bin/varnishtest/tests/v00009.vtc
@@ -33,8 +33,8 @@ varnish v1 -vcl+backend {
 		batman.add_backend(s4);
 	}
 
-	sub vcl_recv {
-		set req.backend = batman.backend();
+	sub vcl_backend_fetch {
+		set bereq.backend = batman.backend();
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc
index 67d3431..3a48188 100644
--- a/bin/varnishtest/tests/v00014.vtc
+++ b/bin/varnishtest/tests/v00014.vtc
@@ -27,7 +27,7 @@ varnish v1 -vcl {
 	}
 
 	sub vcl_recv {
-		if (std.healthy(req.backend)) {
+		if (std.healthy(default)) {
 			return(error(200,"Backend healthy"));
 		} else {
 			return(error(500,"Backend sick"));
diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index a155dd0..7a00d95 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -84,8 +84,9 @@ varnish v1 -errvcl {Expression has type DURATION, expected BOOL} {
 }
 
 varnish v1 -errvcl {Operator > not possible on BACKEND} {
+	backend a { .host = "127.0.0.1"; }
 	backend b { .host = "127.0.0.1"; }
-	sub vcl_recv { if (req.backend > b) { } }
+	sub vcl_recv { if (a > b) { } }
 }
 
 varnish v1 -errvcl {Symbol not found: 'req.hash' (expected type BOOL):} {
diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc
index c264cca..720c816 100644
--- a/bin/varnishtest/tests/v00018.vtc
+++ b/bin/varnishtest/tests/v00018.vtc
@@ -29,7 +29,7 @@ varnish v1 -errvcl {Expected '=' got '>>'} {
 
 varnish v1 -errvcl {Expected '=' got '+='} {
 	backend b { .host = "127.0.0.1"; }
-	sub vcl_recv { set req.backend += b; }
+	sub vcl_backend_fetch { set bereq.backend += b; }
 }
 
 varnish v1 -errvcl {Expected '=' got '+='} {
diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc
index 10f4c9f..5e5a17b 100644
--- a/bin/varnishtest/tests/v00022.vtc
+++ b/bin/varnishtest/tests/v00022.vtc
@@ -43,9 +43,11 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_recv {
-		set req.backend = foo.backend();
 		return(pass);
 	}
+	sub vcl_backend_fetch {
+		set bereq.backend = foo.backend();
+	}
 } -start
 
 # NB: Do not change the number 1
diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc
index 40d3b33..e1b77b9 100644
--- a/bin/varnishtest/tests/v00026.vtc
+++ b/bin/varnishtest/tests/v00026.vtc
@@ -25,9 +25,11 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_recv {
-		set req.backend = h1.backend(req.url);
 		return(pass);
 	}
+	sub vcl_backend_fetch {
+		set bereq.backend = h1.backend(bereq.url);
+	}
 
 } -start
 
diff --git a/bin/varnishtest/tests/v00027.vtc b/bin/varnishtest/tests/v00027.vtc
index 72a7030..f014322 100644
--- a/bin/varnishtest/tests/v00027.vtc
+++ b/bin/varnishtest/tests/v00027.vtc
@@ -20,9 +20,9 @@ varnish v1 -vcl {
 		.port = "${s2_port}";
 	}
 
-	sub vcl_recv {
-		if (req.url != req.url) {
-			set req.backend = s1;
+	sub vcl_backend_fetch {
+		if (bereq.url != bereq.url) {
+			set bereq.backend = s1;
 		}
 	}
 } -start
diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc
index 42e9123..7bb1be8 100644
--- a/bin/varnishtest/tests/v00036.vtc
+++ b/bin/varnishtest/tests/v00036.vtc
@@ -26,9 +26,11 @@ varnish v1 -vcl+backend {
 	}
 
         sub vcl_recv {
-                set req.backend = fb1.backend();
                 return (pass);
         }
+        sub vcl_backend_fetch {
+                set bereq.backend = fb1.backend();
+        }
 
 } -start
 



More information about the varnish-commit mailing list