blob: 972151816c9995836c4f2ce6dcec98be01f18d0f [file] [log] [blame]
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +02001# This script is to test the ability to remove servers, unless they are
2# referenced by some elements from the configuration.
3#
Amaury Denoyellee5580432021-04-15 14:41:20 +02004varnishtest "Delete server via cli"
5
Tim Duesterhus7ba98482021-08-25 19:14:01 +02006feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
Amaury Denoyellee5580432021-04-15 14:41:20 +02007feature ignore_unknown_macro
8
Amaury Denoyellee5580432021-04-15 14:41:20 +02009haproxy h1 -conf {
10 defaults
11 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010012 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
13 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
14 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Amaury Denoyellee5580432021-04-15 14:41:20 +020015
16 frontend fe
17 bind "fd@${feS}"
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020018 acl s1_full srv_sess_rate(test/s1) gt 50
Amaury Denoyellee5580432021-04-15 14:41:20 +020019 default_backend test
20
21 backend test
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020022 use-server s3 unless { always_false }
23 server s1 ${s1_addr}:${s1_port} # referenced in ACL
24 server s2 ${s1_addr}:${s1_port} check # referenced in track
25 server s3 ${s1_addr}:${s1_port} track s2 # referenced in use-server
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020026 server s4 ${s1_addr}:${s1_port} # removable server
Amaury Denoyellee5580432021-04-15 14:41:20 +020027} -start
28
Amaury Denoyellee5580432021-04-15 14:41:20 +020029haproxy h1 -cli {
30 # experimental mode disabled
31 send "del server test/s1"
32 expect ~ "This command is restricted to experimental mode only."
33
34 # non existent backend
35 send "experimental-mode on; del server foo/s1"
36 expect ~ "No such backend."
37
38 # non existent server
39 send "experimental-mode on; del server test/other"
40 expect ~ "No such server."
41
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020042 # server referenced in ACL
Amaury Denoyellee5580432021-04-15 14:41:20 +020043 send "experimental-mode on; del server test/s1"
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020044 expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it."
45
46 # tracked server
47 send "experimental-mode on; del server test/s2"
48 expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it."
49
50 # tracked server
51 send "experimental-mode on; del server test/s3"
52 expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it."
Amaury Denoyellee5580432021-04-15 14:41:20 +020053
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020054 # server in running mode
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020055 send "experimental-mode on; del server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020056 expect ~ "Only servers in maintenance mode can be deleted."
57
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020058 send "disable server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020059 expect ~ ".*"
60
61 # valid command
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020062 send "experimental-mode on; del server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020063 expect ~ "Server deleted."
64}