diff options
Diffstat (limited to 'plugin/forward/persistent_test.go')
-rw-r--r-- | plugin/forward/persistent_test.go | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/plugin/forward/persistent_test.go b/plugin/forward/persistent_test.go index f1c906076..1fb239ca7 100644 --- a/plugin/forward/persistent_test.go +++ b/plugin/forward/persistent_test.go @@ -82,54 +82,6 @@ func TestCleanupByTimer(t *testing.T) { tr.Yield(c4) } -func TestPartialCleanup(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - tr := newTransport(s.Addr) - tr.SetExpire(100 * time.Millisecond) - tr.Start() - defer tr.Stop() - - c1, _, _ := tr.Dial("udp") - c2, _, _ := tr.Dial("udp") - c3, _, _ := tr.Dial("udp") - c4, _, _ := tr.Dial("udp") - c5, _, _ := tr.Dial("udp") - - tr.Yield(c1) - time.Sleep(10 * time.Millisecond) - tr.Yield(c2) - time.Sleep(10 * time.Millisecond) - tr.Yield(c3) - time.Sleep(50 * time.Millisecond) - tr.Yield(c4) - time.Sleep(10 * time.Millisecond) - tr.Yield(c5) - time.Sleep(40 * time.Millisecond) - - c6, _, _ := tr.Dial("udp") - if c6 != c5 { - t.Errorf("Expected c6 == c5") - } - c7, _, _ := tr.Dial("udp") - if c7 != c4 { - t.Errorf("Expected c7 == c4") - } - c8, cached, _ := tr.Dial("udp") - if cached { - t.Error("Expected non-cached connection (c8)") - } - - tr.Yield(c6) - tr.Yield(c7) - tr.Yield(c8) -} - func TestCleanupAll(t *testing.T) { s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { ret := new(dns.Msg) @@ -150,12 +102,12 @@ func TestCleanupAll(t *testing.T) { {c3, time.Now()}, } - if tr.len() != 3 { + if len(tr.conns["udp"]) != 3 { t.Error("Expected 3 connections") } tr.cleanup(true) - if tr.len() > 0 { + if len(tr.conns["udp"]) > 0 { t.Error("Expected no cached connections") } } |