]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTESTS: stats: add test stats-file counters preload
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 2 May 2024 13:25:53 +0000 (15:25 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 2 May 2024 14:44:28 +0000 (16:44 +0200)
Define a simple regtest to check stats-file loading on startup. A sample
stats-file is written with some invalid values which should be silently
ignored.

reg-tests/stats/sample-stats-file [new file with mode: 0644]
reg-tests/stats/stats-file.vtc [new file with mode: 0644]

diff --git a/reg-tests/stats/sample-stats-file b/reg-tests/stats/sample-stats-file
new file mode 100644 (file)
index 0000000..4748579
--- /dev/null
@@ -0,0 +1,26 @@
+#fe guid,stot,
+
+// valid line
+guid-fe,1024,
+
+// invalid non numerical value must be silently ignored
+guid-fe,abc,
+
+// listener counters not allocated if no option socket-stats
+guid-feS-0,1024
+guid-fe2S-0,1024
+
+// unknown GUID must be silently ignored
+guid-unknown,1024,
+
+// invalid GUID side must be silently ignored
+guid-be,1024
+
+// unknown section line must be silently ignored
+#inval guid,other,
+guid-foo,0,0,
+
+// valid lines
+#be guid,unknown,stot,
+guid-be,512,1024,
+guid-srv,512,1024,
diff --git a/reg-tests/stats/stats-file.vtc b/reg-tests/stats/stats-file.vtc
new file mode 100644 (file)
index 0000000..204a415
--- /dev/null
@@ -0,0 +1,36 @@
+varnishtest "Preload counters via stats-file"
+
+feature ignore_unknown_macro
+
+#REQUIRE_VERSION=3.0
+
+haproxy h1 -conf {
+       global
+               stats-file ${testdir}/sample-stats-file
+
+       frontend fe
+               guid guid-fe
+               bind "fd@${feS}" guid-prefix guid-feS
+
+       frontend fe2
+               guid guid-fe2
+               option socket-stats
+               bind "fd@${fe2S}" guid-prefix guid-fe2S
+
+       backend be
+               guid guid-be
+               server srv ${s1_addr}:${s1_port} guid guid-srv
+} -start
+
+haproxy h1 -cli {
+       send "show stat fe 15 -1 typed"
+       expect ~ "F.*.*.*.stot.1:MCP:u64:1024"
+
+       send "show stat fe2 15 -1 typed"
+       expect ~ "L.*.*.*.stot.1:MCP:u64:1024"
+
+       send "show stat be 15 -1 typed"
+       expect ~ "B.*.*.*.stot.1:MCP:u64:1024"
+       send "show stat be 15 -1 typed"
+       expect ~ "S.*.*.*.stot.1:MCP:u64:1024"
+}