blob: 670eaac1a21c48aadc51c50abee826c1e0e8baad [file] [log] [blame]
Amaury Denoyelle65273ab2021-03-12 10:45:12 +01001varnishtest "Add server via cli"
2
3feature ignore_unknown_macro
4
5#REQUIRE_VERSION=2.4
6
7server s1 {
8 rxreq
9 txresp
10} -start
11
12haproxy h1 -conf {
13 defaults
14 mode http
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010015 timeout connect 1s
16 timeout client 1s
17 timeout server 1s
18
19 frontend fe
20 bind "fd@${feS}"
21 default_backend test
22
23 backend test
24 balance random
25
26 backend other
27 balance static-rr
Amaury Denoyelle30467232021-03-12 18:03:27 +010028
29 backend other2
30 balance random
31 mode tcp
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010032} -start
33
34client c1 -connect ${h1_feS_sock} {
35 txreq
36 rxresp
37 expect resp.status == 503
38} -run
39
40haproxy h1 -cli {
41 # experimental mode disabled
42 send "add server foo/s1 ${s1_addr}:${s1_port}"
43 expect ~ "This command is restricted to experimental mode only."
44
45 # non existent backend
46 send "experimental-mode on; add server foo/s1 ${s1_addr}:${s1_port}"
47 expect ~ "No such backend."
48
49 # missing address
50 send "experimental-mode on; add server test/s1"
51 expect ~ "'server' expects <name> and <addr>\\[:<port>\\] as arguments."
52
53 # invalid load-balancing algo
54 send "experimental-mode on; add server other/s1 ${s1_addr}:${s1_port}"
Amaury Denoyelle996190a2021-04-29 15:35:46 +020055 expect ~ "Backend must use a dynamic load balancing to support dynamic servers."
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010056
Amaury Denoyelle30467232021-03-12 18:03:27 +010057 # invalid mux proto
58 send "experimental-mode on; add server other2/s1 ${s1_addr}:${s1_port} proto h2"
59 expect ~ "MUX protocol is not usable for server."
60
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010061 # valid command
62 send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
63 expect ~ "New server registered."
64
65 # duplicate server
66 send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
67 expect ~ "Already exists a server with the same name in backend."
Amaury Denoyelle30467232021-03-12 18:03:27 +010068
69 # valid command
70 # specify the proto, it should be accepted for this backend
71 send "experimental-mode on; add server test/s2 ${s1_addr}:${s1_port} proto h2"
72 expect ~ "New server registered."
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010073}
74
75# dynamic servers are created on MAINT mode and should not be available at first
76client c2 -connect ${h1_feS_sock} {
77 txreq
78 rxresp
79 expect resp.status == 503
80} -run
81
82haproxy h1 -cli {
Amaury Denoyelle318c0082021-03-22 11:43:03 +010083 send "enable server test/s1"
Amaury Denoyelle79e6d2a2021-03-22 11:44:12 +010084 expect ~ ".*"
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010085}
86
87client c3 -connect ${h1_feS_sock} {
88 txreq
89 rxresp
90 expect resp.status == 200
91} -run