MCPcopy
hub / github.com/coredns/coredns / TestMaxIdleConnsUnlimited

Function TestMaxIdleConnsUnlimited

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

Source from the content-addressed store, hash-verified

164}
165
166func TestMaxIdleConnsUnlimited(t *testing.T) {
167 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
168 ret := new(dns.Msg)
169 ret.SetReply(r)
170 w.WriteMsg(ret)
171 })
172 defer s.Close()
173
174 tr := newTransport("TestMaxIdleConnsUnlimited", s.Addr)
175 // maxIdleConns defaults to 0 (unlimited)
176 tr.Start()
177 defer tr.Stop()
178
179 // Dial and yield 5 connections
180 conns := make([]*persistConn, 5)
181 for i := range conns {
182 conns[i], _, _ = tr.Dial("udp")
183 }
184 for _, c := range conns {
185 tr.Yield(c)
186 }
187
188 // Check all 5 are in pool
189 tr.mu.Lock()
190 poolSize := len(tr.conns[typeUDP])
191 tr.mu.Unlock()
192
193 if poolSize != 5 {
194 t.Errorf("Expected pool size 5 (unlimited), got %d", poolSize)
195 }
196}
197
198func TestYieldAfterStop(t *testing.T) {
199 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…