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