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" |
| 22 | expect_close |
| 23 | barrier b2 sync |
| 24 | } -start |
| 25 | |
| 26 | syslog S1 -level notice { |
| 27 | recv |
| 28 | expect ~ ".*Server be1/s1 is UP/READY \\(leaving forced maintenance\\)." |
| 29 | recv |
| 30 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s1 succeeded.+reason: Layer7 check passed, code: 200, check duration: [[:digit:]]+ms.+status: 1/1 UP" |
| 31 | |
| 32 | barrier b1 sync |
| 33 | |
| 34 | recv |
| 35 | expect ~ ".*Server be1/s2 is UP/READY \\(leaving forced maintenance\\)." |
| 36 | recv |
| 37 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s2 failed.+reason: Layer7 timeout, check duration: [[:digit:]]+ms.+status: 0/1 DOWN" |
| 38 | |
| 39 | barrier b1 sync |
| 40 | |
| 41 | recv |
| 42 | expect ~ ".*Server be1/s2 was DOWN and now enters maintenance." |
| 43 | |
| 44 | recv |
| 45 | expect ~ ".*Server be1/s3 is UP/READY \\(leaving forced maintenance\\)." |
| 46 | |
| 47 | recv |
| 48 | 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" |
| 49 | |
| 50 | barrier b1 sync |
| 51 | barrier b2 sync |
| 52 | } -start |
| 53 | |
| 54 | haproxy h1 -conf { |
| 55 | global |
| 56 | stats socket "${tmpdir}/h1/stats" level admin |
| 57 | |
| 58 | backend be1 |
| 59 | option log-health-checks |
| 60 | option httpchk GET / |
| 61 | log ${S1_addr}:${S1_port} daemon |
| 62 | } -start |
| 63 | |
| 64 | # check on a functional server |
| 65 | haproxy h1 -cli { |
| 66 | send "experimental-mode on; add server be1/s1 ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1" |
| 67 | expect ~ "New server registered." |
| 68 | |
| 69 | send "enable server be1/s1" |
| 70 | expect ~ ".*" |
| 71 | send "enable health be1/s1" |
| 72 | expect ~ ".*" |
| 73 | |
| 74 | barrier b1 sync |
| 75 | |
| 76 | send "disable server be1/s1" |
| 77 | expect ~ ".*" |
| 78 | |
| 79 | send "experimental-mode on; del server be1/s1" |
| 80 | expect ~ "Server deleted." |
| 81 | } |
| 82 | |
| 83 | server s2 -break |
| 84 | |
| 85 | # check on a disabled server |
| 86 | haproxy h1 -cli { |
| 87 | send "experimental-mode on; add server be1/s2 ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1" |
| 88 | expect ~ "New server registered." |
| 89 | |
| 90 | send "enable server be1/s2" |
| 91 | expect ~ ".*" |
| 92 | send "enable health be1/s2" |
| 93 | expect ~ ".*" |
| 94 | |
| 95 | barrier b1 sync |
| 96 | |
| 97 | send "disable server be1/s2" |
| 98 | expect ~ ".*" |
| 99 | |
| 100 | send "experimental-mode on; del server be1/s2" |
| 101 | expect ~ "Server deleted." |
| 102 | } |
| 103 | |
| 104 | # agent check |
| 105 | haproxy h1 -cli { |
| 106 | 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" |
| 107 | expect ~ "New server registered." |
| 108 | |
| 109 | send "enable agent be1/s3" |
| 110 | expect ~ ".*" |
| 111 | |
| 112 | barrier b1 sync |
| 113 | |
| 114 | send "disable agent be1/s3; disable server be1/s3" |
| 115 | expect ~ ".*" |
| 116 | |
| 117 | send "experimental-mode on; del server be1/s3" |
| 118 | expect ~ "Server deleted." |
| 119 | } |
| 120 | |
| 121 | syslog S1 -wait |