aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-08-26 17:39:43 +0100
committerGravatar GitHub <noreply@github.com> 2017-08-26 17:39:43 +0100
commit1bb836b7936fc4b6e2ec3678919fc1eb5b17983b (patch)
treea31194556a97de8b45269d383eb8703b3ce91c20 /test
parentafad8abef3d0eb046d448f6e597cc18004628f4a (diff)
downloadcoredns-1bb836b7936fc4b6e2ec3678919fc1eb5b17983b.tar.gz
coredns-1bb836b7936fc4b6e2ec3678919fc1eb5b17983b.tar.zst
coredns-1bb836b7936fc4b6e2ec3678919fc1eb5b17983b.zip
mw/health: add reload test (#980)
Start CoreDNS instance in call Restart() on it.
Diffstat (limited to 'test')
-rw-r--r--test/health_reload_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/health_reload_test.go b/test/health_reload_test.go
new file mode 100644
index 000000000..66e701532
--- /dev/null
+++ b/test/health_reload_test.go
@@ -0,0 +1,49 @@
+package test
+
+import (
+ "io/ioutil"
+ "log"
+ "net/http"
+ "testing"
+)
+
+func TestHealthReload(t *testing.T) {
+ log.SetOutput(ioutil.Discard)
+
+ // Corefile with for example without proxy section.
+ corefile := `example.org:0 {
+ health localhost:35080
+}
+`
+ i, err := CoreDNSServer(corefile)
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+
+ resp, err := http.Get("http://localhost:35080/health")
+ if err != nil {
+ t.Fatalf("Could not get health: %s", err)
+ }
+ body, err := ioutil.ReadAll(resp.Body)
+ if x := string(body); x != "OK" {
+ t.Fatalf("Expect OK, got %s", x)
+ }
+ resp.Body.Close()
+
+ i, err = i.Restart(NewInput(corefile))
+ if err != nil {
+ t.Fatalf("Could not restart CoreDNS serving instance: %s", err)
+ }
+
+ defer i.Stop()
+
+ resp, err = http.Get("http://localhost:35080/health")
+ if err != nil {
+ t.Fatalf("Could not get health: %s", err)
+ }
+ body, err = ioutil.ReadAll(resp.Body)
+ if x := string(body); x != "OK" {
+ t.Fatalf("Expect OK, got %s", x)
+ }
+ resp.Body.Close()
+}