2021-03-12 09:45:12 +00:00
|
|
|
varnishtest "Add server via cli"
|
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
#REQUIRE_VERSION=2.4
|
|
|
|
|
|
|
|
server s1 {
|
|
|
|
rxreq
|
|
|
|
txresp
|
|
|
|
} -start
|
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
defaults
|
|
|
|
mode http
|
|
|
|
timeout connect 1s
|
|
|
|
timeout client 1s
|
|
|
|
timeout server 1s
|
|
|
|
|
|
|
|
frontend fe
|
|
|
|
bind "fd@${feS}"
|
|
|
|
default_backend test
|
|
|
|
|
|
|
|
backend test
|
|
|
|
balance random
|
|
|
|
|
|
|
|
backend other
|
|
|
|
balance static-rr
|
2021-03-12 17:03:27 +00:00
|
|
|
|
|
|
|
backend other2
|
|
|
|
balance random
|
|
|
|
mode tcp
|
2021-03-12 09:45:12 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
client c1 -connect ${h1_feS_sock} {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 503
|
|
|
|
} -run
|
|
|
|
|
|
|
|
haproxy h1 -cli {
|
|
|
|
# experimental mode disabled
|
|
|
|
send "add server foo/s1 ${s1_addr}:${s1_port}"
|
|
|
|
expect ~ "This command is restricted to experimental mode only."
|
|
|
|
|
|
|
|
# non existent backend
|
|
|
|
send "experimental-mode on; add server foo/s1 ${s1_addr}:${s1_port}"
|
|
|
|
expect ~ "No such backend."
|
|
|
|
|
|
|
|
# missing address
|
|
|
|
send "experimental-mode on; add server test/s1"
|
|
|
|
expect ~ "'server' expects <name> and <addr>\\[:<port>\\] as arguments."
|
|
|
|
|
|
|
|
# invalid load-balancing algo
|
|
|
|
send "experimental-mode on; add server other/s1 ${s1_addr}:${s1_port}"
|
2021-04-29 13:35:46 +00:00
|
|
|
expect ~ "Backend must use a dynamic load balancing to support dynamic servers."
|
2021-03-12 09:45:12 +00:00
|
|
|
|
2021-03-12 17:03:27 +00:00
|
|
|
# invalid mux proto
|
|
|
|
send "experimental-mode on; add server other2/s1 ${s1_addr}:${s1_port} proto h2"
|
|
|
|
expect ~ "MUX protocol is not usable for server."
|
|
|
|
|
2021-03-12 09:45:12 +00:00
|
|
|
# valid command
|
|
|
|
send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
|
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
# duplicate server
|
|
|
|
send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
|
|
|
|
expect ~ "Already exists a server with the same name in backend."
|
2021-03-12 17:03:27 +00:00
|
|
|
|
|
|
|
# valid command
|
|
|
|
# specify the proto, it should be accepted for this backend
|
|
|
|
send "experimental-mode on; add server test/s2 ${s1_addr}:${s1_port} proto h2"
|
|
|
|
expect ~ "New server registered."
|
2021-03-12 09:45:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# dynamic servers are created on MAINT mode and should not be available at first
|
|
|
|
client c2 -connect ${h1_feS_sock} {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 503
|
|
|
|
} -run
|
|
|
|
|
|
|
|
haproxy h1 -cli {
|
2021-03-22 10:43:03 +00:00
|
|
|
send "enable server test/s1"
|
2021-03-22 10:44:12 +00:00
|
|
|
expect ~ ".*"
|
2021-03-12 09:45:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
client c3 -connect ${h1_feS_sock} {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
} -run
|