Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: MySQL health-check" |
| 2 | #REQUIRE_VERSION=2.2 |
| 3 | #REGTEST_TYPE=slow |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This scripts tests health-checks for MySQL application, enabled using |
| 7 | # "option mysql-check" line. A intermediate listener is used to validate |
| 8 | # the request because it is impossible with VTEST to read and match raw |
| 9 | # text. |
| 10 | |
| 11 | server s1 { |
| 12 | sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400" |
| 13 | expect_close |
| 14 | } -start |
| 15 | |
| 16 | server s2 { |
| 17 | sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400" |
| 18 | recv 20 |
| 19 | sendhex "03000002000000" |
| 20 | } -start |
| 21 | |
| 22 | server s3 { |
| 23 | sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400" |
| 24 | recv 47 |
| 25 | sendhex "0700000200000002000000" |
| 26 | } -start |
| 27 | |
| 28 | server s4 { |
| 29 | sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400" |
| 30 | recv 21 |
| 31 | sendhex "67000002FFE304436C69656E7420646F6573206E6F7420737570706F72742061757468656E7469636174696F6E2070726F746F636F6C20726571756573746564206279207365727665723B20636F6E736964657220757067726164696E67204D7953514C20636C69656E74" |
| 32 | } -start |
| 33 | |
| 34 | server s5 { |
| 35 | sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400" |
| 36 | recv 48 |
| 37 | sendhex "67000002FFE304436C69656E7420646F6573206E6F7420737570706F72742061757468656E7469636174696F6E2070726F746F636F6C20726571756573746564206279207365727665723B20636F6E736964657220757067726164696E67204D7953514C20636C69656E74" |
| 38 | } -start |
| 39 | |
| 40 | syslog S1 -level notice { |
| 41 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 42 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"8.0.19\".+check duration: [[:digit:]]+ms, status: 1/1 UP." |
| 43 | } -start |
| 44 | |
| 45 | syslog S2 -level notice { |
| 46 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 47 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded, reason: Layer7 check passed.+info: \"8.0.19\".+check duration: [[:digit:]]+ms, status: 1/1 UP." |
| 48 | } -start |
| 49 | |
| 50 | syslog S3 -level notice { |
| 51 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 52 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded, reason: Layer7 check passed.+info: \"8.0.19\".+check duration: [[:digit:]]+ms, status: 1/1 UP." |
| 53 | } -start |
| 54 | |
| 55 | syslog S4 -level notice { |
| 56 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 57 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv failed, reason: Layer7 wrong status.+code: 1251.+info: \"Client does not support authentication protocol requested by server; consider upgrading MySQL client\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." |
| 58 | } -start |
| 59 | |
| 60 | syslog S5 -level notice { |
| 61 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 62 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv failed, reason: Layer7 wrong status.+code: 1251.+info: \"Client does not support authentication protocol requested by server; consider upgrading MySQL client\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." |
| 63 | } -start |
| 64 | |
| 65 | |
| 66 | haproxy h1 -conf { |
| 67 | defaults |
| 68 | mode tcp |
| 69 | timeout client 1s |
| 70 | timeout server 1s |
| 71 | timeout connect 100ms |
| 72 | |
| 73 | backend be1 |
| 74 | log ${S1_addr}:${S1_port} daemon |
| 75 | option log-health-checks |
| 76 | option mysql-check |
| 77 | server srv ${s1_addr}:${s1_port} check inter 1s rise 1 fall 1 |
| 78 | |
| 79 | backend be2 |
| 80 | log ${S2_addr}:${S2_port} daemon |
| 81 | option log-health-checks |
Christopher Faulet | 62f79fe | 2020-05-18 18:13:03 +0200 | [diff] [blame] | 82 | option mysql-check user user pre-41 |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 83 | server srv ${h1_mysql1_addr}:${h1_mysql1_port} check inter 1s rise 1 fall 1 |
| 84 | |
| 85 | backend be3 |
| 86 | log ${S3_addr}:${S3_port} daemon |
| 87 | option log-health-checks |
Christopher Faulet | 62f79fe | 2020-05-18 18:13:03 +0200 | [diff] [blame] | 88 | option mysql-check user user |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 89 | server srv ${h1_mysql2_addr}:${h1_mysql2_port} check inter 1s rise 1 fall 1 |
| 90 | |
| 91 | backend be4 |
| 92 | log ${S4_addr}:${S4_port} daemon |
| 93 | option log-health-checks |
| 94 | option mysql-check user pouet |
| 95 | server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1 |
| 96 | |
| 97 | backend be5 |
| 98 | log ${S5_addr}:${S5_port} daemon |
| 99 | option log-health-checks |
| 100 | option mysql-check user pouet post-41 |
| 101 | server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1 |
| 102 | |
| 103 | listen mysql1 |
| 104 | bind "fd@${mysql1}" |
| 105 | tcp-request inspect-delay 100ms |
| 106 | tcp-request content accept if { req.len eq 20 } { req.payload(0,20) -m bin "0B00000100800000017573657200000100000001" } |
| 107 | tcp-request content reject |
| 108 | server srv ${s2_addr}:${s2_port} |
| 109 | |
| 110 | listen mysql2 |
| 111 | bind "fd@${mysql2}" |
| 112 | tcp-request inspect-delay 100ms |
| 113 | tcp-request content accept if { req.len eq 47 } { req.payload(0,47) -m bin "2600000100820000008000012100000000000000000000000000000000000000000000007573657200000100000001" } |
| 114 | tcp-request content reject |
| 115 | server srv ${s3_addr}:${s3_port} |
| 116 | |
| 117 | } -start |
| 118 | |
| 119 | syslog S1 -wait |
| 120 | syslog S2 -wait |
| 121 | syslog S3 -wait |
| 122 | syslog S4 -wait |
| 123 | syslog S5 -wait |