[master] 5d48d91 More coverage of vmod_vtc

Poul-Henning Kamp phk at FreeBSD.org
Thu Nov 16 08:41:05 UTC 2017


commit 5d48d91e2bac264f3ca8a79dd809558ac35da0f2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Nov 16 08:39:50 2017 +0000

    More coverage of vmod_vtc

diff --git a/bin/varnishtest/tests/c00070.vtc b/bin/varnishtest/tests/c00070.vtc
index 973af28..6593569 100644
--- a/bin/varnishtest/tests/c00070.vtc
+++ b/bin/varnishtest/tests/c00070.vtc
@@ -10,6 +10,11 @@ server s1 {
 
 varnish v1 -vcl+backend {
 	import vtc;
+	sub vcl_recv {
+		if (req.url == "/overflow") {
+			vtc.workspace_alloc(client, 100000000);
+		}
+	}
 	sub vcl_backend_response {
 		set beresp.http.free_backend = vtc.workspace_free(backend);
 	}
@@ -29,7 +34,7 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -d 1 -g vxid -q "Error ~ 'overflow'" {
 	expect 0 *	Begin
-	expect * =	Error	"workspace_client overflow"
+	expect * =	Error		"workspace_client overflow"
 	expect * =	End
 } -start
 
@@ -43,10 +48,22 @@ client c1 {
 	expect resp.http.free_thread > 2000
 } -run
 
-client c2 {
+client c1 {
 	txreq -url /bar
 	rxresp
 	expect resp.status == 500
 } -run
 
 logexpect l1 -wait
+
+logexpect l2 -v v1 -d 1 -g vxid  {
+	expect * 1007	VCL_Error
+} -start
+
+client c1 {
+	txreq -url /overflow
+	rxresp
+	expect resp.status == 503
+} -run
+
+logexpect l2 -wait
diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index 2dbe456..6200b80 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -24,6 +24,7 @@ varnish v1 -vcl+backend {
 		set resp.http.bar = std.tolower(resp.http.bar);
 		set resp.http.who = debug.author(phk);
 		set resp.http.what = vtc.typesize("dfijlopsz");
+		set resp.http.not = vtc.typesize("*");
 		debug.test_priv_call();
 		debug.test_priv_vcl();
 		obj.test_priv_call();
@@ -43,6 +44,7 @@ client c1 {
 	expect resp.http.bar == "foo"
 	expect resp.http.encrypted == "ROT52"
 	expect resp.http.what >= 16
+	expect resp.http.not == -1
 } -run
 
 logexpect l1 -v v1 -g raw -d 1 {
@@ -53,6 +55,7 @@ logexpect l1 -v v1 -g raw -d 1 {
 	expect 0 =    RespHeader	{^bar: foo}
 	expect 0 =    RespHeader	{^who: Poul-Henning}
 	expect 0 =    RespHeader	{^what: [1-9][0-9]}
+	expect 0 =    RespHeader	{^not: -1}
 	expect 0 =    VCL_Log		{^VCL initiated log}
 	expect 0 =    RespHeader	{^Encrypted: ROT52}
 	expect 0 =    VCL_return	{^deliver}
diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c
index e8fbf61..c91eb2e 100644
--- a/lib/libvmod_vtc/vmod_vtc.c
+++ b/lib/libvmod_vtc/vmod_vtc.c
@@ -131,9 +131,7 @@ vtc_ws_find(VRT_CTX, VCL_ENUM which)
 		return (ctx->req->sp->ws);
 	if (!strcmp(which, "thread"))
 		return (ctx->req->wrk->aws);
-
-	VRT_fail(ctx, "Unknown workspace: '%s'", which);
-	return (NULL);
+	WRONG("vtc_ws_find Illegal enum");
 }
 
 VCL_VOID __match_proto__(td_vtc_workspace_alloc)


More information about the varnish-commit mailing list