Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 1 | vtest "Basic test for peers protocol stick-table declared in peers sections" |
| 2 | feature ignore_unknown_macro |
| 3 | |
Frédéric Lécaille | c8f931c | 2019-05-07 11:11:00 +0200 | [diff] [blame] | 4 | #REGTEST_TYPE=slow |
Willy Tarreau | 596ce52 | 2019-05-07 07:53:54 +0200 | [diff] [blame] | 5 | |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 6 | haproxy h1 -arg "-L A" -conf { |
| 7 | defaults |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 8 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 9 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 10 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 11 | |
| 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 Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 22 | tcp-request inspect-delay 100ms |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 23 | tcp-request content track-sc0 url table peers/stkt |
| 24 | tcp-request content sc-inc-gpc0(0) |
| 25 | } |
| 26 | |
| 27 | haproxy h2 -arg "-L B" -conf { |
| 28 | defaults |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 29 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 30 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 31 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 32 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 33 | |
| 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 | |
| 47 | haproxy h3 -arg "-L C" -conf { |
| 48 | defaults |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 49 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 50 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 51 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 52 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 53 | |
| 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 | |
| 67 | client c1 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 68 | txreq -url "/c1_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 69 | expect_close |
| 70 | } -start |
| 71 | |
| 72 | client c2 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 73 | txreq -url "/c2_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 74 | expect_close |
| 75 | } -start |
| 76 | |
| 77 | client c3 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 78 | txreq -url "/c3_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 79 | expect_close |
| 80 | } -start |
| 81 | |
| 82 | client c4 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 83 | txreq -url "/c4_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 84 | expect_close |
| 85 | } -start |
| 86 | |
| 87 | haproxy h1 -start |
| 88 | delay 0.2 |
| 89 | haproxy h2 -start |
| 90 | delay 0.2 |
| 91 | haproxy h3 -start |
| 92 | delay 0.2 |
| 93 | |
| 94 | client c1 -wait |
| 95 | client c2 -wait |
| 96 | client c3 -wait |
| 97 | client c4 -wait |
| 98 | |
| 99 | delay 2 |
| 100 | |
| 101 | haproxy h1 -cli { |
| 102 | send "show table peers/stkt" |
Willy Tarreau | 5a63e72 | 2022-11-29 16:29:12 +0100 | [diff] [blame] | 103 | 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écaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | haproxy h2 -cli { |
| 107 | send "show table peers/stkt" |
Willy Tarreau | 5a63e72 | 2022-11-29 16:29:12 +0100 | [diff] [blame] | 108 | 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écaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | haproxy h3 -cli { |
| 112 | send "show table peers/stkt" |
Willy Tarreau | 5a63e72 | 2022-11-29 16:29:12 +0100 | [diff] [blame] | 113 | 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écaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 114 | } |
| 115 | |