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 | |
Willy Tarreau | 596ce52 | 2019-05-07 07:53:54 +0200 | [diff] [blame] | 4 | #REQUIRE_VERSION=2.0 |
Frédéric Lécaille | c8f931c | 2019-05-07 11:11:00 +0200 | [diff] [blame] | 5 | #REGTEST_TYPE=slow |
Willy Tarreau | 596ce52 | 2019-05-07 07:53:54 +0200 | [diff] [blame] | 6 | |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 7 | haproxy h1 -arg "-L A" -conf { |
| 8 | defaults |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 9 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 10 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 11 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 12 | |
| 13 | |
| 14 | peers peers |
| 15 | bind "fd@${A}" |
| 16 | server A |
| 17 | server B ${h2_B_addr}:${h2_B_port} |
| 18 | server C ${h3_C_addr}:${h3_C_port} |
| 19 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 20 | |
| 21 | frontend fe |
| 22 | bind "fd@${fe}" |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 23 | tcp-request inspect-delay 100ms |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 24 | tcp-request content track-sc0 url table peers/stkt |
| 25 | tcp-request content sc-inc-gpc0(0) |
| 26 | } |
| 27 | |
| 28 | haproxy h2 -arg "-L B" -conf { |
| 29 | defaults |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 30 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 31 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 32 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 33 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 34 | |
| 35 | peers peers |
| 36 | bind "fd@${B}" |
| 37 | server A ${h1_A_addr}:${h1_A_port} |
| 38 | server B |
| 39 | server C ${h3_C_addr}:${h3_C_port} |
| 40 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 41 | |
| 42 | frontend fe |
| 43 | bind "fd@${fe}" |
| 44 | http-request track-sc0 url table peers/stkt |
| 45 | http-request sc-inc-gpc0(0) |
| 46 | } |
| 47 | |
| 48 | haproxy h3 -arg "-L C" -conf { |
| 49 | defaults |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 50 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 51 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 52 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 53 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 54 | |
| 55 | peers peers |
| 56 | bind "fd@${C}" |
| 57 | server A ${h1_A_addr}:${h1_A_port} |
| 58 | server B ${h2_B_addr}:${h2_B_port} |
| 59 | server C |
| 60 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 61 | |
| 62 | frontend fe |
| 63 | bind "fd@${fe}" |
| 64 | http-request track-sc0 url table peers/stkt |
| 65 | http-request sc-inc-gpc0(0) |
| 66 | } |
| 67 | |
| 68 | client c1 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 69 | txreq -url "/c1_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 70 | expect_close |
| 71 | } -start |
| 72 | |
| 73 | client c2 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 74 | txreq -url "/c2_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 75 | expect_close |
| 76 | } -start |
| 77 | |
| 78 | client c3 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 79 | txreq -url "/c3_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 80 | expect_close |
| 81 | } -start |
| 82 | |
| 83 | client c4 -connect ${h1_fe_sock} { |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 84 | txreq -url "/c4_client" |
Frédéric Lécaille | 4d78948 | 2019-03-18 14:08:46 +0100 | [diff] [blame] | 85 | expect_close |
| 86 | } -start |
| 87 | |
| 88 | haproxy h1 -start |
| 89 | delay 0.2 |
| 90 | haproxy h2 -start |
| 91 | delay 0.2 |
| 92 | haproxy h3 -start |
| 93 | delay 0.2 |
| 94 | |
| 95 | client c1 -wait |
| 96 | client c2 -wait |
| 97 | client c3 -wait |
| 98 | client c4 -wait |
| 99 | |
| 100 | delay 2 |
| 101 | |
| 102 | haproxy h1 -cli { |
| 103 | send "show table peers/stkt" |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 104 | 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 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] | 105 | } |
| 106 | |
| 107 | haproxy h2 -cli { |
| 108 | send "show table peers/stkt" |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 109 | 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 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] | 110 | } |
| 111 | |
| 112 | haproxy h3 -cli { |
| 113 | send "show table peers/stkt" |
Christopher Faulet | 1448d3a | 2019-10-14 16:10:52 +0200 | [diff] [blame] | 114 | 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 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] | 115 | } |
| 116 | |