William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame^] | 1 | varnishtest "prometheus exporter test" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.0 |
| 4 | #REQUIRE_SERVICES=prometheus-exporter |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | server s1 { |
| 9 | rxreq |
| 10 | txresp |
| 11 | } -repeat 2 -start |
| 12 | |
| 13 | haproxy h1 -conf { |
| 14 | defaults |
| 15 | mode http |
| 16 | timeout connect 1s |
| 17 | timeout client 1s |
| 18 | timeout server 1s |
| 19 | |
| 20 | listen stats |
| 21 | bind "fd@${stats}" |
| 22 | http-request use-service prometheus-exporter if { path /metrics } |
| 23 | |
| 24 | frontend fe |
| 25 | bind "fd@${fe}" |
| 26 | default_backend be |
| 27 | |
| 28 | backend be |
| 29 | server s1 ${s1_addr}:${s1_port} |
| 30 | } -start |
| 31 | |
| 32 | client c1 -connect ${h1_stats_sock} { |
| 33 | txreq -url "/metrics" |
| 34 | rxresp |
| 35 | expect resp.status == 200 |
| 36 | expect resp.body ~ ".*haproxy_process.*" |
| 37 | expect resp.body ~ ".*haproxy_frontend.*" |
| 38 | expect resp.body ~ ".*haproxy_backend.*" |
| 39 | expect resp.body ~ ".*haproxy_server.*" |
| 40 | } -run |
| 41 | |
| 42 | client c2 -connect ${h1_stats_sock} { |
| 43 | txreq -url "/metrics?scope" |
| 44 | rxresp |
| 45 | expect resp.status == 400 |
| 46 | } -run |
| 47 | |
| 48 | client c3 -connect ${h1_stats_sock} { |
| 49 | txreq -url "/metrics?scope=" |
| 50 | rxresp |
| 51 | expect resp.status == 200 |
| 52 | expect resp.bodylen == 0 |
| 53 | } -run |
| 54 | |
| 55 | client c4 -connect ${h1_stats_sock} { |
| 56 | txreq -url "/metrics?scope=server" |
| 57 | rxresp |
| 58 | expect resp.status == 200 |
| 59 | expect resp.body !~ ".*haproxy_process.*" |
| 60 | expect resp.body !~ ".*haproxy_frontend.*" |
| 61 | expect resp.body !~ ".*haproxy_backend.*" |
| 62 | expect resp.body ~ ".*haproxy_server.*" |
| 63 | } -run |
| 64 | |
| 65 | client c5 -connect ${h1_stats_sock} { |
| 66 | txreq -url "/metrics?scope=frontend&scope=backend" |
| 67 | rxresp |
| 68 | expect resp.status == 200 |
| 69 | expect resp.body !~ ".*haproxy_process.*" |
| 70 | expect resp.body ~ ".*haproxy_frontend.*" |
| 71 | expect resp.body ~ ".*haproxy_backend.*" |
| 72 | expect resp.body !~ ".*haproxy_server.*" |
| 73 | } -run |