source: bin/varnishtest/tests/r00977.vtc @ 149c4d

Revision 149c4d, 884 bytes checked in by Poul-Henning Kamp <phk@…>, 3 years ago (diff)

Implement a consistent retry policy in the random/client/hash director:

If the first (policy-chosen) backend fails to get us a connection,
retry a random backend (still according to their weight) until
retries are exhausted.

Kristian sent a proof of concept patch, I just cleaned it up and made
it compile.

Thanks to: Kristian

Fixes #977

  • Property mode set to 100644
Line 
1
2varnishtest "Test proper fallbacks of client director"
3
4server s1 {
5        rxreq
6        txresp -status 200
7        accept
8        rxreq
9        txresp -status 200
10} -start
11
12varnish v1 -vcl+backend {
13        director foo client{
14                .retries = 5;
15                { .backend = { .host = "${bad_ip}"; .port = "9090"; } .weight = 1; }
16                { .backend = s1; .weight = 1;}
17        }
18        director bar client{
19                .retries = 1;
20                { .backend = { .host = "${bad_ip}"; .port = "9090"; } .weight = 1; }
21                { .backend = s1; .weight = 1;}
22        }
23        sub vcl_recv {
24                if (req.url ~ "/one") {
25                        set req.backend = foo;
26                } else {
27                        set req.backend = bar;
28                }
29                # Carefully chosen seed that'll give us bad backend on
30                # first try and good on second.
31                set client.identity = "1.4";
32                return (pass);
33        }
34} -start
35
36client c1 {
37        txreq -url "/one"
38        rxresp
39        expect resp.status == 200
40
41        txreq -url "/two"
42        rxresp
43        expect resp.status == 503
44} -run
45
46varnish v1 -expect backend_fail == 2
Note: See TracBrowser for help on using the repository browser.