MCPcopy
hub / github.com/coredns/coredns / TestCleanupByTimer

Function TestCleanupByTimer

plugin/pkg/proxy/persistent_test.go:53–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestCleanupByTimer(t *testing.T) {
54 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
55 ret := new(dns.Msg)
56 ret.SetReply(r)
57 w.WriteMsg(ret)
58 })
59 defer s.Close()
60
61 tr := newTransport("TestCleanupByTimer", s.Addr)
62 tr.SetExpire(100 * time.Millisecond)
63 tr.Start()
64 defer tr.Stop()
65
66 c1, _, _ := tr.Dial("udp")
67 c2, _, _ := tr.Dial("udp")
68 tr.Yield(c1)
69 time.Sleep(10 * time.Millisecond)
70 tr.Yield(c2)
71
72 time.Sleep(120 * time.Millisecond)
73 c3, cached, _ := tr.Dial("udp")
74 if cached {
75 t.Error("Expected non-cached connection (c3)")
76 }
77 tr.Yield(c3)
78
79 time.Sleep(120 * time.Millisecond)
80 c4, cached, _ := tr.Dial("udp")
81 if cached {
82 t.Error("Expected non-cached connection (c4)")
83 }
84 tr.Yield(c4)
85}
86
87func TestCleanupAll(t *testing.T) {
88 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
NewServerFunction · 0.92
newTransportFunction · 0.85
DialMethod · 0.80
YieldMethod · 0.80
StopMethod · 0.65
ErrorMethod · 0.65
WriteMsgMethod · 0.45
SetExpireMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…