From: tfheen Date: Mon, 8 Sep 2008 09:49:01 +0000 (+0000) Subject: Rename backend.health to req.backend.health and add test X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5159fdbfdd082f004f6eb0e918ca9c22bb20710;p=varnish Rename backend.health to req.backend.health and add test git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3169 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index f83c417f..2235edb2 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -585,7 +585,7 @@ VRT_r_obj_hash(const struct sess *sp) } unsigned -VRT_r_backend_healthy(const struct sess *sp) +VRT_r_req_backend_healthy(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); diff --git a/varnish-cache/bin/varnishtest/tests/v00014.vtc b/varnish-cache/bin/varnishtest/tests/v00014.vtc new file mode 100644 index 00000000..4acd9c1f --- /dev/null +++ b/varnish-cache/bin/varnishtest/tests/v00014.vtc @@ -0,0 +1,48 @@ +# $Id$ + +test "Check req.backend.healthy" + +server s1 { + rxreq + expect req.url == "/" + txresp -body "slash" +} -start -repeat 4 + +varnish v1 -vcl { + + backend default { + .host = "127.0.0.1"; + .port = "9080"; + .max_connections = 1; + .probe = { + .url = "/"; + .timeout = 100 ms; + .interval = 1s; + .window = 3; + .threshold = 2; + } + } + + sub vcl_recv { + if (req.backend.healthy) { + error 200 "Backend healthy"; + } else { + error 500 "Backend sick"; + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 500 +} -run + +shell "sleep 1" + +client c2 { + txreq + rxresp + expect resp.status == 200 +} -start + diff --git a/varnish-cache/include/vrt_obj.h b/varnish-cache/include/vrt_obj.h index 6d7e691a..e11b4eb8 100644 --- a/varnish-cache/include/vrt_obj.h +++ b/varnish-cache/include/vrt_obj.h @@ -52,4 +52,4 @@ void VRT_l_resp_status(const struct sess *, int); const char * VRT_r_resp_response(const struct sess *); void VRT_l_resp_response(const struct sess *, const char *, ...); double VRT_r_now(const struct sess *); -unsigned VRT_r_backend_healthy(const struct sess *); +unsigned VRT_r_req_backend_healthy(const struct sess *); diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index ba24a2b8..7a41bdae 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -510,5 +510,5 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "const char * VRT_r_resp_response(const struct sess *);\n"); vsb_cat(sb, "void VRT_l_resp_response(const struct sess *, const char *, ...);\n"); vsb_cat(sb, "double VRT_r_now(const struct sess *);\n"); - vsb_cat(sb, "unsigned VRT_r_backend_healthy(const struct sess *);\n"); + vsb_cat(sb, "unsigned VRT_r_req_backend_healthy(const struct sess *);\n"); } diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index 2c9a2a0d..5d728e48 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -216,7 +216,7 @@ set spobj { {recv pipe pass hash miss hit fetch deliver discard timeout} "const struct sess *" } - { backend.healthy RO BOOL + { req.backend.healthy RO BOOL {recv pipe pass hash miss hit fetch deliver discard timeout} "const struct sess *" } diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index eeff69f6..a2d9ac8a 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -235,8 +235,8 @@ struct var vcc_vars[] = { 0, VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT }, - { "backend.healthy", BOOL, 15, - "VRT_r_backend_healthy(sp)", + { "req.backend.healthy", BOOL, 19, + "VRT_r_req_backend_healthy(sp)", NULL, V_RO, 0,