mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user