[master] 7f9a97a Speed things up

Federico G. Schwindt fgsch at lodoss.net
Sun Jan 15 00:45:04 CET 2017


commit 7f9a97ad341a6b0cb121f8573e7bd8f57637905c
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sat Jan 14 21:04:42 2017 +0000

    Speed things up
    
    Add bad_backend macro and use it instead of ${bad_ip}/port,
    should shave a few seconds here and there.
    While here also replace some unneeded ${bad_ip} entries.

diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc
index ec1990f..cc6df6d 100644
--- a/bin/varnishtest/tests/b00015.vtc
+++ b/bin/varnishtest/tests/b00015.vtc
@@ -4,8 +4,7 @@ varnishtest "Check synthetic error page caching"
 
 varnish v1 -vcl {
 	backend foo {
-		.host = "${bad_ip}";
-		.port = "9080";
+		.host = "${bad_backend}";
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/b00017.vtc b/bin/varnishtest/tests/b00017.vtc
index d0088aa..42c96fe 100644
--- a/bin/varnishtest/tests/b00017.vtc
+++ b/bin/varnishtest/tests/b00017.vtc
@@ -2,8 +2,7 @@ varnishtest "Check that we do not close one error"
 
 varnish v1 -vcl {
 	backend foo {
-		.host = "${bad_ip}";
-		.port = "9080";
+		.host = "${bad_backend}";
 	}
 	sub vcl_recv {
 		return (synth(888));
diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc
index 7ecfb7c..0399e9f 100644
--- a/bin/varnishtest/tests/c00028.vtc
+++ b/bin/varnishtest/tests/c00028.vtc
@@ -2,8 +2,7 @@ varnishtest "Test that we can't recurse restarts forever"
 
 varnish v1 -vcl {
 	backend bad {
-		.host = "${bad_ip}";
-		.port = "9090";
+		.host = "${bad_backend}";
 	}
 
 	sub vcl_backend_fetch {
diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc
index b22f259..d41ca79 100644
--- a/bin/varnishtest/tests/c00061.vtc
+++ b/bin/varnishtest/tests/c00061.vtc
@@ -2,7 +2,7 @@ varnishtest "retry in vcl_backend_error"
 
 varnish v1 -vcl {
 
-	backend b1 { .host = "${bad_ip}"; .port = "9080"; }
+	backend b1 { .host = "${bad_backend}"; }
 
 	sub vcl_backend_error {
 		return (retry);
diff --git a/bin/varnishtest/tests/c00063.vtc b/bin/varnishtest/tests/c00063.vtc
index 9da60a0..b5c2cfe 100644
--- a/bin/varnishtest/tests/c00063.vtc
+++ b/bin/varnishtest/tests/c00063.vtc
@@ -2,7 +2,7 @@ varnishtest "cache backend synth object"
 
 varnish v1 -vcl {
 
-	backend b { .host = "${bad_ip}"; .port = "9080"; }
+	backend b { .host = "${bad_backend}"; }
 
 	sub vcl_backend_error {
 		set beresp.ttl = 1s;
diff --git a/bin/varnishtest/tests/c00066.vtc b/bin/varnishtest/tests/c00066.vtc
index 7d8f972..0472415 100644
--- a/bin/varnishtest/tests/c00066.vtc
+++ b/bin/varnishtest/tests/c00066.vtc
@@ -6,7 +6,7 @@ server s1 {
 } -start
 
 varnish v1 -vcl+backend {
-	backend bad { .host = "${bad_ip}"; .port = "9080"; }
+	backend bad { .host = "${bad_backend}"; }
 	sub vcl_recv {
 		if (req.url == "/synth") {
 			return (synth(200, "Synth test"));
diff --git a/bin/varnishtest/tests/d00007.vtc b/bin/varnishtest/tests/d00007.vtc
index cdc889c..eac4a4d 100644
--- a/bin/varnishtest/tests/d00007.vtc
+++ b/bin/varnishtest/tests/d00007.vtc
@@ -8,7 +8,7 @@ server s1 {
 varnish v1 -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/d00008.vtc b/bin/varnishtest/tests/d00008.vtc
index 465fcda..8fd71b9 100644
--- a/bin/varnishtest/tests/d00008.vtc
+++ b/bin/varnishtest/tests/d00008.vtc
@@ -15,7 +15,7 @@ server s2 {
 varnish v1 -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/d00009.vtc b/bin/varnishtest/tests/d00009.vtc
index fd30602..1318e7a 100644
--- a/bin/varnishtest/tests/d00009.vtc
+++ b/bin/varnishtest/tests/d00009.vtc
@@ -21,7 +21,7 @@ server s2 {
 varnish v1 -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/d00010.vtc b/bin/varnishtest/tests/d00010.vtc
index 4646ec2..6963e59 100644
--- a/bin/varnishtest/tests/d00010.vtc
+++ b/bin/varnishtest/tests/d00010.vtc
@@ -21,7 +21,7 @@ server s2 {
 varnish v1 -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/d00011.vtc b/bin/varnishtest/tests/d00011.vtc
index f2fb3a4..21fd684 100644
--- a/bin/varnishtest/tests/d00011.vtc
+++ b/bin/varnishtest/tests/d00011.vtc
@@ -14,7 +14,7 @@ varnish v1 -vcl {
 	import std;
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc
index bca1c5b..8e5f25f 100644
--- a/bin/varnishtest/tests/d00012.vtc
+++ b/bin/varnishtest/tests/d00012.vtc
@@ -16,7 +16,7 @@ server s1 {
 varnish v1 -arg "-p thread_pools=1" -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
@@ -47,7 +47,7 @@ barrier b1 sync
 varnish v1 -vcl {
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s2 = debug.dyn("${s2_addr}", "${s2_port}");
diff --git a/bin/varnishtest/tests/d00013.vtc b/bin/varnishtest/tests/d00013.vtc
index 12457bf..a9b1826 100644
--- a/bin/varnishtest/tests/d00013.vtc
+++ b/bin/varnishtest/tests/d00013.vtc
@@ -14,7 +14,7 @@ varnish v1 -vcl {
 	import std;
 	import debug;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_init {
 		new s1 = debug.dyn("${s1_addr}", "${s1_port}");
diff --git a/bin/varnishtest/tests/m00025.vtc b/bin/varnishtest/tests/m00025.vtc
index cdd6a8e..432043f 100644
--- a/bin/varnishtest/tests/m00025.vtc
+++ b/bin/varnishtest/tests/m00025.vtc
@@ -3,7 +3,7 @@ varnishtest "Pass probe definitions to VMODs"
 varnish v1 -vcl {
 	import debug;
 
-	backend be { .host = "${bad_ip}"; }
+	backend be { .host = "127.0.0.1"; }
 	probe pb { }
 
 	sub vcl_init {
diff --git a/bin/varnishtest/tests/m00026.vtc b/bin/varnishtest/tests/m00026.vtc
index 17ca1ed..8c5f717 100644
--- a/bin/varnishtest/tests/m00026.vtc
+++ b/bin/varnishtest/tests/m00026.vtc
@@ -3,7 +3,7 @@ varnishtest "Test std.getenv"
 varnish v1 -vcl {
 	import std;
 
-	backend dummy { .host = "${bad_ip}"; .port = "9080"; }
+	backend dummy { .host = "${bad_backend}"; }
 
 	sub vcl_recv {
 		return(synth(200));
diff --git a/bin/varnishtest/tests/r00948.vtc b/bin/varnishtest/tests/r00948.vtc
index 559cbbc..d029990 100644
--- a/bin/varnishtest/tests/r00948.vtc
+++ b/bin/varnishtest/tests/r00948.vtc
@@ -11,10 +11,10 @@ server s1 {
 varnish v1 -vcl+backend {
 
 sub vcl_recv {
-	if (client.ip == "${s1_addr}" || client.ip == "${bad_ip}") {
+	if (client.ip == "${s1_addr}" || client.ip == "127.0.0.1") {
 		set req.http.foo1 = "Match";
 	}
-	if (client.ip == "${bad_ip}" || client.ip == "${s1_addr}") {
+	if (client.ip == "127.0.0.1" || client.ip == "${s1_addr}") {
 		set req.http.foo2 = "Match";
 	}
 }
diff --git a/bin/varnishtest/tests/r01002.vtc b/bin/varnishtest/tests/r01002.vtc
index d9bfb52..fbede7c 100644
--- a/bin/varnishtest/tests/r01002.vtc
+++ b/bin/varnishtest/tests/r01002.vtc
@@ -3,7 +3,7 @@ varnishtest "Real relational comparisons"
 varnish v1 -vcl {
 	import std;
 
-	backend foo { .host = "${bad_ip}"; .port = "9080"; }
+	backend foo { .host = "127.0.0.1"; }
 	sub vcl_recv {
 		if (std.random(0,5) < 1.0) {
 			return (pipe);
diff --git a/bin/varnishtest/tests/r01395.vtc b/bin/varnishtest/tests/r01395.vtc
index 06962db..b7e3881 100644
--- a/bin/varnishtest/tests/r01395.vtc
+++ b/bin/varnishtest/tests/r01395.vtc
@@ -1,10 +1,7 @@
 varnishtest "Test vcl_synth is called even if vcl_backend_fetch failed"
 
 varnish v1 -vcl {
-	backend default {
-		.host = "${bad_ip}";
-		.port = "9090";
-	}
+	backend default { .host = "${bad_backend}"; }
 
 	sub vcl_backend_error {
 		set beresp.status = 299;
diff --git a/bin/varnishtest/tests/r01398.vtc b/bin/varnishtest/tests/r01398.vtc
index ec0003e..3f929c3 100644
--- a/bin/varnishtest/tests/r01398.vtc
+++ b/bin/varnishtest/tests/r01398.vtc
@@ -2,8 +2,7 @@ varnishtest "ticket 1398"
 
 varnish v1 -vcl {
 	backend foo {
-		.host = "${bad_ip}";
-		.port = "9080";
+		.host = "${bad_backend}";
 	}
 	sub vcl_backend_response {
 		set beresp.http.X-BE-Name = beresp.backend.name;
diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc
index 8a466f7..02182a5 100644
--- a/bin/varnishtest/tests/r01504.vtc
+++ b/bin/varnishtest/tests/r01504.vtc
@@ -2,8 +2,7 @@ varnishtest "unreferenced acls"
 
 varnish v1 -arg "-p vcc_err_unref=off" -vcl {
 	backend s1 {
-		.host = "${bad_ip}";
-		.port = "9090";
+		.host = "127.0.0.1";
 	}
 	acl foo {
 		"127.0.0.1";
diff --git a/bin/varnishtest/tests/r01510.vtc b/bin/varnishtest/tests/r01510.vtc
index 7e1555b..1092ff7 100644
--- a/bin/varnishtest/tests/r01510.vtc
+++ b/bin/varnishtest/tests/r01510.vtc
@@ -11,7 +11,7 @@ varnish v1 -errvcl {Instance 'first' redefined.} {
 varnish v1 -errvcl {Name 'first' already defined.} {
 	import debug;
 
-	backend first { .host = "${bad_ip}"; .port = "9080"; }
+	backend first { .host = "127.0.0.1"; }
 
 	sub vcl_init {
 		new first = debug.obj("FOO");
diff --git a/bin/varnishtest/tests/r01512.vtc b/bin/varnishtest/tests/r01512.vtc
index 87556f1..09e07e0 100644
--- a/bin/varnishtest/tests/r01512.vtc
+++ b/bin/varnishtest/tests/r01512.vtc
@@ -33,7 +33,7 @@ client c1 {
 # Then across v_b_e and v_b_f
 
 varnish v1 -vcl {
-	backend bad { .host = "${bad_ip}"; .port = "9080"; }
+	backend bad { .host = "${bad_backend}"; }
 	sub vcl_backend_fetch {
 		set bereq.backend = bad;
 		if (bereq.http.x-abandon == "2") {
diff --git a/bin/varnishtest/tests/r01730.vtc b/bin/varnishtest/tests/r01730.vtc
index baef368..c7a8ec1 100644
--- a/bin/varnishtest/tests/r01730.vtc
+++ b/bin/varnishtest/tests/r01730.vtc
@@ -1,7 +1,7 @@
 varnishtest "Test connection error on pipe"
 
 varnish v1 -vcl {
-       backend default { .host = "${bad_ip}"; .port = "9080"; }
+       backend default { .host = "${bad_backend}"; }
        sub vcl_recv {
 		return (pipe);
        }
diff --git a/bin/varnishtest/tests/r01990.vtc b/bin/varnishtest/tests/r01990.vtc
index e9f5a19..7c72f0f 100644
--- a/bin/varnishtest/tests/r01990.vtc
+++ b/bin/varnishtest/tests/r01990.vtc
@@ -4,13 +4,12 @@ varnish v1 -vcl {
 	import debug;
 
 	backend default {
-		.host = "${bad_ip}";
-		.port = "9090";
+		.host = "${bad_backend}";
 	}
 
 	sub vcl_backend_fetch {
 		# avoid LostHeader      b Host: %s
-		set bereq.http.Host = "${bad_ip}";
+		set bereq.http.Host = "127.0.0.1";
 		debug.workspace_allocate(backend,
 			debug.workspace_free(backend));
 	}
diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc
index 44c4327..5288ff5 100644
--- a/bin/varnishtest/tests/v00021.vtc
+++ b/bin/varnishtest/tests/v00021.vtc
@@ -43,7 +43,7 @@ varnish v1 -errvcl "Function recurses on" {
 varnish v1 -errvcl {Unused acl foo, defined:} {
 	backend b { .host = "127.0.0.1"; }
 
-	acl foo { "localhost"; }
+	acl foo { "127.0.0.1"; }
 
 }
 
@@ -75,7 +75,7 @@ varnish v1 -errvcl {Invalid return "deliver"} {
 
 varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} {
 
-	backend foo { .host = "${bad_ip}"; .port = "9080"; }
+	backend foo { .host = "127.0.0.1"; }
 
 	sub vcl_deliver {
 		set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambucking = "foobar";
@@ -84,7 +84,7 @@ varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} {
 
 varnish v1 -vcl {
 
-	backend foo { .host = "${bad_ip}"; .port = "9080"; }
+	backend foo { .host = "127.0.0.1"; }
 
 	sub vcl_deliver {
 		set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckin = "foobar";
diff --git a/bin/varnishtest/tests/v00050.vtc b/bin/varnishtest/tests/v00050.vtc
index 9f05674..c880c7b 100644
--- a/bin/varnishtest/tests/v00050.vtc
+++ b/bin/varnishtest/tests/v00050.vtc
@@ -22,8 +22,7 @@ varnish v1 -vcl+backend {
 	    .initial = 0;
 	}
 	backend sick {
-	    .host = "${bad_ip}";
-	    .port = "9080";
+	    .host = "${bad_backend}";
 	    .probe = sick_probe;
 	}
 
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index e3ecd0a..0a2c6e3 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -448,12 +448,20 @@ dns_works(void)
  * Figure out what IP related magic
  */
 
+static int __match_proto__(vss_resolved_f)
+bind_cb(void *priv, const struct suckaddr *sa)
+{
+	(void)priv;
+	return (VTCP_bind(sa, NULL));
+}
+
 static void
 ip_magic(void)
 {
 	const char *p;
 	int fd;
 	char abuf[VTCP_ADDRBUFSIZE];
+	char pbuf[VTCP_PORTBUFSIZE];
 
 	/*
 	 * In FreeBSD jails localhost/127.0.0.1 becomes the jails IP#
@@ -462,12 +470,14 @@ ip_magic(void)
 	 * XXX: "localhost", but that doesn't work out of the box.
 	 * XXX: Things like "prefer_ipv6" parameter complicates things.
 	 */
-	fd = VTCP_listen_on("127.0.0.1", NULL, 10, &p);
+	fd = VSS_resolver("127.0.0.1", NULL, &bind_cb, NULL, &p);
 	assert(fd >= 0);
-	VTCP_myname(fd, abuf, sizeof abuf, NULL, 0);
-	AZ(close(fd));
+	VTCP_myname(fd, abuf, sizeof abuf, pbuf, sizeof(pbuf));
 	extmacro_def("localhost", "%s", abuf);
 
+	/* Expose a backend that is forever down. */
+	extmacro_def("bad_backend", "%s %s", abuf, pbuf);
+
 	/*
 	 * We need an IP number which will not repond, ever, and that is a
 	 * lot harder than it sounds.  This IP# is from RFC5737 and a



More information about the varnish-commit mailing list