Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 1 | # This script is to test the ability to remove servers, unless they are |
| 2 | # referenced by some elements from the configuration. |
| 3 | # |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 4 | varnishtest "Delete server via cli" |
| 5 | |
Tim Duesterhus | 7ba9848 | 2021-08-25 19:14:01 +0200 | [diff] [blame] | 6 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 7 | feature ignore_unknown_macro |
| 8 | |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 9 | haproxy h1 -conf { |
| 10 | defaults |
| 11 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 12 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 13 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 14 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 15 | |
| 16 | frontend fe |
| 17 | bind "fd@${feS}" |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 18 | acl s1_full srv_sess_rate(test/s1) gt 50 |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 19 | default_backend test |
| 20 | |
| 21 | backend test |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 22 | 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 Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 26 | server s4 ${s1_addr}:${s1_port} # removable server |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 27 | } -start |
| 28 | |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 29 | haproxy 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 Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 42 | # server referenced in ACL |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 43 | send "experimental-mode on; del server test/s1" |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 44 | 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 Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 53 | |
Amaury Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 54 | # server in running mode |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 55 | send "experimental-mode on; del server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 56 | expect ~ "Only servers in maintenance mode can be deleted." |
| 57 | |
Amaury Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 58 | send "disable server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 59 | expect ~ ".*" |
| 60 | |
| 61 | # valid command |
Amaury Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 62 | send "experimental-mode on; del server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 63 | expect ~ "Server deleted." |
| 64 | } |