[master] 10e3b1770 vtc: Move the remaining vmod_directors test cases

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Sep 10 10:17:06 UTC 2021


commit 10e3b1770f733eac8b900db92edceacebba690c6
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Sep 10 12:03:01 2021 +0200

    vtc: Move the remaining vmod_directors test cases
    
    With a tiny bit of polish here and there.

diff --git a/bin/varnishtest/tests/README b/bin/varnishtest/tests/README
index 1d01105de..4070daf05 100644
--- a/bin/varnishtest/tests/README
+++ b/bin/varnishtest/tests/README
@@ -17,7 +17,7 @@ Naming scheme
 	id ~ ^a02	--> HTTP2
 	id ~ ^b		--> Basic functionality tests
 	id ~ ^c		--> Complex functionality tests
-	id ~ ^d		--> Director VMOD tests
+	id ~ ^d		--> Director facility tests
 	id ~ ^e		--> ESI tests
 	id ~ ^f		--> Security related tests
 	id ~ ^g		--> GZIP tests
@@ -34,3 +34,5 @@ Naming scheme
 	id ~ ^t02	--> HTTP2
 	id ~ ^u		--> Utilities and background processes
 	id ~ ^v		--> VCL tests: execute VRT functions
+
+	Coverage for individual VMODs is in "${top_srcdir}vmod/tests".
diff --git a/bin/varnishtest/tests/d00025.vtc b/vmod/tests/directors_b00007.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00025.vtc
rename to vmod/tests/directors_b00007.vtc
diff --git a/bin/varnishtest/tests/d00018.vtc b/vmod/tests/directors_c00003.vtc
similarity index 55%
rename from bin/varnishtest/tests/d00018.vtc
rename to vmod/tests/directors_c00003.vtc
index 429bc9014..5a81f479c 100644
--- a/bin/varnishtest/tests/d00018.vtc
+++ b/vmod/tests/directors_c00003.vtc
@@ -2,17 +2,17 @@ varnishtest "shard director/int key"
 
 server s1 {
 	rxreq
-	txresp -body "ech3Ooj"
+	txresp
 } -start
 
 server s2 {
 	rxreq
-	txresp -body "ieQu2qua"
+	txresp
 } -start
 
 server s3 {
 	rxreq
-	txresp -body "xiuFi3Pe"
+	txresp
 } -start
 
 varnish v1 -vcl+backend {
@@ -36,31 +36,26 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_recv {
-		if (req.url == "/1") {
-			set req.backend_hint = vd.backend(by=KEY, key=1);
-		}
-		if (req.url == "/2") {
-			set req.backend_hint = vd.backend(by=KEY, key=2147483647);
-		}
-		if (req.url == "/3") {
-			set req.backend_hint = vd.backend(by=KEY, key=4294967295);
-		}
+		set req.backend_hint = vd.backend(by=KEY, key=std.integer(req.http.key));
 		return(pass);
 	}
 
+	sub vcl_backend_response {
+		set beresp.http.backend = beresp.backend;
+	}
 } -start
 
 
 client c1 {
-	txreq -url /1
+	txreq -hdr "key: 1"
 	rxresp
-	expect resp.body == "ech3Ooj"
+	expect resp.http.backend == s1
 
-	txreq -url /2
+	txreq -hdr "key: 2147483647"
 	rxresp
-	expect resp.body == "ieQu2qua"
+	expect resp.http.backend == s2
 
-	txreq -url /3
+	txreq -hdr "key: 4294967295"
 	rxresp
-	expect resp.body == "xiuFi3Pe"
+	expect resp.http.backend == s3
 } -run
diff --git a/bin/varnishtest/tests/d00029.vtc b/vmod/tests/directors_c00004.vtc
similarity index 97%
rename from bin/varnishtest/tests/d00029.vtc
rename to vmod/tests/directors_c00004.vtc
index 26fc5b0b5..668d6c5a8 100644
--- a/bin/varnishtest/tests/d00029.vtc
+++ b/vmod/tests/directors_c00004.vtc
@@ -1,4 +1,4 @@
-varnishtest "shard director LAZY - d18.vtc"
+varnishtest "shard director LAZY - directors_c00003.vtc"
 
 server s1 -repeat 2 {
 	rxreq
diff --git a/bin/varnishtest/tests/d00019.vtc b/vmod/tests/directors_c00005.vtc
similarity index 73%
rename from bin/varnishtest/tests/d00019.vtc
rename to vmod/tests/directors_c00005.vtc
index 9695457db..0fea75d1a 100644
--- a/bin/varnishtest/tests/d00019.vtc
+++ b/vmod/tests/directors_c00005.vtc
@@ -2,17 +2,17 @@ varnishtest "shard director by req.url (default)"
 
 server s1 {
 	rxreq
-	txresp -body "ech3Ooj"
+	txresp
 } -start
 
 server s2 {
 	rxreq
-	txresp -body "ieQu2qua"
+	txresp
 } -start
 
 server s3 {
 	rxreq
-	txresp -body "xiuFi3Pe"
+	txresp
 } -start
 
 varnish v1 -vcl+backend {
@@ -31,19 +31,22 @@ varnish v1 -vcl+backend {
 		return(pass);
 	}
 
+	sub vcl_backend_response {
+		set beresp.http.backend = beresp.backend;
+	}
 } -start
 
 
 client c1 {
 	txreq -url /Boo0aixe
 	rxresp
-	expect resp.body == "ech3Ooj"
+	expect resp.http.backend == s1
 
 	txreq -url /eishoSu2
 	rxresp
-	expect resp.body == "ieQu2qua"
+	expect resp.http.backend == s2
 
 	txreq -url /Aunah3uo
 	rxresp
-	expect resp.body == "xiuFi3Pe"
+	expect resp.http.backend == s3
 } -run
diff --git a/bin/varnishtest/tests/d00041.vtc b/vmod/tests/directors_c00006.vtc
similarity index 99%
rename from bin/varnishtest/tests/d00041.vtc
rename to vmod/tests/directors_c00006.vtc
index 3e108b81b..794cc904e 100644
--- a/bin/varnishtest/tests/d00041.vtc
+++ b/vmod/tests/directors_c00006.vtc
@@ -1,4 +1,4 @@
-varnishtest "d00017.vtc but with weights"
+varnishtest "directors_c00005.vtc but with weights"
 
 server s1 {
 	rxreq
diff --git a/bin/varnishtest/tests/d00017.vtc b/vmod/tests/directors_c00007.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00017.vtc
rename to vmod/tests/directors_c00007.vtc
diff --git a/bin/varnishtest/tests/d00026.vtc b/vmod/tests/directors_c00008.vtc
similarity index 90%
rename from bin/varnishtest/tests/d00026.vtc
rename to vmod/tests/directors_c00008.vtc
index 0cfd81649..c571f5d2f 100644
--- a/bin/varnishtest/tests/d00026.vtc
+++ b/vmod/tests/directors_c00008.vtc
@@ -1,4 +1,4 @@
-varnishtest "shard director - same as d00017.vtc but setting backend in fetch"
+varnishtest "directors_c00007.vtc but setting backend in fetch"
 
 server s1 {
 	rxreq
diff --git a/bin/varnishtest/tests/d00020.vtc b/vmod/tests/directors_c00009.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00020.vtc
rename to vmod/tests/directors_c00009.vtc
diff --git a/bin/varnishtest/tests/d00015.vtc b/vmod/tests/directors_c00010.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00015.vtc
rename to vmod/tests/directors_c00010.vtc
diff --git a/bin/varnishtest/tests/d00016.vtc b/vmod/tests/directors_c00011.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00016.vtc
rename to vmod/tests/directors_c00011.vtc
diff --git a/bin/varnishtest/tests/d00021.vtc b/vmod/tests/directors_c00012.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00021.vtc
rename to vmod/tests/directors_c00012.vtc
diff --git a/bin/varnishtest/tests/d00022.vtc b/vmod/tests/directors_c00013.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00022.vtc
rename to vmod/tests/directors_c00013.vtc
diff --git a/bin/varnishtest/tests/d00023.vtc b/vmod/tests/directors_c00014.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00023.vtc
rename to vmod/tests/directors_c00014.vtc
diff --git a/bin/varnishtest/tests/d00030.vtc b/vmod/tests/directors_c00015.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00030.vtc
rename to vmod/tests/directors_c00015.vtc
diff --git a/bin/varnishtest/tests/d00024.vtc b/vmod/tests/directors_s00000.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00024.vtc
rename to vmod/tests/directors_s00000.vtc
diff --git a/bin/varnishtest/tests/d00039.vtc b/vmod/tests/directors_v00000.vtc
similarity index 100%
rename from bin/varnishtest/tests/d00039.vtc
rename to vmod/tests/directors_v00000.vtc


More information about the varnish-commit mailing list