blob: 7b92d71462f9c74a38f5b0062491117ad0403ed8 [file] [log] [blame]
Amaury Denoyellee5580432021-04-15 14:41:20 +02001varnishtest "Delete server via cli"
2
3feature ignore_unknown_macro
4
5#REQUIRE_VERSION=2.4
6
7# static server
8server s1 -repeat 3 {
9 rxreq
10 txresp \
11 -body "resp from s1"
12} -start
13
14# use as a dynamic server, added then deleted via CLI
15server s2 -repeat 3 {
16 rxreq
17 txresp \
18 -body "resp from s2"
19} -start
20
21haproxy h1 -conf {
22 defaults
23 mode http
Amaury Denoyellee5580432021-04-15 14:41:20 +020024 timeout connect 1s
25 timeout client 1s
26 timeout server 1s
27
28 frontend fe
29 bind "fd@${feS}"
30 default_backend test
31
32 backend test
33 server s1 ${s1_addr}:${s1_port}
34} -start
35
36# add a new dynamic server to be able to delete it then
37haproxy h1 -cli {
38 # add a dynamic server and enable it
39 send "experimental-mode on; add server test/s2 ${s2_addr}:${s2_port}"
40 expect ~ "New server registered."
41
42 send "enable server test/s2"
43 expect ~ ".*"
44}
45
46haproxy h1 -cli {
47 # experimental mode disabled
48 send "del server test/s1"
49 expect ~ "This command is restricted to experimental mode only."
50
51 # non existent backend
52 send "experimental-mode on; del server foo/s1"
53 expect ~ "No such backend."
54
55 # non existent server
56 send "experimental-mode on; del server test/other"
57 expect ~ "No such server."
58
59 # static server
60 send "experimental-mode on; del server test/s1"
61 expect ~ "Only servers added at runtime via <add server> CLI cmd can be deleted."
62}
63
64# first check that both servers are active
65client c1 -connect ${h1_feS_sock} {
66 txreq
67 rxresp
68 expect resp.body == "resp from s1"
69
70 txreq
71 rxresp
72 expect resp.body == "resp from s2"
73} -run
74
75# delete the dynamic server
76haproxy h1 -cli {
77 # server not in maintenance mode
78 send "experimental-mode on; del server test/s2"
79 expect ~ "Only servers in maintenance mode can be deleted."
80
81 send "disable server test/s2"
82 expect ~ ".*"
83
84 # valid command
85 send "experimental-mode on; del server test/s2"
86 expect ~ "Server deleted."
87}
88
89# now check that only the first server is used
90client c2 -connect ${h1_feS_sock} {
91 txreq
92 rxresp
93 expect resp.body == "resp from s1"
94
95 txreq
96 rxresp
97 expect resp.body == "resp from s1"
98} -run
99