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 |
| 51 | } -start |
| 52 | |
| 53 | haproxy h1 -conf { |
| 54 | global |
| 55 | stats socket "${tmpdir}/h1/stats" level admin |
| 56 | |
| 57 | backend be1 |
| 58 | option log-health-checks |
| 59 | option httpchk GET / |
| 60 | log ${S1_addr}:${S1_port} daemon |
| 61 | } -start |
| 62 | |
| 63 | # check on a functional server |
| 64 | haproxy h1 -cli { |
| 65 | send "experimental-mode on; add server be1/s1 ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1" |
| 66 | expect ~ "New server registered." |
| 67 | |
| 68 | send "enable server be1/s1" |
| 69 | expect ~ ".*" |
| 70 | send "enable health be1/s1" |
| 71 | expect ~ ".*" |
| 72 | |
| 73 | barrier b1 sync |
| 74 | |
| 75 | send "disable server be1/s1" |
| 76 | expect ~ ".*" |
| 77 | |
| 78 | send "experimental-mode on; del server be1/s1" |
| 79 | expect ~ "Server deleted." |
| 80 | } |
| 81 | |
| 82 | server s2 -break |
| 83 | |
| 84 | # check on a disabled server |
| 85 | haproxy h1 -cli { |
| 86 | send "experimental-mode on; add server be1/s2 ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1" |
| 87 | expect ~ "New server registered." |
| 88 | |
| 89 | send "enable server be1/s2" |
| 90 | expect ~ ".*" |
| 91 | send "enable health be1/s2" |
| 92 | expect ~ ".*" |
| 93 | |
| 94 | barrier b1 sync |
| 95 | |
| 96 | send "disable server be1/s2" |
| 97 | expect ~ ".*" |
| 98 | |
| 99 | send "experimental-mode on; del server be1/s2" |
| 100 | expect ~ "Server deleted." |
| 101 | } |
| 102 | |
| 103 | # agent check |
| 104 | haproxy h1 -cli { |
Willy Tarreau | 3b2533f | 2021-08-20 11:28:15 +0200 | [diff] [blame] | 105 | send "experimental-mode on; 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] | 106 | expect ~ "New server registered." |
| 107 | |
| 108 | send "enable agent be1/s3" |
| 109 | expect ~ ".*" |
| 110 | |
| 111 | barrier b1 sync |
| 112 | |
| 113 | send "disable agent be1/s3; disable server be1/s3" |
| 114 | expect ~ ".*" |
| 115 | |
| 116 | send "experimental-mode on; del server be1/s3" |
| 117 | expect ~ "Server deleted." |
| 118 | } |
| 119 | |
| 120 | syslog S1 -wait |