blob: 61d241c2afb024ad408a003e3853b743d9aad3e6 [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 {
Amaury Denoyellee5580432021-04-15 14:41:20 +020030 # non existent backend
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010031 send "del server foo/s1"
Amaury Denoyellee5580432021-04-15 14:41:20 +020032 expect ~ "No such backend."
33
34 # non existent server
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010035 send "del server test/other"
Amaury Denoyellee5580432021-04-15 14:41:20 +020036 expect ~ "No such server."
37
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020038 # server referenced in ACL
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010039 send "del server test/s1"
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020040 expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it."
41
42 # tracked server
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010043 send "del server test/s2"
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
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010047 send "del server test/s3"
Amaury Denoyelle14c3c5c2021-08-23 14:10:51 +020048 expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it."
Amaury Denoyellee5580432021-04-15 14:41:20 +020049
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020050 # server in running mode
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010051 send "del server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020052 expect ~ "Only servers in maintenance mode can be deleted."
53
Amaury Denoyelle104b8e52021-08-25 16:24:23 +020054 send "disable server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020055 expect ~ ".*"
56
57 # valid command
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010058 send "del server test/s4"
Amaury Denoyellee5580432021-04-15 14:41:20 +020059 expect ~ "Server deleted."
60}