Testing Varnish with varnishtest·续1

Because the server has no support for French content and because Varnish doesn’t create a separate cache variation for the fr value, the test fails. Here’s the very verbose output:

$ varnishtest test.vtc
**** dT    0.000
*    top   TEST test.vtc starting
**** top   extmacro def pwd=/etc/varnish
**** top   extmacro def date(...)
**** top   extmacro def string(...)
**** top   extmacro def localhost=127.0.0.1
**** top   extmacro def bad_backend=127.0.0.1:40127
**** top   extmacro def listen_addr=127.0.0.1:0
**** top   extmacro def bad_ip=192.0.2.255
**** top   macro def testdir=/etc/varnish
**** top   macro def tmpdir=/tmp/vtc.1204.1da971c3
**   top   === varnishtest "Language cookie cache variation"
*    top   VTEST Language cookie cache variation
**   top   === server s1 {
**   s1    Starting server
**** s1    macro def s1_addr=127.0.0.1
**** s1    macro def s1_port=32807
**** s1    macro def s1_sock=127.0.0.1:32807
*    s1    Listen on 127.0.0.1:32807
**   top   === varnish v1 -vcl+backend {
**** dT    0.001
**   s1    Started on 127.0.0.1:32807 (1 iterations)
**** dT    0.007
**   v1    Launch
***  v1    CMD: cd ${pwd} && exec varnishd  -d -n /tmp/vtc.1204.1da971c3/v1 -l 2m -p auto_restart=off -p syslog_cli_traffic=off -p thread_pool_min=10 -p debug=+vtc_mode -p vsl_mask=+Debug -p h2_initial_window_size=1m -p h2_rx_window_low_water=64k -a '127.0.0.1:0' -M '127.0.0.1 33323' -P /tmp/vtc.1204.1da971c3/v1/varnishd.pid
***  v1    CMD: cd /etc/varnish && exec varnishd  -d -n /tmp/vtc.1204.1da971c3/v1 -l 2m -p auto_restart=off -p syslog_cli_traffic=off -p thread_pool_min=10 -p debug=+vtc_mode -p vsl_mask=+Debug -p h2_initial_window_size=1m -p h2_rx_window_low_water=64k -a '127.0.0.1:0' -M '127.0.0.1 33323' -P /tmp/vtc.1204.1da971c3/v1/varnishd.pid
**** dT    0.008
***  v1    PID: 1210
**** v1    macro def v1_pid=1210
**** v1    macro def v1_name=/tmp/vtc.1204.1da971c3/v1
**** dT    0.019
***  v1    debug|Debug: Version: varnish-7.0.1 revision d454d0ed759ce8ed2b5c7bf244090a73487e8021
***  v1    debug|Debug: Platform: Linux,5.10.76-linuxkit,aarch64,-junix,-sdefault,-sdefault,-hcritbit
***  v1    debug|200 318
***  v1    debug|-----------------------------
***  v1    debug|Varnish Cache CLI 1.0
***  v1    debug|-----------------------------
***  v1    debug|Linux,5.10.76-linuxkit,aarch64,-junix,-sdefault,-sdefault,-hcritbit
***  v1    debug|varnish-7.0.1 revision d454d0ed759ce8ed2b5c7bf244090a73487e8021
***  v1    debug|
***  v1    debug|Type 'help' for command list.
***  v1    debug|Type 'quit' to close CLI session.
***  v1    debug|Type 'start' to launch worker process.
***  v1    debug|
**** dT    0.121
**** v1    CLIPOLL 1 0x1 0x0 0x0
***  v1    CLI connection fd = 7
**** dT    0.122
***  v1    CLI RX  107
**** v1    CLI RX|vmflkeqmasqgjwqwcteihfqznqwmlney
**** v1    CLI RX|
**** v1    CLI RX|Authentication required.
**** v1    CLI TX|auth 03c9bf424fbaf18bd3bb931640ac9ee7fb242ea18ad0b525f8604aa33fda1952
**** dT    0.123
***  v1    CLI RX  200
**** v1    CLI RX|-----------------------------
**** v1    CLI RX|Varnish Cache CLI 1.0
**** v1    CLI RX|-----------------------------
**** v1    CLI RX|Linux,5.10.76-linuxkit,aarch64,-junix,-sdefault,-sdefault,-hcritbit
**** v1    CLI RX|varnish-7.0.1 revision d454d0ed759ce8ed2b5c7bf244090a73487e8021
**** v1    CLI RX|
**** v1    CLI RX|Type 'help' for command list.
**** v1    CLI RX|Type 'quit' to close CLI session.
**** v1    CLI RX|Type 'start' to launch worker process.
**** dT    0.124
**** v1    CLI TX|vcl.inline vcl1 << %XJEIFLH|)Xspa8P
**** v1    CLI TX|vcl 4.1;
**** v1    CLI TX|backend s1 { .host = "127.0.0.1"; .port = "32807"; }
**** v1    CLI TX|
**** v1    CLI TX|
**** v1    CLI TX|    vcl 4.1;
**** v1    CLI TX|
**** v1    CLI TX|    sub vcl_recv {
**** v1    CLI TX|        if (req.http.Cookie) {
**** v1    CLI TX|            set req.http.Cookie = ";" + req.http.Cookie;
**** v1    CLI TX|            set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
**** v1    CLI TX|            set req.http.Cookie = regsuball(req.http.Cookie, ";(language)=", "; \1=");
**** v1    CLI TX|            set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
**** v1    CLI TX|            set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
**** v1    CLI TX|
**** v1    CLI TX|            if (req.http.cookie ~ "^\s*$") {
**** v1    CLI TX|                unset req.http.cookie;
**** v1    CLI TX|            }
**** v1    CLI TX|
**** v1    CLI TX|            return(hash);
**** v1    CLI TX|        }
**** v1    CLI TX|    }
**** v1    CLI TX|
**** v1    CLI TX|    sub vcl_hash {
**** v1    CLI TX|        if(req.http.Cookie ~ "^.*language=(nl|en|fr);*.*$") {
**** v1    CLI TX|            hash_data(regsub( req.http.Cookie, "^.*language=(nl|en|fr);*.*$", "\1" ));
**** v1    CLI TX|        } else {
**** v1    CLI TX|            hash_data("en");
**** v1    CLI TX|        }
**** v1    CLI TX|
**** v1    CLI TX|    }
**** v1    CLI TX|
**** v1    CLI TX|%XJEIFLH|)Xspa8P
**** dT    0.229
***  v1    vsl|No VSL chunk found (child not started ?)
**** dT    0.329
***  v1    vsl|No VSL chunk found (child not started ?)
**** dT    0.333
***  v1    CLI RX  200
**** v1    CLI RX|VCL compiled.
**** v1    CLI TX|vcl.use vcl1
***  v1    CLI RX  200
**** v1    CLI RX|VCL 'vcl1' now active
**   v1    Start
**** v1    CLI TX|start
**** dT    0.334
***  v1    debug|Debug: Child (1226) Started
**** dT    0.357
***  v1    CLI RX  200
***  v1    wait-running
**** v1    CLI TX|status
***  v1    CLI RX  200
**** v1    CLI RX|Child in state running
**** v1    CLI TX|debug.listen_address
***  v1    debug|Info: Child (1226) said Child starts
**** dT    0.358
***  v1    CLI RX  200
**** v1    CLI RX|a0 127.0.0.1 45471
**** v1    CLI TX|debug.xid 999
***  v1    CLI RX  200
**** v1    CLI RX|XID is 999
**** v1    CLI TX|debug.listen_address
***  v1    CLI RX  200
**** v1    CLI RX|a0 127.0.0.1 45471
**   v1    Listen on 127.0.0.1 45471
**** v1    macro def v1_addr=127.0.0.1
**** v1    macro def v1_port=45471
**** v1    macro def v1_sock=127.0.0.1:45471
**** v1    macro def v1_a0_addr=127.0.0.1
**** v1    macro def v1_a0_port=45471
**** v1    macro def v1_a0_sock=127.0.0.1:45471
**** dT    0.434
**** v1    vsl|          0 CLI             - Rd vcl.load "vcl1" vcl_vcl1.1640785455.977380/vgc.so 1auto
**** v1    vsl|          0 CLI             - Wr 200 52 Loaded "vcl_vcl1.1640785455.977380/vgc.so" as "vcl1"
**** v1    vsl|          0 CLI             - Rd vcl.use "vcl1"
**** v1    vsl|          0 CLI             - Wr 200 0
**** v1    vsl|          0 CLI             - Rd start
**** v1    vsl|          0 Debug           - sockopt: Setting SO_LINGER for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting SO_KEEPALIVE for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting SO_SNDTIMEO for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting SO_RCVTIMEO for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting TCP_NODELAY for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting TCP_KEEPIDLE for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting TCP_KEEPCNT for a0=127.0.0.1:45471
**** v1    vsl|          0 Debug           - sockopt: Setting TCP_KEEPINTVL for a0=127.0.0.1:45471
**** v1    vsl|          0 CLI             - Wr 200 0
**** v1    vsl|          0 CLI             - Rd debug.listen_address
**** v1    vsl|          0 CLI             - Wr 200 19 a0 127.0.0.1 45471

**** v1    vsl|          0 CLI             - Rd debug.xid 999
**** v1    vsl|          0 CLI             - Wr 200 10 XID is 999
**** v1    vsl|          0 CLI             - Rd debug.listen_address
**** v1    vsl|          0 CLI             - Wr 200 19 a0 127.0.0.1 45471

**** dT    0.459
**   top   === client c1 {
**   c1    Starting client
**   c1    Waiting for client
**   c1    Started on 127.0.0.1:45471 (1 iterations)
***  c1    Connect to 127.0.0.1:45471
***  c1    connected fd 17 from 127.0.0.1 45314 to 127.0.0.1:45471
**   c1    === txreq -hdr "Cookie: a=1; b=2; language=nl; c=3"
**** c1    txreq|GET / HTTP/1.1\r
**** c1    txreq|Cookie: a=1; b=2; language=nl; c=3\r
**** c1    txreq|Host: 127.0.0.1\r
**** c1    txreq|\r
**   c1    === rxresp
***  s1    accepted fd 5 127.0.0.1 51844
**   s1    === rxreq
**** dT    0.460
**** s1    rxhdr|GET / HTTP/1.1\r
**** s1    rxhdr|Host: 127.0.0.1\r
**** s1    rxhdr|X-Forwarded-For: 127.0.0.1\r
**** s1    rxhdr|Cookie: language=nl\r
**** s1    rxhdr|Accept-Encoding: gzip\r
**** s1    rxhdr|X-Varnish: 1002\r
**** s1    rxhdr|\r
**** s1    rxhdrlen = 124
**** s1    http[ 0] |GET
**** s1    http[ 1] |/
**** s1    http[ 2] |HTTP/1.1
**** s1    http[ 3] |Host: 127.0.0.1
**** s1    http[ 4] |X-Forwarded-For: 127.0.0.1
**** s1    http[ 5] |Cookie: language=nl
**** s1    http[ 6] |Accept-Encoding: gzip
**** s1    http[ 7] |X-Varnish: 1002
**** s1    bodylen = 0
**   s1    === expect req.http.Cookie == "language=nl"
**** s1    EXPECT req.http.Cookie (language=nl) == "language=nl" match
**   s1    === txresp -body "Goede morgen"
**** s1    txresp|HTTP/1.1 200 OK\r
**** s1    txresp|Content-Length: 12\r
**** s1    txresp|\r
**** s1    txresp|Goede morgen
**   s1    === rxreq
**** c1    rxhdr|HTTP/1.1 200 OK\r
**** c1    rxhdr|Content-Length: 12\r
**** c1    rxhdr|Date: Wed, 29 Dec 2021 13:44:16 GMT\r
**** c1    rxhdr|X-Varnish: 1001\r
**** c1    rxhdr|Age: 0\r
**** c1    rxhdr|Via: 1.1 varnish (Varnish/7.0)\r
**** c1    rxhdr|Accept-Ranges: bytes\r
**** c1    rxhdr|Connection: keep-alive\r
**** c1    rxhdr|\r
**** c1    rxhdrlen = 179
**** c1    http[ 0] |HTTP/1.1
**** c1    http[ 1] |200
**** c1    http[ 2] |OK
**** c1    http[ 3] |Content-Length: 12
**** c1    http[ 4] |Date: Wed, 29 Dec 2021 13:44:16 GMT
**** c1    http[ 5] |X-Varnish: 1001
**** c1    http[ 6] |Age: 0
**** c1    http[ 7] |Via: 1.1 varnish (Varnish/7.0)
**** c1    http[ 8] |Accept-Ranges: bytes
**** c1    http[ 9] |Connection: keep-alive
**** c1    c-l|Goede morgen
**** c1    bodylen = 12
**   c1    === expect resp.body == "Goede morgen"
**** c1    EXPECT resp.body (Goede morgen) == "Goede morgen" match
**   c1    === txreq -hdr "Cookie: a=1; language=en"
**** c1    txreq|GET / HTTP/1.1\r
**** c1    txreq|Cookie: a=1; language=en\r
**** c1    txreq|Host: 127.0.0.1\r
**** c1    txreq|\r
**   c1    === rxresp
**** dT    0.470
**** s1    rxhdr|GET / HTTP/1.1\r
**** s1    rxhdr|Host: 127.0.0.1\r
**** s1    rxhdr|X-Forwarded-For: 127.0.0.1\r
**** s1    rxhdr|Cookie: language=en\r
**** s1    rxhdr|Accept-Encoding: gzip\r
**** s1    rxhdr|X-Varnish: 1004\r
**** s1    rxhdr|\r
**** s1    rxhdrlen = 124
**** s1    http[ 0] |GET
**** s1    http[ 1] |/
**** s1    http[ 2] |HTTP/1.1
**** s1    http[ 3] |Host: 127.0.0.1
**** s1    http[ 4] |X-Forwarded-For: 127.0.0.1
**** s1    http[ 5] |Cookie: language=en
**** s1    http[ 6] |Accept-Encoding: gzip
**** s1    http[ 7] |X-Varnish: 1004
**** s1    bodylen = 0
**   s1    === expect req.http.Cookie != "language=nl"
**** s1    EXPECT req.http.Cookie (language=en) != "language=nl" match
**   s1    === txresp -body "Good morning"
**** s1    txresp|HTTP/1.1 200 OK\r
**** s1    txresp|Content-Length: 12\r
**** s1    txresp|\r
**** s1    txresp|Good morning
**   s1    === rxreq
**** dT    0.471
**** c1    rxhdr|HTTP/1.1 200 OK\r
**** c1    rxhdr|Content-Length: 12\r
**** c1    rxhdr|Date: Wed, 29 Dec 2021 13:44:16 GMT\r
**** c1    rxhdr|X-Varnish: 1003\r
**** c1    rxhdr|Age: 0\r
**** c1    rxhdr|Via: 1.1 varnish (Varnish/7.0)\r
**** c1    rxhdr|Accept-Ranges: bytes\r
**** c1    rxhdr|Connection: keep-alive\r
**** c1    rxhdr|\r
**** c1    rxhdrlen = 179
**** c1    http[ 0] |HTTP/1.1
**** c1    http[ 1] |200
**** c1    http[ 2] |OK
**** c1    http[ 3] |Content-Length: 12
**** c1    http[ 4] |Date: Wed, 29 Dec 2021 13:44:16 GMT
**** c1    http[ 5] |X-Varnish: 1003
**** c1    http[ 6] |Age: 0
**** c1    http[ 7] |Via: 1.1 varnish (Varnish/7.0)
**** c1    http[ 8] |Accept-Ranges: bytes
**** c1    http[ 9] |Connection: keep-alive
**** c1    c-l|Good morning
**** c1    bodylen = 12
**   c1    === expect resp.body == "Good morning"
**** c1    EXPECT resp.body (Good morning) == "Good morning" match
**   c1    === txreq -hdr "Cookie: a=1; language=fr"
**** c1    txreq|GET / HTTP/1.1\r
**** c1    txreq|Cookie: a=1; language=fr\r
**** c1    txreq|Host: 127.0.0.1\r
**** c1    txreq|\r
**   c1    === rxresp
**** dT    0.483
**** s1    rxhdr|GET / HTTP/1.1\r
**** s1    rxhdr|Host: 127.0.0.1\r
**** s1    rxhdr|X-Forwarded-For: 127.0.0.1\r
**** s1    rxhdr|Cookie: language=fr\r
**** s1    rxhdr|Accept-Encoding: gzip\r
**** s1    rxhdr|X-Varnish: 1006\r
**** s1    rxhdr|\r
**** s1    rxhdrlen = 124
**** s1    http[ 0] |GET
**** s1    http[ 1] |/
**** s1    http[ 2] |HTTP/1.1
**** s1    http[ 3] |Host: 127.0.0.1
**** s1    http[ 4] |X-Forwarded-For: 127.0.0.1
**** s1    http[ 5] |Cookie: language=fr
**** s1    http[ 6] |Accept-Encoding: gzip
**** s1    http[ 7] |X-Varnish: 1006
**** s1    bodylen = 0
**   s1    === expect req.http.Cookie != "language=nl"
**** s1    EXPECT req.http.Cookie (language=fr) != "language=nl" match
**   s1    === txresp -body "Good morning"
**** s1    txresp|HTTP/1.1 200 OK\r
**** s1    txresp|Content-Length: 12\r
**** s1    txresp|\r
**** s1    txresp|Good morning
**   s1    === rxreq
**** dT    0.484
**** c1    rxhdr|HTTP/1.1 200 OK\r
**** c1    rxhdr|Content-Length: 12\r
**** c1    rxhdr|Date: Wed, 29 Dec 2021 13:44:16 GMT\r
**** c1    rxhdr|X-Varnish: 1005\r
**** c1    rxhdr|Age: 0\r
**** c1    rxhdr|Via: 1.1 varnish (Varnish/7.0)\r
**** c1    rxhdr|Accept-Ranges: bytes\r
**** c1    rxhdr|Connection: keep-alive\r
**** c1    rxhdr|\r
**** c1    rxhdrlen = 179
**** c1    http[ 0] |HTTP/1.1
**** c1    http[ 1] |200
**** c1    http[ 2] |OK
**** c1    http[ 3] |Content-Length: 12
**** c1    http[ 4] |Date: Wed, 29 Dec 2021 13:44:16 GMT
**** c1    http[ 5] |X-Varnish: 1005
**** c1    http[ 6] |Age: 0
**** c1    http[ 7] |Via: 1.1 varnish (Varnish/7.0)
**** c1    http[ 8] |Accept-Ranges: bytes
**** c1    http[ 9] |Connection: keep-alive
**** c1    c-l|Good morning
**** c1    bodylen = 12
**   c1    === expect resp.body == "Good morning"
**** c1    EXPECT resp.body (Good morning) == "Good morning" match
**   c1    === txreq
**** c1    txreq|GET / HTTP/1.1\r
**** c1    txreq|Host: 127.0.0.1\r
**** c1    txreq|\r
**   c1    === rxresp
**** dT    0.497
**** c1    rxhdr|HTTP/1.1 200 OK\r
**** c1    rxhdr|Content-Length: 12\r
**** c1    rxhdr|Date: Wed, 29 Dec 2021 13:44:16 GMT\r
**** c1    rxhdr|X-Varnish: 1007 1004\r
**** c1    rxhdr|Age: 0\r
**** c1    rxhdr|Via: 1.1 varnish (Varnish/7.0)\r
**** c1    rxhdr|Accept-Ranges: bytes\r
**** c1    rxhdr|Connection: keep-alive\r
**** c1    rxhdr|\r
**** c1    rxhdrlen = 184
**** c1    http[ 0] |HTTP/1.1
**** c1    http[ 1] |200
**** c1    http[ 2] |OK
**** c1    http[ 3] |Content-Length: 12
**** c1    http[ 4] |Date: Wed, 29 Dec 2021 13:44:16 GMT
**** c1    http[ 5] |X-Varnish: 1007 1004
**** c1    http[ 6] |Age: 0