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.*" |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 40 | |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 41 | txreq -url "/metrics?scope=" |
| 42 | rxresp |
| 43 | expect resp.status == 200 |
| 44 | expect resp.bodylen == 0 |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 45 | |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 46 | txreq -url "/metrics?scope=server" |
| 47 | rxresp |
| 48 | expect resp.status == 200 |
| 49 | expect resp.body !~ ".*haproxy_process.*" |
| 50 | expect resp.body !~ ".*haproxy_frontend.*" |
| 51 | expect resp.body !~ ".*haproxy_backend.*" |
| 52 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 53 | |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 54 | txreq -url "/metrics?scope=frontend&scope=backend" |
| 55 | rxresp |
| 56 | expect resp.status == 200 |
| 57 | expect resp.body !~ ".*haproxy_process.*" |
| 58 | expect resp.body ~ ".*haproxy_frontend.*" |
| 59 | expect resp.body ~ ".*haproxy_backend.*" |
| 60 | expect resp.body !~ ".*haproxy_server.*" |
William Dauchy | 2f19974 | 2021-01-11 20:07:48 +0100 | [diff] [blame] | 61 | |
| 62 | txreq -url "/metrics?scope" |
| 63 | rxresp |
| 64 | expect resp.status == 400 |
William Dauchy | 648b4bd | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 65 | } -run |