blob: 8bb4cd2e62fd134e32ccf1efefed444f722cc34d [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
15 ${no-htx} option http-use-htx
16 timeout connect 1s
17 timeout client 1s
18 timeout server 1s
19
20 frontend fe
21 bind "fd@${feS}"
22 default_backend test
23
24 backend test
25 balance random
26
27 backend other
28 balance static-rr
Amaury Denoyelle30467232021-03-12 18:03:27 +010029
30 backend other2
31 balance random
32 mode tcp
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010033} -start
34
35client c1 -connect ${h1_feS_sock} {
36 txreq
37 rxresp
38 expect resp.status == 503
39} -run
40
41haproxy h1 -cli {
42 # experimental mode disabled
43 send "add server foo/s1 ${s1_addr}:${s1_port}"
44 expect ~ "This command is restricted to experimental mode only."
45
46 # non existent backend
47 send "experimental-mode on; add server foo/s1 ${s1_addr}:${s1_port}"
48 expect ~ "No such backend."
49
50 # missing address
51 send "experimental-mode on; add server test/s1"
52 expect ~ "'server' expects <name> and <addr>\\[:<port>\\] as arguments."
53
54 # invalid load-balancing algo
55 send "experimental-mode on; add server other/s1 ${s1_addr}:${s1_port}"
Amaury Denoyelle996190a2021-04-29 15:35:46 +020056 expect ~ "Backend must use a dynamic load balancing to support dynamic servers."
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010057
Amaury Denoyelle30467232021-03-12 18:03:27 +010058 # invalid mux proto
59 send "experimental-mode on; add server other2/s1 ${s1_addr}:${s1_port} proto h2"
60 expect ~ "MUX protocol is not usable for server."
61
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010062 # valid command
63 send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
64 expect ~ "New server registered."
65
66 # duplicate server
67 send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
68 expect ~ "Already exists a server with the same name in backend."
Amaury Denoyelle30467232021-03-12 18:03:27 +010069
70 # valid command
71 # specify the proto, it should be accepted for this backend
72 send "experimental-mode on; add server test/s2 ${s1_addr}:${s1_port} proto h2"
73 expect ~ "New server registered."
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010074}
75
76# dynamic servers are created on MAINT mode and should not be available at first
77client c2 -connect ${h1_feS_sock} {
78 txreq
79 rxresp
80 expect resp.status == 503
81} -run
82
83haproxy h1 -cli {
Amaury Denoyelle318c0082021-03-22 11:43:03 +010084 send "enable server test/s1"
Amaury Denoyelle79e6d2a2021-03-22 11:44:12 +010085 expect ~ ".*"
Amaury Denoyelle65273ab2021-03-12 10:45:12 +010086}
87
88client c3 -connect ${h1_feS_sock} {
89 txreq
90 rxresp
91 expect resp.status == 200
92} -run