blob: 061f2c1bba7549251a43198582bb78f46e52a619 [file] [log] [blame]
Christopher Fauletaec7f762020-04-22 15:16:58 +02001varnishtest "Health-checks: MySQL health-check"
2#REQUIRE_VERSION=2.2
3#REGTEST_TYPE=slow
4feature 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
11server s1 {
12 sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400"
13 expect_close
14} -start
15
16server s2 {
17 sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400"
18 recv 20
19 sendhex "03000002000000"
20} -start
21
22server s3 {
23 sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400"
24 recv 47
25 sendhex "0700000200000002000000"
26} -start
27
28server s4 {
29 sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400"
30 recv 21
31 sendhex "67000002FFE304436C69656E7420646F6573206E6F7420737570706F72742061757468656E7469636174696F6E2070726F746F636F6C20726571756573746564206279207365727665723B20636F6E736964657220757067726164696E67204D7953514C20636C69656E74"
32} -start
33
34server s5 {
35 sendhex "4A0000000A382E302E3139000A0000006F3C025E6249410D00FFFFFF0200FFC715000000000000000000007C182159106E2761144322200063616368696E675F736861325F70617373776F726400"
36 recv 48
37 sendhex "67000002FFE304436C69656E7420646F6573206E6F7420737570706F72742061757468656E7469636174696F6E2070726F746F636F6C20726571756573746564206279207365727665723B20636F6E736964657220757067726164696E67204D7953514C20636C69656E74"
38} -start
39
40syslog S1 -level notice {
41 recv
42 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
43 recv
44 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."
45} -start
46
47syslog S2 -level notice {
48 recv
49 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started."
50 recv
51 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."
52} -start
53
54syslog S3 -level notice {
55 recv
56 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be3 started."
57 recv
58 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."
59} -start
60
61syslog S4 -level notice {
62 recv
63 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be4 started."
64 recv
65 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."
66} -start
67
68syslog S5 -level notice {
69 recv
70 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be5 started."
71 recv
72 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."
73} -start
74
75
76haproxy h1 -conf {
77 defaults
78 mode tcp
79 timeout client 1s
80 timeout server 1s
81 timeout connect 100ms
82
83 backend be1
84 log ${S1_addr}:${S1_port} daemon
85 option log-health-checks
86 option mysql-check
87 server srv ${s1_addr}:${s1_port} check inter 1s rise 1 fall 1
88
89 backend be2
90 log ${S2_addr}:${S2_port} daemon
91 option log-health-checks
92 option mysql-check user user
93 server srv ${h1_mysql1_addr}:${h1_mysql1_port} check inter 1s rise 1 fall 1
94
95 backend be3
96 log ${S3_addr}:${S3_port} daemon
97 option log-health-checks
98 option mysql-check user user post-41
99 server srv ${h1_mysql2_addr}:${h1_mysql2_port} check inter 1s rise 1 fall 1
100
101 backend be4
102 log ${S4_addr}:${S4_port} daemon
103 option log-health-checks
104 option mysql-check user pouet
105 server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1
106
107 backend be5
108 log ${S5_addr}:${S5_port} daemon
109 option log-health-checks
110 option mysql-check user pouet post-41
111 server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1
112
113 listen mysql1
114 bind "fd@${mysql1}"
115 tcp-request inspect-delay 100ms
116 tcp-request content accept if { req.len eq 20 } { req.payload(0,20) -m bin "0B00000100800000017573657200000100000001" }
117 tcp-request content reject
118 server srv ${s2_addr}:${s2_port}
119
120 listen mysql2
121 bind "fd@${mysql2}"
122 tcp-request inspect-delay 100ms
123 tcp-request content accept if { req.len eq 47 } { req.payload(0,47) -m bin "2600000100820000008000012100000000000000000000000000000000000000000000007573657200000100000001" }
124 tcp-request content reject
125 server srv ${s3_addr}:${s3_port}
126
127} -start
128
129syslog S1 -wait
130syslog S2 -wait
131syslog S3 -wait
132syslog S4 -wait
133syslog S5 -wait