Commit 86eba833 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Have clients pick up the varnish accept address using macros.

Make the varnish accept address just use a random free TCP port.

Fix a couple of tests where we need to know the port number.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4372 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e4d6bb3a
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
test "Check -f command line arg" test "Check -f command line arg"
shell "echo 'backend foo { .host = \"127.0.0.1\"; .port = \"9080\"; }' > /tmp/_b00014.vcl"
varnish v1 -arg "-f /tmp/_b00014.vcl" -start
server s1 { server s1 {
rxreq rxreq
...@@ -14,6 +12,9 @@ server s1 { ...@@ -14,6 +12,9 @@ server s1 {
txresp -body "bar" txresp -body "bar"
} -start } -start
shell "echo 'backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > /tmp/_b00014.vcl"
varnish v1 -arg "-f /tmp/_b00014.vcl" -start
client c1 { client c1 {
txreq -url /foo txreq -url /foo
rxresp rxresp
......
...@@ -13,7 +13,7 @@ server s1 { ...@@ -13,7 +13,7 @@ server s1 {
# Benchmark Testing # Benchmark Testing
varnish v1 -cliok "param.set listen_address 198.18.1.1:9082" varnish v1 -cliok "param.set listen_address 198.18.1.1:9082"
varnish v1 -vcl+backend {} -clierr 300 start varnish v1 -vcl+backend {} -clierr 300 start
varnish v1 -cliok "param.set listen_address :9081,127.0.0.2:9082" varnish v1 -cliok "param.set listen_address 127.0.0.1:9081,127.0.0.2:9082"
varnish v1 -start varnish v1 -start
client c1 { client c1 {
......
...@@ -8,6 +8,9 @@ server s1 { ...@@ -8,6 +8,9 @@ server s1 {
rxreq rxreq
txresp -hdr "Panic: please" -body "012345\n" txresp -hdr "Panic: please" -body "012345\n"
sema r1 sync 2 sema r1 sync 2
accept
rxreq
txresp -hdr "Foo: foo" -body "abcdef\n"
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
...@@ -19,7 +22,12 @@ varnish v1 -vcl+backend { ...@@ -19,7 +22,12 @@ varnish v1 -vcl+backend {
} }
} -start } -start
varnish v1 -cliok "param.set diag_bitmap 0x00001000" varnish v1 -cliok "param.set diag_bitmap 0x00001000"
# We have to force a known listen address otherwise the client cannot find
# the varnish after the restart.
varnish v1 -cliok "param.set listen_address 127.0.0.1:9080" -stop -start
# varnishtest defaults to auto_restart off, to avoid masking bugs. # varnishtest defaults to auto_restart off, to avoid masking bugs.
varnish v1 -cliok "param.set auto_restart on" varnish v1 -cliok "param.set auto_restart on"
...@@ -31,13 +39,9 @@ client c1 { ...@@ -31,13 +39,9 @@ client c1 {
txreq -url "/foo" txreq -url "/foo"
# Don't expect answer, the server crashed. # Don't expect answer, the server crashed.
sema r1 sync 2 sema r1 sync 2
delay 2.5
} -run } -run
server s1 { delay 2.5
rxreq
txresp -hdr "Foo: foo" -body "abcdef\n"
} -start
client c1 { client c1 {
txreq -url "/" txreq -url "/"
......
...@@ -136,7 +136,7 @@ macro_get(const char *name) ...@@ -136,7 +136,7 @@ macro_get(const char *name)
return (retval); return (retval);
} }
static struct vsb * struct vsb *
macro_expand(char *name) macro_expand(char *name)
{ {
struct vsb *vsb; struct vsb *vsb;
......
...@@ -74,4 +74,4 @@ void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, ...@@ -74,4 +74,4 @@ void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx,
const char *str); const char *str);
void macro_def(struct vtclog *vl, const char *instance, const char *name, const char *fmt, ...); void macro_def(struct vtclog *vl, const char *instance, const char *name, const char *fmt, ...);
struct vsb *macro_expand(char *name);
...@@ -42,6 +42,7 @@ SVNID("$Id$") ...@@ -42,6 +42,7 @@ SVNID("$Id$")
#include "vtc.h" #include "vtc.h"
#include "vsb.h"
#include "vqueue.h" #include "vqueue.h"
#include "miniobj.h" #include "miniobj.h"
#include "vss.h" #include "vss.h"
...@@ -78,29 +79,39 @@ client_thread(void *priv) ...@@ -78,29 +79,39 @@ client_thread(void *priv)
int fd; int fd;
int i; int i;
unsigned u; unsigned u;
struct vsb *vsb;
char *p;
CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
AN(c->connect); AN(c->connect);
p = strdup(c->connect);
vsb = macro_expand(p);
AN(vsb);
vl = vtc_logopen(c->name); vl = vtc_logopen(c->name);
if (c->repeat == 0) if (c->repeat == 0)
c->repeat = 1; c->repeat = 1;
vtc_log(vl, 2, "Started (%u iterations)", c->repeat); vtc_log(vl, 2, "Started (%u iterations)", c->repeat);
for (u = 0; u < c->repeat; u++) { for (u = 0; u < c->repeat; u++) {
vtc_log(vl, 3, "Connect to %s", c->connect); vtc_log(vl, 3, "Connect to %s", vsb_data(vsb));
fd = VSS_open(c->connect); fd = VSS_open(vsb_data(vsb));
for (i = 0; fd < 0 && i < 3; i++) { for (i = 0; fd < 0 && i < 3; i++) {
(void)sleep(1); (void)sleep(1);
fd = VSS_open(c->connect); fd = VSS_open(vsb_data(vsb));
} }
if (fd < 0)
vtc_log(c->vl, 0, "Failed to open %s", vsb_data(vsb));
assert(fd >= 0); assert(fd >= 0);
vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd); vtc_log(vl, 3, "Connected to %s fd is %d", vsb_data(vsb), fd);
http_process(vl, c->spec, fd, -1); http_process(vl, c->spec, fd, -1);
vtc_log(vl, 3, "Closing fd %d", fd); vtc_log(vl, 3, "Closing fd %d", fd);
TCP_close(&fd); TCP_close(&fd);
} }
vtc_log(vl, 2, "Ending"); vtc_log(vl, 2, "Ending");
vsb_delete(vsb);
free(p);
return (NULL); return (NULL);
} }
...@@ -122,7 +133,7 @@ client_new(const char *name) ...@@ -122,7 +133,7 @@ client_new(const char *name)
if (*c->name != 'c') if (*c->name != 'c')
vtc_log(c->vl, 0, "Client name must start with 'c'"); vtc_log(c->vl, 0, "Client name must start with 'c'");
REPLACE(c->connect, "127.0.0.1:9081"); REPLACE(c->connect, "${v1_sock}");
VTAILQ_INSERT_TAIL(&clients, c, list); VTAILQ_INSERT_TAIL(&clients, c, list);
return (c); return (c);
} }
......
...@@ -172,7 +172,7 @@ varnish_new(const char *name) ...@@ -172,7 +172,7 @@ varnish_new(const char *name)
v->args = vsb_newauto(); v->args = vsb_newauto();
v->telnet = "127.0.0.1:9001"; v->telnet = "127.0.0.1:9001";
v->accept = "127.0.0.1:9081"; v->accept = "127.0.0.1:0";
v->cli_fd = -1; v->cli_fd = -1;
VTAILQ_INSERT_TAIL(&varnishes, v, list); VTAILQ_INSERT_TAIL(&varnishes, v, list);
......
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