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 |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 15 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 16 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 17 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 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 { |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 41 | # non existent backend |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 42 | send "add server foo/s1 ${s1_addr}:${s1_port}" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 43 | expect ~ "No such backend." |
| 44 | |
| 45 | # missing address |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 46 | send "add server test/s1" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 47 | expect ~ "'server' expects <name> and <addr>\\[:<port>\\] as arguments." |
| 48 | |
| 49 | # invalid load-balancing algo |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 50 | send "add server other/s1 ${s1_addr}:${s1_port}" |
Amaury Denoyelle | 996190a | 2021-04-29 15:35:46 +0200 | [diff] [blame] | 51 | expect ~ "Backend must use a dynamic load balancing to support dynamic servers." |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 52 | |
Amaury Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 53 | # invalid mux proto |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 54 | send "add server other2/s1 ${s1_addr}:${s1_port} proto h2" |
Amaury Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 55 | expect ~ "MUX protocol is not usable for server." |
| 56 | |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 57 | # valid command |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 58 | send "add server test/s1 ${s1_addr}:${s1_port}" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 59 | expect ~ "New server registered." |
| 60 | |
| 61 | # duplicate server |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 62 | send "add server test/s1 ${s1_addr}:${s1_port}" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 63 | expect ~ "Already exists a server with the same name in backend." |
Amaury Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 64 | |
| 65 | # valid command |
| 66 | # specify the proto, it should be accepted for this backend |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 67 | send "add server test/s2 ${s1_addr}:${s1_port} proto h2" |
Amaury Denoyelle | 3046723 | 2021-03-12 18:03:27 +0100 | [diff] [blame] | 68 | expect ~ "New server registered." |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | # dynamic servers are created on MAINT mode and should not be available at first |
| 72 | client c2 -connect ${h1_feS_sock} { |
| 73 | txreq |
| 74 | rxresp |
| 75 | expect resp.status == 503 |
| 76 | } -run |
| 77 | |
| 78 | haproxy h1 -cli { |
Amaury Denoyelle | 318c008 | 2021-03-22 11:43:03 +0100 | [diff] [blame] | 79 | send "enable server test/s1" |
Amaury Denoyelle | 79e6d2a | 2021-03-22 11:44:12 +0100 | [diff] [blame] | 80 | expect ~ ".*" |
Amaury Denoyelle | 65273ab | 2021-03-12 10:45:12 +0100 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | client c3 -connect ${h1_feS_sock} { |
| 84 | txreq |
| 85 | rxresp |
| 86 | expect resp.status == 200 |
| 87 | } -run |