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