Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 1 | varnishtest "Add server via cli" |
| 2 | |
| 3 | feature ignore_unknown_macro |
| 4 | |
| 5 | #REQUIRE_VERSION=2.4 |
| 6 | |
| 7 | server s1 { |
| 8 | rxreq |
| 9 | txresp |
| 10 | } -start |
| 11 | |
| 12 | haproxy 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 Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 29 | |
| 30 | backend other2 |
| 31 | balance random |
| 32 | mode tcp |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 33 | } -start |
| 34 | |
| 35 | client c1 -connect ${h1_feS_sock} { |
| 36 | txreq |
| 37 | rxresp |
| 38 | expect resp.status == 503 |
| 39 | } -run |
| 40 | |
| 41 | haproxy 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 Denoyelle | 996190a | 2021-04-29 15:35:46 +0200 | [diff] [blame^] | 56 | expect ~ "Backend must use a dynamic load balancing to support dynamic servers." |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 57 | |
Amaury Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 58 | # 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 Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 62 | # 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 Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 69 | |
| 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 Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | # dynamic servers are created on MAINT mode and should not be available at first |
| 77 | client c2 -connect ${h1_feS_sock} { |
| 78 | txreq |
| 79 | rxresp |
| 80 | expect resp.status == 503 |
| 81 | } -run |
| 82 | |
| 83 | haproxy h1 -cli { |
Amaury Denoyelle | 318c008 | 2021-03-22 11:43:03 +0100 | [diff] [blame] | 84 | send "enable server test/s1" |
Amaury Denoyelle | 79e6d2a | 2021-03-22 11:44:12 +0100 | [diff] [blame] | 85 | expect ~ ".*" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | client c3 -connect ${h1_feS_sock} { |
| 89 | txreq |
| 90 | rxresp |
| 91 | expect resp.status == 200 |
| 92 | } -run |