summaryrefslogtreecommitdiffstats
path: root/reg-tests/checks/4be_1srv_health_checks.vtc
blob: 02564be54c1d46a6eb6d05483c4da5f25e2f593b (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
varnishtest "Health-check test"
feature ignore_unknown_macro

#REQUIRE_VERSION=2.4
#EXCLUDE_TARGETS=freebsd
#REGTEST_TYPE=slow

# This script test health-checks for four backends with one server by backend.
# A syslog server is attached to each backend to check the syslog messages
# in the right order.

# First, we check a health-check has passed for all the servers thanks to the syslog
# messages. Then each server is disabled. The health-check status are checked.
# Then each server is re-enabled. Finally health-check status
# verifications for each server terminate the execution of this script.

# Note that the CLI is synchronized with the syslog servers so that
# to be sure to receive the passed health-checks status messages before
# disabling the servers. Same thing, when we check that the servers are down
# before enabling the servers.

# Cyclic barrier to synchronize the CLI with the syslog servers
barrier b1 cond 5 -cyclic

# These servers are there only for the health-check test.
server s1 {
} -start

server s2 {
} -start

server s3 {
} -start

server s4 {
} -start

syslog S1 -level notice {
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP"
    barrier b1 sync
    recv alert
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be1/srv1 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
    recv emerg
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be1 has no server available!"
    barrier b1 sync
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be1/srv1 is UP/READY \\(leaving forced maintenance\\).|Health check for server be1/srv1 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP)"
    barrier b1 sync
} -start

syslog S2 -level notice {
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv2 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP"
    barrier b1 sync
    recv alert
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be2/srv2 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
    recv emerg
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be2 has no server available!"
    barrier b1 sync
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be2/srv2 is UP/READY \\(leaving forced maintenance\\).|Health check for server be2/srv2 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP)"
    barrier b1 sync
} -start

syslog S3 -level notice {
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv3 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP"
    barrier b1 sync
    recv alert
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be3/srv3 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
    recv emerg
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be3 has no server available!"
    barrier b1 sync
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be3/srv3 is UP/READY \\(leaving forced maintenance\\).|Health check for server be3/srv3 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP)"
    barrier b1 sync
} -start

syslog S4 -level notice {
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv4 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP"
    barrier b1 sync
    recv alert
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be4/srv4 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
    recv emerg
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be4 has no server available!"
    barrier b1 sync
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be4/srv4 is UP/READY \\(leaving forced maintenance\\).|Health check for server be4/srv4 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP)"
    barrier b1 sync
} -start


haproxy h1 -conf {
    defaults
        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
        default-server check inter 200ms downinter 100s rise 1 fall 1

    frontend fe1
        bind "fd@${fe1}"
        use_backend be1

    frontend fe2
        bind "fd@${fe2}"
        use_backend be2

    frontend fe3
        bind "fd@${fe3}"
        use_backend be3

    frontend fe4
        bind "fd@${fe4}"
        use_backend be4

    backend be1
        option log-health-checks
        log ${S1_addr}:${S1_port} daemon
        server srv1 ${s1_addr}:${s1_port}

    backend be2
        option log-health-checks
        log ${S2_addr}:${S2_port} daemon
        server srv2 ${s2_addr}:${s2_port}

    backend be3
        option log-health-checks
        log ${S3_addr}:${S3_port} daemon
        server srv3 ${s3_addr}:${s3_port}

    backend be4
        option log-health-checks
        log ${S4_addr}:${S4_port} daemon
        server srv4 ${s4_addr}:${s4_port}
} -start

haproxy h1 -cli {
    barrier b1 sync
    send "show servers state"
    expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s4_port} - 0 0 - - 0"
}

haproxy h1 -cli {
    send "disable server be1/srv1"
    expect ~ .*
}

haproxy h1 -cli {
    send "disable server be2/srv2"
    expect ~ .*
}

haproxy h1 -cli {
    send "disable server be3/srv3"
    expect ~ .*
}

haproxy h1 -cli {
    send "disable server be4/srv4"
    expect ~ .*
}

haproxy h1 -cli {
    barrier b1 sync
    send "show servers state"
    expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s4_port} - 0 0 - - 0"
}

haproxy h1 -cli {
    send "enable server be1/srv1"
    expect ~ .*
}

haproxy h1 -cli {
    send "enable server be2/srv2"
    expect ~ .*
}

haproxy h1 -cli {
    send "enable server be3/srv3"
    expect ~ .*
}

haproxy h1 -cli {
    send "enable server be4/srv4"
    expect ~ .*
}

haproxy h1 -cli {
    barrier b1 sync
    send "show servers state"
    expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s4_port} - 0 0 - - 0"
}

syslog S1 -wait
syslog S2 -wait
syslog S3 -wait
syslog S4 -wait