Commit 2b9d2d6c authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

reload: don't fail test on addr in use (#1804)

A bit meh, but we *need* hardcoded addresses in these tests, because
we can't get them from a running coredns. These may be in-use and this
fails the tests then. Do an ugly err.Error() string match if this is the
case to prevent failing the test for something not in our control.

A better fix would be to retreive the listening address from coredns via
some api, so we could listen on :0 for these as well. No such API exists
as of yet.
parent a9f3ad1f
......@@ -4,6 +4,7 @@ import (
"bytes"
"io/ioutil"
"net/http"
"strings"
"testing"
"time"
......@@ -65,10 +66,12 @@ func TestReloadHealth(t *testing.T) {
}`
c, err := CoreDNSServer(corefile)
if err != nil {
if strings.Contains(err.Error(), inUse) {
return // meh, but don't error
}
t.Fatalf("Could not get service instance: %s", err)
}
// This fails with address 8080 already in use, it shouldn't.
if c1, err := c.Restart(NewInput(corefile)); err != nil {
t.Fatal(err)
} else {
......@@ -85,6 +88,9 @@ func TestReloadMetricsHealth(t *testing.T) {
}`
c, err := CoreDNSServer(corefile)
if err != nil {
if strings.Contains(err.Error(), inUse) {
return // meh, but don't error
}
t.Fatalf("Could not get service instance: %s", err)
}
......@@ -118,3 +124,5 @@ func TestReloadMetricsHealth(t *testing.T) {
t.Errorf("Failed to see %s in metric output", proc)
}
}
const inUse = "address already in use"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment