aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-06-29 22:22:34 +0100
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2019-06-30 05:22:34 +0800
commit3a0c7c61532db7f8e4ce79f99129201a79729525 (patch)
treefab82dba453c4676a796f3b2e8f02b3573a1466f /test
parent2c1f5009be5fa0074b1e204f1c2906d6d1f8ea68 (diff)
downloadcoredns-3a0c7c61532db7f8e4ce79f99129201a79729525.tar.gz
coredns-3a0c7c61532db7f8e4ce79f99129201a79729525.tar.zst
coredns-3a0c7c61532db7f8e4ce79f99129201a79729525.zip
plugin/file: load secondary zones lazily on startup (#2944)
This fixes a long standing bug: fixes: #1609 Load secondary zones in a go-routine; this required another mutex to protect some fields; I think those were needded anyway because a transfer can also happen when we're running; we just didn't have a test for that situation. The test had to be changed to wait for the transfer to happen at this is async now. Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'test')
-rw-r--r--test/secondary_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/secondary_test.go b/test/secondary_test.go
index bb013bbaf..685e23e61 100644
--- a/test/secondary_test.go
+++ b/test/secondary_test.go
@@ -2,6 +2,7 @@ package test
import (
"testing"
+ "time"
"github.com/coredns/coredns/plugin/test"
@@ -69,12 +70,16 @@ func TestSecondaryZoneTransfer(t *testing.T) {
m := new(dns.Msg)
m.SetQuestion("example.org.", dns.TypeSOA)
- r, err := dns.Exchange(m, udp)
- if err != nil {
- t.Fatalf("Expected to receive reply, but didn't: %s", err)
+ var r *dns.Msg
+ // This is now async; we we need to wait for it to be transfered.
+ for i := 0; i < 10; i++ {
+ r, _ = dns.Exchange(m, udp)
+ if len(r.Answer) == 0 {
+ break
+ }
+ time.Sleep(100 * time.Microsecond)
}
-
- if len(r.Answer) == 0 {
+ if len(r.Answer) != 0 {
t.Fatalf("Expected answer section")
}
}