blob: 59ff82d5b9e7e0a60bf2bf13f7df4e65f1b8368c [file] [log] [blame]
William Dauchy76603f22021-01-10 21:13:06 +01001varnishtest "prometheus exporter test"
2
3#REQUIRE_VERSION=2.0
4#REQUIRE_SERVICES=prometheus-exporter
5
6feature ignore_unknown_macro
7
8server s1 {
9 rxreq
10 txresp
11} -repeat 2 -start
12
13haproxy 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
32client 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 Dauchy76603f22021-01-10 21:13:06 +010040
William Dauchy76603f22021-01-10 21:13:06 +010041 txreq -url "/metrics?scope="
42 rxresp
43 expect resp.status == 200
44 expect resp.bodylen == 0
William Dauchy76603f22021-01-10 21:13:06 +010045
William Dauchy76603f22021-01-10 21:13:06 +010046 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 Dauchy76603f22021-01-10 21:13:06 +010053
William Dauchy76603f22021-01-10 21:13:06 +010054 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 Dauchy1704efe2021-01-11 20:07:48 +010061
62 txreq -url "/metrics?scope"
63 rxresp
64 expect resp.status == 400
William Dauchy76603f22021-01-10 21:13:06 +010065} -run