]> err.no Git - varnish/commitdiff
Rename backend.health to req.backend.health and add test
authortfheen <tfheen@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Sep 2008 09:49:01 +0000 (09:49 +0000)
committertfheen <tfheen@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Sep 2008 09:49:01 +0000 (09:49 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3169 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishtest/tests/v00014.vtc [new file with mode: 0644]
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c

index f83c417f5fc311c8fde4365231235e4c81e9b6ff..2235edb248653d72d042c28d0f6b90f8a15d79d3 100644 (file)
@@ -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 (file)
index 0000000..4acd9c1
--- /dev/null
@@ -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
+
index 6d7e691a601c42ec3a53da8b54c52c4f51a7aca5..e11b4eb8e13b21df5a23993e59605d87f1c5a7bb 100644 (file)
@@ -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 *);
index ba24a2b83099d9be8e9cba8abd44031901b645ce..7a41bdae28b8589c4bab957d3038d715b0a98834 100644 (file)
@@ -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");
 }
index 2c9a2a0d573bdbc96da0a42f5cffd89c2dd3a662..5d728e4848147e40bab66612f0bb79f0c855c24b 100755 (executable)
@@ -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 *"
     }
index eeff69f6312ac1d0e44a0f0e668500413bbceae6..a2d9ac8a7a36e0bc3e43a74bc59c12a5242ffacf 100644 (file)
@@ -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,