blob: 43e25eb231b8c386dd82a1bdf05952acbd412986 [file] [log] [blame]
Frédéric Lécailledd51e532018-08-31 11:05:39 +02001# commit 3e60b11
2# BUG/MEDIUM: stick-tables: Decrement ref_cnt in table_* converters
3#
4# When using table_* converters ref_cnt was incremented
5# and never decremented causing entries to not expire.
6#
7# The root cause appears to be that stktable_lookup_key()
8# was called within all sample_conv_table_* functions which was
9# incrementing ref_cnt and not decrementing after completion.
10#
11# Added stktable_release() to the end of each sample_conv_table_*
12# function and reworked the end logic to ensure that ref_cnt is
13# always decremented after use.
14#
15# This should be backported to 1.8
16
17varnishtest "stick-tables: Test expirations when used with table_*"
18
19# As some macros for haproxy are used in this file, this line is mandatory.
20feature ignore_unknown_macro
21
22# Do nothing.
23server s1 {
24} -start
25
26haproxy h1 -conf {
27 # Configuration file of 'h1' haproxy instance.
28 defaults
29 mode http
30 timeout connect 5s
31 timeout server 30s
32 timeout client 30s
33
34 frontend http1
35 bind "fd@${my_frontend_fd}"
36 stick-table size 1k expire 1ms type ip store conn_rate(10s),http_req_cnt,http_err_cnt,http_req_rate(10s),http_err_rate(10s),gpc0,gpc0_rate(10s),gpt0
37 http-request track-sc0 req.hdr(X-Forwarded-For)
38 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
39 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
40 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),in_table(http1) -m int lt 0 }
41 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_in_rate(http1) -m int lt 0 }
42 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_out_rate(http1) -m int lt 0 }
43 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cnt(http1) -m int lt 0 }
44 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cur(http1) -m int lt 0 }
45 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_rate(http1) -m int lt 0 }
46 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpt0(http1) -m int lt 0 }
47 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0(http1) -m int lt 0 }
48 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0_rate(http1) -m int lt 0 }
49 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_cnt(http1) -m int lt 0 }
50 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_rate(http1) -m int lt 0 }
51 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
52 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_rate(http1) -m int lt 0 }
53 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_in(http1) -m int lt 0 }
54 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_out(http1) -m int lt 0 }
55 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_server_id(http1) -m int lt 0 }
56 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_cnt(http1) -m int lt 0 }
57 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_rate(http1) -m int lt 0 }
58 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
59 } -start
60
61client c1 -connect ${h1_my_frontend_fd_sock} {
62 txreq -url "/" -hdr "X-Forwarded-For: 127.0.0.1"
63 rxresp
64 expect resp.status == 503
65} -run
66
67haproxy h1 -cli {
68 send "show table http1"
69 expect ~ "table: http1, type: ip, size:1024, used:(0|1\\n0x[0-9a-f]*: key=127\\.0\\.0\\.1 use=0 exp=[0-9]* gpt0=0 gpc0=0 gpc0_rate\\(10000\\)=0 conn_rate\\(10000\\)=1 http_req_cnt=1 http_req_rate\\(10000\\)=1 http_err_cnt=0 http_err_rate\\(10000\\)=0)\\n$"
70} -wait