blob: 9f97ff54e5df62a0fff8540fb543523d8ea50b4c [file] [log] [blame]
Frédéric Lécaille4d789482019-03-18 14:08:46 +01001vtest "Basic test for peers protocol stick-table declared in peers sections"
2feature ignore_unknown_macro
3
Frédéric Lécaillec8f931c2019-05-07 11:11:00 +02004#REGTEST_TYPE=slow
Willy Tarreau596ce522019-05-07 07:53:54 +02005
Frédéric Lécaille4d789482019-03-18 14:08:46 +01006haproxy h1 -arg "-L A" -conf {
7 defaults
Willy Tarreauf6739232021-11-18 17:46:22 +01008 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
9 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
10 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010011
12
13 peers peers
14 bind "fd@${A}"
15 server A
16 server B ${h2_B_addr}:${h2_B_port}
17 server C ${h3_C_addr}:${h3_C_port}
18 table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000)
19
20 frontend fe
21 bind "fd@${fe}"
Christopher Faulet1448d3a2019-10-14 16:10:52 +020022 tcp-request inspect-delay 100ms
Frédéric Lécaille4d789482019-03-18 14:08:46 +010023 tcp-request content track-sc0 url table peers/stkt
24 tcp-request content sc-inc-gpc0(0)
25}
26
27haproxy h2 -arg "-L B" -conf {
28 defaults
Christopher Faulet1448d3a2019-10-14 16:10:52 +020029 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010030 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
31 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
32 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010033
34 peers peers
35 bind "fd@${B}"
36 server A ${h1_A_addr}:${h1_A_port}
37 server B
38 server C ${h3_C_addr}:${h3_C_port}
39 table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000)
40
41 frontend fe
42 bind "fd@${fe}"
43 http-request track-sc0 url table peers/stkt
44 http-request sc-inc-gpc0(0)
45}
46
47haproxy h3 -arg "-L C" -conf {
48 defaults
Christopher Faulet1448d3a2019-10-14 16:10:52 +020049 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010050 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
51 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
52 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010053
54 peers peers
55 bind "fd@${C}"
56 server A ${h1_A_addr}:${h1_A_port}
57 server B ${h2_B_addr}:${h2_B_port}
58 server C
59 table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000)
60
61 frontend fe
62 bind "fd@${fe}"
63 http-request track-sc0 url table peers/stkt
64 http-request sc-inc-gpc0(0)
65}
66
67client c1 -connect ${h1_fe_sock} {
Christopher Faulet1448d3a2019-10-14 16:10:52 +020068 txreq -url "/c1_client"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010069 expect_close
70} -start
71
72client c2 -connect ${h1_fe_sock} {
Christopher Faulet1448d3a2019-10-14 16:10:52 +020073 txreq -url "/c2_client"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010074 expect_close
75} -start
76
77client c3 -connect ${h1_fe_sock} {
Christopher Faulet1448d3a2019-10-14 16:10:52 +020078 txreq -url "/c3_client"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010079 expect_close
80} -start
81
82client c4 -connect ${h1_fe_sock} {
Christopher Faulet1448d3a2019-10-14 16:10:52 +020083 txreq -url "/c4_client"
Frédéric Lécaille4d789482019-03-18 14:08:46 +010084 expect_close
85} -start
86
87haproxy h1 -start
88delay 0.2
89haproxy h2 -start
90delay 0.2
91haproxy h3 -start
92delay 0.2
93
94client c1 -wait
95client c2 -wait
96client c3 -wait
97client c4 -wait
98
99delay 2
100
101haproxy h1 -cli {
102 send "show table peers/stkt"
Willy Tarreau5a63e722022-11-29 16:29:12 +0100103 expect ~ "# table: peers/stkt, type: string, size:1048[0-9]{4}, used:4(\n0x[0-9a-f]*: key=/c[1-4]_client use=0 exp=0 shard=0 server_id=0 gpc0=1 conn_rate\\(50000\\)=1 conn_cur=0){4}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +0100104}
105
106haproxy h2 -cli {
107 send "show table peers/stkt"
Willy Tarreau5a63e722022-11-29 16:29:12 +0100108 expect ~ "# table: peers/stkt, type: string, size:1048[0-9]{4}, used:4(\n0x[0-9a-f]*: key=/c[1-4]_client use=0 exp=0 shard=0 server_id=0 gpc0=1 conn_rate\\(50000\\)=1 conn_cur=0){4}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +0100109}
110
111haproxy h3 -cli {
112 send "show table peers/stkt"
Willy Tarreau5a63e722022-11-29 16:29:12 +0100113 expect ~ "# table: peers/stkt, type: string, size:1048[0-9]{4}, used:4(\n0x[0-9a-f]*: key=/c[1-4]_client use=0 exp=0 shard=0 server_id=0 gpc0=1 conn_rate\\(50000\\)=1 conn_cur=0){4}"
Frédéric Lécaille4d789482019-03-18 14:08:46 +0100114}
115