MCPcopy
hub / github.com/coredns/coredns / TestYieldAfterStop

Function TestYieldAfterStop

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

Source from the content-addressed store, hash-verified

196}
197
198func TestYieldAfterStop(t *testing.T) {
199 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
200 ret := new(dns.Msg)
201 ret.SetReply(r)
202 w.WriteMsg(ret)
203 })
204 defer s.Close()
205
206 tr := newTransport("TestYieldAfterStop", s.Addr)
207 tr.Start()
208
209 // Dial a connection while transport is running
210 c1, _, err := tr.Dial("udp")
211 if err != nil {
212 t.Fatalf("Failed to dial: %v", err)
213 }
214
215 // Stop the transport
216 tr.Stop()
217
218 // Give cleanup goroutine time to exit
219 time.Sleep(50 * time.Millisecond)
220
221 // Yield the connection after stop - should close it, not pool it
222 tr.Yield(c1)
223
224 // Verify pool is empty (connection was closed, not added)
225 tr.mu.Lock()
226 poolSize := len(tr.conns[typeUDP])
227 tr.mu.Unlock()
228
229 if poolSize != 0 {
230 t.Errorf("Expected pool size 0 after stop, got %d", poolSize)
231 }
232}
233
234// TestMaxAgeExpireByCreation verifies that a connection is rejected when its
235// creation time exceeds max_age, even if it was recently yielded (fresh used time).

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
NewServerFunction · 0.92
newTransportFunction · 0.85
DialMethod · 0.80
YieldMethod · 0.80
FatalfMethod · 0.65
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…