summaryrefslogtreecommitdiffstats
path: root/reg-tests/server/cli_add_track_server.vtc
blob: 318f236aa5b5586f61412a550c0c2a6edd2b3d42 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
varnishtest "Add/Delete server via cli with track support"

feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'"
feature ignore_unknown_macro


# just use to provide s1_{addr,port} macros
server s1 {
}


# scenario 1
# -> 3 dynamic servers, delete the first one
syslog S1 {
	recv notice
	expect ~ "Server be1/s1 is UP/READY"
	recv notice
	expect ~ "Server be1/s2 is UP/READY"
	recv notice
	expect ~ "Server be1/s3 is UP/READY"

	recv alert
	expect ~ "Server be1/srv is going DOWN for maintenance."
	recv alert
	expect ~ "Server be1/s3 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be1/s2 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be1/s1 is going DOWN for maintenance."

	recv notice
	expect ~ "Server be1/srv is UP/READY"
	recv notice
	expect ~ "Server be1/s3 is UP/READY"
	recv notice
	expect ~ "Server be1/s2 is UP/READY"
} -start

# scenario 2
# -> 3 dynamic servers, delete the middle one
syslog S2 {
	recv notice
	expect ~ "Server be2/s1 is UP/READY"
	recv notice
	expect ~ "Server be2/s2 is UP/READY"
	recv notice
	expect ~ "Server be2/s3 is UP/READY"

	recv alert
	expect ~ "Server be2/srv is going DOWN for maintenance."
	recv alert
	expect ~ "Server be2/s3 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be2/s2 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be2/s1 is going DOWN for maintenance."

	recv notice
	expect ~ "Server be2/srv is UP/READY"
	recv notice
	expect ~ "Server be2/s3 is UP/READY"
	recv notice
	expect ~ "Server be2/s1 is UP/READY"
} -start

# scenario 3
# -> 3 dynamic servers, delete all of them
syslog S3 {
	recv notice
	expect ~ "Server be3/s1 is UP/READY"
	recv notice
	expect ~ "Server be3/s2 is UP/READY"
	recv notice
	expect ~ "Server be3/s3 is UP/READY"

	recv alert
	expect ~ "Server be3/s1 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be3/s3 is going DOWN for maintenance."
	recv alert
	expect ~ "Server be3/s2 is going DOWN for maintenance."

	recv alert
	expect ~ "Server be3/srv is going DOWN for maintenance."

	recv notice
	expect ~ "Server be3/srv is UP/READY"
} -start


haproxy h1 -conf {
	global
		stats socket "${tmpdir}/h1/stats" level admin

	backend be_check
		server srv_check ${s1_addr}:${s1_port} check
		server srv_no_check ${s1_addr}:${s1_port}

	backend be1
		log ${S1_addr}:${S1_port} daemon
		server srv ${s1_addr}:${s1_port} check

	backend be2
		log ${S2_addr}:${S2_port} daemon
		server srv ${s1_addr}:${s1_port} check

	backend be3
		log ${S3_addr}:${S3_port} daemon
		server srv ${s1_addr}:${s1_port} check
} -start


###
# check the support of the 'track' keyword on 'add server' CLI command.
# rejection must happen if track on a non-checked or a dynamic server
###
haproxy h1 -cli {
	# invalid command: track on a non-checked server
	send "add server be_check/s1 ${s1_addr}:${s1_port} track be_check/srv_no_check"
	expect ~ "unable to use be_check/srv_no_check for tracking as it does not have any check nor agent enabled."

	# valid track usage
	send "add server be_check/s1 ${s1_addr}:${s1_port} track be_check/srv_check"
	expect ~ "New server registered."

	# invalid command: track on a dynamic server
	send "add server be_check/s3 ${s1_addr}:${s1_port} track be_check/s1"
	expect ~ "unable to use be_check/s1 for tracking as it is a dynamic server."
}

###
# scenario 1
#
# Add 3 dynamic servers with tracking on be1/srv
# Disable be1/srv, S1 should report all servers DOWN
# Delete the first dynamic server, enable be1/srv, S1 should report s1 and s3 UP
####
haproxy h1 -cli {
	send "add server be1/s1 ${s1_addr}:${s1_port} track be1/srv"
	expect ~ "New server registered."
	send "enable server be1/s1"
	expect ~ ".*"

	send "add server be1/s2 ${s1_addr}:${s1_port} track be1/srv"
	expect ~ "New server registered."
	send "enable server be1/s2"
	expect ~ ".*"

	send "add server be1/s3 ${s1_addr}:${s1_port} track be1/srv"
	expect ~ "New server registered."
	send "enable server be1/s3"
	expect ~ ".*"

	send "disable server be1/srv"
	expect ~ ".*"

	send "del server be1/s1"
	expect ~ "Server deleted."

	send "enable server be1/srv"
	expect ~ ".*"
}

###
# scenario 2
#
# Add 3 dynamic servers with tracking on be2/srv
# Disable be2/srv, S3 should report all servers DOWN
# Delete the second dynamic server, enable be2/srv, S2 should report s2 and s3 UP
####
haproxy h1 -cli {
	send "add server be2/s1 ${s1_addr}:${s1_port} track be2/srv"
	expect ~ "New server registered."
	send "enable server be2/s1"
	expect ~ ".*"

	send "add server be2/s2 ${s1_addr}:${s1_port} track be2/srv"
	expect ~ "New server registered."
	send "enable server be2/s2"
	expect ~ ".*"

	send "add server be2/s3 ${s1_addr}:${s1_port} track be2/srv"
	expect ~ "New server registered."
	send "enable server be2/s3"
	expect ~ ".*"

	send "disable server be2/srv"
	expect ~ ".*"

	send "del server be2/s2"
	expect ~ "Server deleted."

	send "enable server be2/srv"
	expect ~ ".*"
}

###
# scenario 3
#
# Add 3 dynamic servers with tracking on be3/srv
# Delete all of them, disable/enable be3/srv, only be3/srv should be reported
# as DOWN/UP.
####
haproxy h1 -cli {
	# create server 1, track on be3/srv
	send "add server be3/s1 ${s1_addr}:${s1_port} track be3/srv"
	expect ~ "New server registered."
	send "enable server be3/s1"
	expect ~ ".*"

	# create server 2, track on be3/srv
	send "add server be3/s2 ${s1_addr}:${s1_port} track be3/srv"
	expect ~ "New server registered."
	send "enable server be3/s2"
	expect ~ ".*"

	# create server 3, track on be3/srv
	send "add server be3/s3 ${s1_addr}:${s1_port} track be3/srv"
	expect ~ "New server registered."
	send "enable server be3/s3"
	expect ~ ".*"

	# delete all dynamic servers
	send "disable server be3/s1; del server be3/s1"
	expect ~ "Server deleted."
	send "disable server be3/s3; del server be3/s3"
	expect ~ "Server deleted."
	send "disable server be3/s2; del server be3/s2"
	expect ~ "Server deleted."

	# disable / enable the static server
	send "disable server be3/srv"
	expect ~ ".*"
	send "enable server be3/srv"
	expect ~ ".*"
}


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