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