blackbox_exporter
blackbox_exporter copied to clipboard
Add test to verify published metrics do not change
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]
+1, would like to merge. needs rebase.