blob: bf3d4caec2f7ff39a84e43667d666cdc32d08ab0 [file] [log] [blame]
William Dauchy76603f22021-01-10 21:13:06 +01001varnishtest "prometheus exporter test"
2
William Dauchy69164222021-02-07 20:42:38 +01003#REQUIRE_VERSION=2.4
William Dauchy76603f22021-01-10 21:13:06 +01004#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
William Dauchy69164222021-02-07 20:42:38 +010029 stick-table type ip size 1m expire 10s store http_req_rate(10s)
William Dauchy76603f22021-01-10 21:13:06 +010030 server s1 ${s1_addr}:${s1_port}
31} -start
32
33client c1 -connect ${h1_stats_sock} {
34 txreq -url "/metrics"
35 rxresp
36 expect resp.status == 200
37 expect resp.body ~ ".*haproxy_process.*"
38 expect resp.body ~ ".*haproxy_frontend.*"
39 expect resp.body ~ ".*haproxy_backend.*"
40 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010041 expect resp.body ~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010042
William Dauchy76603f22021-01-10 21:13:06 +010043 txreq -url "/metrics?scope="
44 rxresp
45 expect resp.status == 200
46 expect resp.bodylen == 0
William Dauchy76603f22021-01-10 21:13:06 +010047
William Dauchy76603f22021-01-10 21:13:06 +010048 txreq -url "/metrics?scope=server"
49 rxresp
50 expect resp.status == 200
51 expect resp.body !~ ".*haproxy_process.*"
52 expect resp.body !~ ".*haproxy_frontend.*"
53 expect resp.body !~ ".*haproxy_backend.*"
54 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010055 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010056
William Dauchy76603f22021-01-10 21:13:06 +010057 txreq -url "/metrics?scope=frontend&scope=backend"
58 rxresp
59 expect resp.status == 200
60 expect resp.body !~ ".*haproxy_process.*"
61 expect resp.body ~ ".*haproxy_frontend.*"
62 expect resp.body ~ ".*haproxy_backend.*"
63 expect resp.body !~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010064 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy1704efe2021-01-11 20:07:48 +010065
66 txreq -url "/metrics?scope"
67 rxresp
68 expect resp.status == 400
William Dauchy76603f22021-01-10 21:13:06 +010069} -run