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 { |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 30 | # non existent backend |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 31 | send "del server foo/s1" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 32 | expect ~ "No such backend." |
| 33 | |
| 34 | # non existent server |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 35 | send "del server test/other" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 36 | expect ~ "No such server." |
| 37 | |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 38 | # server referenced in ACL |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 39 | send "del server test/s1" |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 40 | expect ~ "This server cannot be removed at runtime due to other configuration elements pointing to it." |
| 41 | |
| 42 | # tracked server |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 43 | send "del server test/s2" |
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 |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 47 | send "del server test/s3" |
Amaury Denoyelle | 14c3c5c | 2021-08-23 14:10:51 +0200 | [diff] [blame] | 48 | 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] | 49 | |
Amaury Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 50 | # server in running mode |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 51 | send "del server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 52 | expect ~ "Only servers in maintenance mode can be deleted." |
| 53 | |
Amaury Denoyelle | 104b8e5 | 2021-08-25 16:24:23 +0200 | [diff] [blame] | 54 | send "disable server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 55 | expect ~ ".*" |
| 56 | |
| 57 | # valid command |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 58 | send "del server test/s4" |
Amaury Denoyelle | e558043 | 2021-04-15 14:41:20 +0200 | [diff] [blame] | 59 | expect ~ "Server deleted." |
| 60 | } |