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 | |
| 4 | haproxy h1 -arg "-L A" -conf { |
| 5 | defaults |
| 6 | timeout client 1s |
| 7 | timeout connect 1s |
| 8 | timeout server 1s |
| 9 | |
| 10 | |
| 11 | peers peers |
| 12 | bind "fd@${A}" |
| 13 | server A |
| 14 | server B ${h2_B_addr}:${h2_B_port} |
| 15 | server C ${h3_C_addr}:${h3_C_port} |
| 16 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 17 | |
| 18 | frontend fe |
| 19 | bind "fd@${fe}" |
| 20 | tcp-request content track-sc0 url table peers/stkt |
| 21 | tcp-request content sc-inc-gpc0(0) |
| 22 | } |
| 23 | |
| 24 | haproxy h2 -arg "-L B" -conf { |
| 25 | defaults |
| 26 | timeout client 1s |
| 27 | timeout connect 1s |
| 28 | timeout server 1s |
| 29 | |
| 30 | peers peers |
| 31 | bind "fd@${B}" |
| 32 | server A ${h1_A_addr}:${h1_A_port} |
| 33 | server B |
| 34 | server C ${h3_C_addr}:${h3_C_port} |
| 35 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 36 | |
| 37 | frontend fe |
| 38 | bind "fd@${fe}" |
| 39 | http-request track-sc0 url table peers/stkt |
| 40 | http-request sc-inc-gpc0(0) |
| 41 | } |
| 42 | |
| 43 | haproxy h3 -arg "-L C" -conf { |
| 44 | defaults |
| 45 | timeout client 1s |
| 46 | timeout connect 1s |
| 47 | timeout server 1s |
| 48 | |
| 49 | peers peers |
| 50 | bind "fd@${C}" |
| 51 | server A ${h1_A_addr}:${h1_A_port} |
| 52 | server B ${h2_B_addr}:${h2_B_port} |
| 53 | server C |
| 54 | table stkt type string size 10m store server_id,gpc0,conn_cur,conn_rate(50000) |
| 55 | |
| 56 | frontend fe |
| 57 | bind "fd@${fe}" |
| 58 | http-request track-sc0 url table peers/stkt |
| 59 | http-request sc-inc-gpc0(0) |
| 60 | } |
| 61 | |
| 62 | client c1 -connect ${h1_fe_sock} { |
| 63 | txreq -url "c1_client" |
| 64 | expect_close |
| 65 | } -start |
| 66 | |
| 67 | client c2 -connect ${h1_fe_sock} { |
| 68 | txreq -url "c2_client" |
| 69 | expect_close |
| 70 | } -start |
| 71 | |
| 72 | client c3 -connect ${h1_fe_sock} { |
| 73 | txreq -url "c3_client" |
| 74 | expect_close |
| 75 | } -start |
| 76 | |
| 77 | client c4 -connect ${h1_fe_sock} { |
| 78 | txreq -url "c4_client" |
| 79 | expect_close |
| 80 | } -start |
| 81 | |
| 82 | haproxy h1 -start |
| 83 | delay 0.2 |
| 84 | haproxy h2 -start |
| 85 | delay 0.2 |
| 86 | haproxy h3 -start |
| 87 | delay 0.2 |
| 88 | |
| 89 | client c1 -wait |
| 90 | client c2 -wait |
| 91 | client c3 -wait |
| 92 | client c4 -wait |
| 93 | |
| 94 | delay 2 |
| 95 | |
| 96 | haproxy h1 -cli { |
| 97 | send "show table peers/stkt" |
| 98 | 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}" |
| 99 | } |
| 100 | |
| 101 | haproxy h2 -cli { |
| 102 | send "show table peers/stkt" |
| 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 server_id=0 gpc0=1 conn_rate\\(50000\\)=1 conn_cur=0){4}" |
| 104 | } |
| 105 | |
| 106 | haproxy h3 -cli { |
| 107 | send "show table peers/stkt" |
| 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 server_id=0 gpc0=1 conn_rate\\(50000\\)=1 conn_cur=0){4}" |
| 109 | } |
| 110 | |