blackbox_exporter icon indicating copy to clipboard operation
blackbox_exporter copied to clipboard

Add test to verify published metrics do not change

Open mem opened this issue 4 years ago • 1 comments

The new checkRegistryMetrics verifies that the metrics produced by a particular probe match the expected metrics. Use this function in tests so that if a change adds or deletes metrics, the test has to be modified accordingly and it doesn't slip thru.

The probes involving TLS are tricky because they contain the fingerprint of the certificate. For the HTTP prober, since we are using the httptest package, the localhost certificate is actually known and fixed, so it's OK to embed the fingerprint in the test. For TCP, we are generating the certificate using random data, so the fingerprint changes each time. Change this to follow a similar strategy as the httptest package. The prober/internal/testcert.go file is actually copied from the Go source and it's the same key and certificate used in the httptest.

Signed-off-by: Marcelo E. Magallon [email protected]

mem avatar Mar 30 '21 02:03 mem

+1, would like to merge. needs rebase.

electron0zero avatar Sep 29 '22 06:09 electron0zero