diff options
author | 2016-10-04 11:05:04 +0100 | |
---|---|---|
committer | 2016-10-04 11:05:04 +0100 | |
commit | db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0 (patch) | |
tree | fab926dc9dab6152a7845313be034c5286d920bb /test/metrics_test.go | |
parent | d914832904760e8638bb79189822e2cbe84edee5 (diff) | |
download | coredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.tar.gz coredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.tar.zst coredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.zip |
middleware/metrics: fix crash on startup (#318)
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.
Diffstat (limited to 'test/metrics_test.go')
-rw-r--r-- | test/metrics_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/metrics_test.go b/test/metrics_test.go new file mode 100644 index 000000000..85cb2a824 --- /dev/null +++ b/test/metrics_test.go @@ -0,0 +1,17 @@ +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() +} |