Make the methods that handle Metrics all use pointer receivers to fix sync.Once not being initialized. Finish the setup_test to test for failures. And make the check for the address more strict and return an error when it does not have a port number. Add a toplevel test that starts a CoreDNS server with metrics enabled so we catch these errors in the future.
17 lines
362 B
Go
17 lines
362 B
Go
package test
|
|
|
|
import "testing"
|
|
|
|
// Start test server that has metrics enabled. Then tear it down again.
|
|
func TestMetricsServer(t *testing.T) {
|
|
corefile := `.:0 {
|
|
chaos CoreDNS-001 miek@miek.nl
|
|
prometheus localhost:0
|
|
}
|
|
`
|
|
srv, err := CoreDNSServer(corefile)
|
|
if err != nil {
|
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
|
}
|
|
defer srv.Stop()
|
|
}
|