Commit 7f9a97ad authored by Federico G. Schwindt's avatar Federico G. Schwindt

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.
parent d306f91c
...@@ -4,8 +4,7 @@ varnishtest "Check synthetic error page caching" ...@@ -4,8 +4,7 @@ varnishtest "Check synthetic error page caching"
varnish v1 -vcl { varnish v1 -vcl {
backend foo { backend foo {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9080";
} }
} -start } -start
......
...@@ -2,8 +2,7 @@ varnishtest "Check that we do not close one error" ...@@ -2,8 +2,7 @@ varnishtest "Check that we do not close one error"
varnish v1 -vcl { varnish v1 -vcl {
backend foo { backend foo {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9080";
} }
sub vcl_recv { sub vcl_recv {
return (synth(888)); return (synth(888));
......
...@@ -2,8 +2,7 @@ varnishtest "Test that we can't recurse restarts forever" ...@@ -2,8 +2,7 @@ varnishtest "Test that we can't recurse restarts forever"
varnish v1 -vcl { varnish v1 -vcl {
backend bad { backend bad {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9090";
} }
sub vcl_backend_fetch { sub vcl_backend_fetch {
......
...@@ -2,7 +2,7 @@ varnishtest "retry in vcl_backend_error" ...@@ -2,7 +2,7 @@ varnishtest "retry in vcl_backend_error"
varnish v1 -vcl { varnish v1 -vcl {
backend b1 { .host = "${bad_ip}"; .port = "9080"; } backend b1 { .host = "${bad_backend}"; }
sub vcl_backend_error { sub vcl_backend_error {
return (retry); return (retry);
......
...@@ -2,7 +2,7 @@ varnishtest "cache backend synth object" ...@@ -2,7 +2,7 @@ varnishtest "cache backend synth object"
varnish v1 -vcl { varnish v1 -vcl {
backend b { .host = "${bad_ip}"; .port = "9080"; } backend b { .host = "${bad_backend}"; }
sub vcl_backend_error { sub vcl_backend_error {
set beresp.ttl = 1s; set beresp.ttl = 1s;
......
...@@ -6,7 +6,7 @@ server s1 { ...@@ -6,7 +6,7 @@ server s1 {
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
backend bad { .host = "${bad_ip}"; .port = "9080"; } backend bad { .host = "${bad_backend}"; }
sub vcl_recv { sub vcl_recv {
if (req.url == "/synth") { if (req.url == "/synth") {
return (synth(200, "Synth test")); return (synth(200, "Synth test"));
......
...@@ -8,7 +8,7 @@ server s1 { ...@@ -8,7 +8,7 @@ server s1 {
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -15,7 +15,7 @@ server s2 { ...@@ -15,7 +15,7 @@ server s2 {
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -21,7 +21,7 @@ server s2 { ...@@ -21,7 +21,7 @@ server s2 {
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -21,7 +21,7 @@ server s2 { ...@@ -21,7 +21,7 @@ server s2 {
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -14,7 +14,7 @@ varnish v1 -vcl { ...@@ -14,7 +14,7 @@ varnish v1 -vcl {
import std; import std;
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -16,7 +16,7 @@ server s1 { ...@@ -16,7 +16,7 @@ server s1 {
varnish v1 -arg "-p thread_pools=1" -vcl { varnish v1 -arg "-p thread_pools=1" -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
...@@ -47,7 +47,7 @@ barrier b1 sync ...@@ -47,7 +47,7 @@ barrier b1 sync
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s2 = debug.dyn("${s2_addr}", "${s2_port}"); new s2 = debug.dyn("${s2_addr}", "${s2_port}");
......
...@@ -14,7 +14,7 @@ varnish v1 -vcl { ...@@ -14,7 +14,7 @@ varnish v1 -vcl {
import std; import std;
import debug; import debug;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_init { sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}"); new s1 = debug.dyn("${s1_addr}", "${s1_port}");
......
...@@ -3,7 +3,7 @@ varnishtest "Pass probe definitions to VMODs" ...@@ -3,7 +3,7 @@ varnishtest "Pass probe definitions to VMODs"
varnish v1 -vcl { varnish v1 -vcl {
import debug; import debug;
backend be { .host = "${bad_ip}"; } backend be { .host = "127.0.0.1"; }
probe pb { } probe pb { }
sub vcl_init { sub vcl_init {
......
...@@ -3,7 +3,7 @@ varnishtest "Test std.getenv" ...@@ -3,7 +3,7 @@ varnishtest "Test std.getenv"
varnish v1 -vcl { varnish v1 -vcl {
import std; import std;
backend dummy { .host = "${bad_ip}"; .port = "9080"; } backend dummy { .host = "${bad_backend}"; }
sub vcl_recv { sub vcl_recv {
return(synth(200)); return(synth(200));
......
...@@ -11,10 +11,10 @@ server s1 { ...@@ -11,10 +11,10 @@ server s1 {
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
sub vcl_recv { 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"; 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"; set req.http.foo2 = "Match";
} }
} }
......
...@@ -3,7 +3,7 @@ varnishtest "Real relational comparisons" ...@@ -3,7 +3,7 @@ varnishtest "Real relational comparisons"
varnish v1 -vcl { varnish v1 -vcl {
import std; import std;
backend foo { .host = "${bad_ip}"; .port = "9080"; } backend foo { .host = "127.0.0.1"; }
sub vcl_recv { sub vcl_recv {
if (std.random(0,5) < 1.0) { if (std.random(0,5) < 1.0) {
return (pipe); return (pipe);
......
varnishtest "Test vcl_synth is called even if vcl_backend_fetch failed" varnishtest "Test vcl_synth is called even if vcl_backend_fetch failed"
varnish v1 -vcl { varnish v1 -vcl {
backend default { backend default { .host = "${bad_backend}"; }
.host = "${bad_ip}";
.port = "9090";
}
sub vcl_backend_error { sub vcl_backend_error {
set beresp.status = 299; set beresp.status = 299;
......
...@@ -2,8 +2,7 @@ varnishtest "ticket 1398" ...@@ -2,8 +2,7 @@ varnishtest "ticket 1398"
varnish v1 -vcl { varnish v1 -vcl {
backend foo { backend foo {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9080";
} }
sub vcl_backend_response { sub vcl_backend_response {
set beresp.http.X-BE-Name = beresp.backend.name; set beresp.http.X-BE-Name = beresp.backend.name;
......
...@@ -2,8 +2,7 @@ varnishtest "unreferenced acls" ...@@ -2,8 +2,7 @@ varnishtest "unreferenced acls"
varnish v1 -arg "-p vcc_err_unref=off" -vcl { varnish v1 -arg "-p vcc_err_unref=off" -vcl {
backend s1 { backend s1 {
.host = "${bad_ip}"; .host = "127.0.0.1";
.port = "9090";
} }
acl foo { acl foo {
"127.0.0.1"; "127.0.0.1";
......
...@@ -11,7 +11,7 @@ varnish v1 -errvcl {Instance 'first' redefined.} { ...@@ -11,7 +11,7 @@ varnish v1 -errvcl {Instance 'first' redefined.} {
varnish v1 -errvcl {Name 'first' already defined.} { varnish v1 -errvcl {Name 'first' already defined.} {
import debug; import debug;
backend first { .host = "${bad_ip}"; .port = "9080"; } backend first { .host = "127.0.0.1"; }
sub vcl_init { sub vcl_init {
new first = debug.obj("FOO"); new first = debug.obj("FOO");
......
...@@ -33,7 +33,7 @@ client c1 { ...@@ -33,7 +33,7 @@ client c1 {
# Then across v_b_e and v_b_f # Then across v_b_e and v_b_f
varnish v1 -vcl { varnish v1 -vcl {
backend bad { .host = "${bad_ip}"; .port = "9080"; } backend bad { .host = "${bad_backend}"; }
sub vcl_backend_fetch { sub vcl_backend_fetch {
set bereq.backend = bad; set bereq.backend = bad;
if (bereq.http.x-abandon == "2") { if (bereq.http.x-abandon == "2") {
......
varnishtest "Test connection error on pipe" varnishtest "Test connection error on pipe"
varnish v1 -vcl { varnish v1 -vcl {
backend default { .host = "${bad_ip}"; .port = "9080"; } backend default { .host = "${bad_backend}"; }
sub vcl_recv { sub vcl_recv {
return (pipe); return (pipe);
} }
......
...@@ -4,13 +4,12 @@ varnish v1 -vcl { ...@@ -4,13 +4,12 @@ varnish v1 -vcl {
import debug; import debug;
backend default { backend default {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9090";
} }
sub vcl_backend_fetch { sub vcl_backend_fetch {
# avoid LostHeader b Host: %s # 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_allocate(backend,
debug.workspace_free(backend)); debug.workspace_free(backend));
} }
......
...@@ -43,7 +43,7 @@ varnish v1 -errvcl "Function recurses on" { ...@@ -43,7 +43,7 @@ varnish v1 -errvcl "Function recurses on" {
varnish v1 -errvcl {Unused acl foo, defined:} { varnish v1 -errvcl {Unused acl foo, defined:} {
backend b { .host = "127.0.0.1"; } 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"} { ...@@ -75,7 +75,7 @@ varnish v1 -errvcl {Invalid return "deliver"} {
varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} { 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 { sub vcl_deliver {
set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambucking = "foobar"; set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambucking = "foobar";
...@@ -84,7 +84,7 @@ varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} { ...@@ -84,7 +84,7 @@ varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} {
varnish v1 -vcl { varnish v1 -vcl {
backend foo { .host = "${bad_ip}"; .port = "9080"; } backend foo { .host = "127.0.0.1"; }
sub vcl_deliver { sub vcl_deliver {
set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckin = "foobar"; set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckin = "foobar";
......
...@@ -22,8 +22,7 @@ varnish v1 -vcl+backend { ...@@ -22,8 +22,7 @@ varnish v1 -vcl+backend {
.initial = 0; .initial = 0;
} }
backend sick { backend sick {
.host = "${bad_ip}"; .host = "${bad_backend}";
.port = "9080";
.probe = sick_probe; .probe = sick_probe;
} }
......
...@@ -448,12 +448,20 @@ dns_works(void) ...@@ -448,12 +448,20 @@ dns_works(void)
* Figure out what IP related magic * 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 static void
ip_magic(void) ip_magic(void)
{ {
const char *p; const char *p;
int fd; int fd;
char abuf[VTCP_ADDRBUFSIZE]; char abuf[VTCP_ADDRBUFSIZE];
char pbuf[VTCP_PORTBUFSIZE];
/* /*
* In FreeBSD jails localhost/127.0.0.1 becomes the jails IP# * In FreeBSD jails localhost/127.0.0.1 becomes the jails IP#
...@@ -462,12 +470,14 @@ ip_magic(void) ...@@ -462,12 +470,14 @@ ip_magic(void)
* XXX: "localhost", but that doesn't work out of the box. * XXX: "localhost", but that doesn't work out of the box.
* XXX: Things like "prefer_ipv6" parameter complicates things. * 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); assert(fd >= 0);
VTCP_myname(fd, abuf, sizeof abuf, NULL, 0); VTCP_myname(fd, abuf, sizeof abuf, pbuf, sizeof(pbuf));
AZ(close(fd));
extmacro_def("localhost", "%s", abuf); 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 * 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 * lot harder than it sounds. This IP# is from RFC5737 and a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment