]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: reg-tests: add base prometheus test
authorWilliam Dauchy <wdauchy@gmail.com>
Sun, 10 Jan 2021 20:13:06 +0000 (21:13 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 11 Jan 2021 13:16:06 +0000 (14:16 +0100)
Add a base test to start with something, even though this is not
necessarily complete.
Also make use of the recent REQUIRE_SERVICE option to exclude it from
test list of it was not build with prometheus included.

note: I thought it was possible to send multiple requests within the
same client, but I'm getting "HTTP header is incomplete" from the second
request

Signed-off-by: William Dauchy <wdauchy@gmail.com>
reg-tests/contrib/prometheus.vtc [new file with mode: 0644]

diff --git a/reg-tests/contrib/prometheus.vtc b/reg-tests/contrib/prometheus.vtc
new file mode 100644 (file)
index 0000000..64b9cc0
--- /dev/null
@@ -0,0 +1,73 @@
+varnishtest "prometheus exporter test"
+
+#REQUIRE_VERSION=2.0
+#REQUIRE_SERVICES=prometheus-exporter
+
+feature ignore_unknown_macro
+
+server s1 {
+       rxreq
+       txresp
+} -repeat 2 -start
+
+haproxy h1 -conf {
+    defaults
+       mode http
+       timeout connect 1s
+       timeout client  1s
+       timeout server  1s
+
+    listen stats
+       bind "fd@${stats}"
+        http-request use-service prometheus-exporter if { path /metrics }
+
+    frontend fe
+       bind "fd@${fe}"
+       default_backend be
+
+    backend be
+       server s1 ${s1_addr}:${s1_port}
+} -start
+
+client c1 -connect ${h1_stats_sock} {
+       txreq -url "/metrics"
+       rxresp
+       expect resp.status == 200
+       expect resp.body ~ ".*haproxy_process.*"
+       expect resp.body ~ ".*haproxy_frontend.*"
+       expect resp.body ~ ".*haproxy_backend.*"
+       expect resp.body ~ ".*haproxy_server.*"
+} -run
+
+client c2 -connect ${h1_stats_sock} {
+       txreq -url "/metrics?scope"
+       rxresp
+       expect resp.status == 400
+} -run
+
+client c3 -connect ${h1_stats_sock} {
+       txreq -url "/metrics?scope="
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 0
+} -run
+
+client c4 -connect ${h1_stats_sock} {
+       txreq -url "/metrics?scope=server"
+       rxresp
+       expect resp.status == 200
+       expect resp.body !~ ".*haproxy_process.*"
+       expect resp.body !~ ".*haproxy_frontend.*"
+       expect resp.body !~ ".*haproxy_backend.*"
+       expect resp.body ~ ".*haproxy_server.*"
+} -run
+
+client c5 -connect ${h1_stats_sock} {
+       txreq -url "/metrics?scope=frontend&scope=backend"
+       rxresp
+       expect resp.status == 200
+       expect resp.body !~ ".*haproxy_process.*"
+       expect resp.body ~ ".*haproxy_frontend.*"
+       expect resp.body ~ ".*haproxy_backend.*"
+       expect resp.body !~ ".*haproxy_server.*"
+} -run