Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 1 | varnishtest "Add/Delete server via cli with check support" |
| 2 | |
| 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev3)'" |
| 4 | feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'" |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | barrier b1 cond 2 -cyclic |
| 8 | barrier b2 cond 2 -cyclic |
| 9 | |
| 10 | server s1 { |
Amaury Denoyelle | a026783 | 2021-08-06 15:34:04 +0200 | [diff] [blame] | 11 | rxreq |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 12 | txresp |
| 13 | } -start |
| 14 | |
| 15 | server s2 { |
| 16 | } -start |
| 17 | |
| 18 | # used for agent checks |
| 19 | server s3 { |
| 20 | recv 5 |
| 21 | send "ready up\n" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 22 | barrier b2 sync |
| 23 | } -start |
| 24 | |
| 25 | syslog S1 -level notice { |
| 26 | recv |
| 27 | expect ~ ".*Server be1/s1 is UP/READY \\(leaving forced maintenance\\)." |
| 28 | recv |
| 29 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s1 succeeded.+reason: Layer7 check passed, code: 200, check duration: [[:digit:]]+ms.+status: 1/1 UP" |
| 30 | |
| 31 | barrier b1 sync |
| 32 | |
| 33 | recv |
| 34 | expect ~ ".*Server be1/s2 is UP/READY \\(leaving forced maintenance\\)." |
| 35 | recv |
| 36 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s2 failed.+reason: Layer7 timeout, check duration: [[:digit:]]+ms.+status: 0/1 DOWN" |
| 37 | |
| 38 | barrier b1 sync |
| 39 | |
| 40 | recv |
| 41 | expect ~ ".*Server be1/s2 was DOWN and now enters maintenance." |
| 42 | |
| 43 | recv |
| 44 | expect ~ ".*Server be1/s3 is UP/READY \\(leaving forced maintenance\\)." |
| 45 | |
| 46 | recv |
| 47 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Agent check for server be1/s3 succeeded.+reason: Layer7 check passed, code: 0, info: \"via agent : up\", check duration: [[:digit:]]+ms.+status: 1/1 UP" |
| 48 | |
| 49 | barrier b1 sync |
| 50 | barrier b2 sync |
Amaury Denoyelle | 3881e17 | 2022-03-09 16:43:34 +0100 | [diff] [blame] | 51 | |
| 52 | recv |
| 53 | expect ~ ".*Server be1/s4 is UP/READY \\(leaving forced maintenance\\)." |
| 54 | recv |
| 55 | expect ~ "Health check for server be1/s4 failed" |
| 56 | |
| 57 | barrier b1 sync |
| 58 | |
| 59 | recv |
| 60 | expect ~ ".*Server be1/s5 is UP/READY \\(leaving forced maintenance\\)." |
| 61 | recv |
| 62 | expect ~ "Health check for server be1/s5 succeeded." |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 63 | } -start |
| 64 | |
| 65 | haproxy h1 -conf { |
| 66 | global |
| 67 | stats socket "${tmpdir}/h1/stats" level admin |
| 68 | |
| 69 | backend be1 |
| 70 | option log-health-checks |
| 71 | option httpchk GET / |
| 72 | log ${S1_addr}:${S1_port} daemon |
Amaury Denoyelle | 3881e17 | 2022-03-09 16:43:34 +0100 | [diff] [blame] | 73 | |
| 74 | frontend fe-proxy |
| 75 | mode http |
| 76 | bind "fd@${hapsrv}" accept-proxy |
| 77 | http-request return status 200 |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 78 | } -start |
| 79 | |
| 80 | # check on a functional server |
| 81 | haproxy h1 -cli { |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 82 | send "add server be1/s1 ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 83 | expect ~ "New server registered." |
| 84 | |
| 85 | send "enable server be1/s1" |
| 86 | expect ~ ".*" |
| 87 | send "enable health be1/s1" |
| 88 | expect ~ ".*" |
| 89 | |
| 90 | barrier b1 sync |
| 91 | |
| 92 | send "disable server be1/s1" |
| 93 | expect ~ ".*" |
| 94 | |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 95 | send "del server be1/s1" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 96 | expect ~ "Server deleted." |
| 97 | } |
| 98 | |
| 99 | server s2 -break |
| 100 | |
| 101 | # check on a disabled server |
| 102 | haproxy h1 -cli { |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 103 | send "add server be1/s2 ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 104 | expect ~ "New server registered." |
| 105 | |
| 106 | send "enable server be1/s2" |
| 107 | expect ~ ".*" |
| 108 | send "enable health be1/s2" |
| 109 | expect ~ ".*" |
| 110 | |
| 111 | barrier b1 sync |
| 112 | |
| 113 | send "disable server be1/s2" |
| 114 | expect ~ ".*" |
| 115 | |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 116 | send "del server be1/s2" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 117 | expect ~ "Server deleted." |
| 118 | } |
| 119 | |
| 120 | # agent check |
| 121 | haproxy h1 -cli { |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 122 | send "add server be1/s3 ${s1_addr}:${s1_port} agent-check agent-addr ${s3_addr} agent-port ${s3_port} agent-send 'hello' agent-inter 200ms rise 1 fall 1" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 123 | expect ~ "New server registered." |
| 124 | |
| 125 | send "enable agent be1/s3" |
| 126 | expect ~ ".*" |
| 127 | |
| 128 | barrier b1 sync |
| 129 | |
| 130 | send "disable agent be1/s3; disable server be1/s3" |
| 131 | expect ~ ".*" |
| 132 | |
Amaury Denoyelle | 76e8b70 | 2022-03-09 15:07:31 +0100 | [diff] [blame] | 133 | send "del server be1/s3" |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 134 | expect ~ "Server deleted." |
| 135 | } |
| 136 | |
Amaury Denoyelle | 3881e17 | 2022-03-09 16:43:34 +0100 | [diff] [blame] | 137 | # check PROXY protocol interaction with checks |
| 138 | haproxy h1 -cli { |
| 139 | # no explicit check-send-proxy |
| 140 | # The health check should failed. |
| 141 | send "add server be1/s4 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1" |
| 142 | expect ~ "New server registered." |
| 143 | |
| 144 | send "enable server be1/s4" |
| 145 | expect ~ ".*" |
| 146 | send "enable health be1/s4" |
| 147 | expect ~ ".*" |
| 148 | |
| 149 | barrier b1 sync |
| 150 | |
| 151 | # explicit check-send-proxy : health check should succeeded |
| 152 | send "add server be1/s5 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1 check-send-proxy" |
| 153 | expect ~ "New server registered." |
| 154 | |
| 155 | send "enable server be1/s5" |
| 156 | expect ~ ".*" |
| 157 | send "enable health be1/s5" |
| 158 | expect ~ ".*" |
| 159 | } |
| 160 | |
Amaury Denoyelle | 3e7d468 | 2021-07-29 17:34:16 +0200 | [diff] [blame] | 161 | syslog S1 -wait |