MCPcopy Create free account
hub / github.com/HyBuildNet/quic-relay / TestWorkerPool_Stop

Function TestWorkerPool_Stop

internal/proxy/pool_test.go:65–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestWorkerPool_Stop(t *testing.T) {
66 var processed atomic.Int32
67
68 pool := NewWorkerPool(4, 100, func(addr *net.UDPAddr, packet []byte) {
69 processed.Add(1)
70 })
71 pool.Start()
72
73 addr := &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234}
74
75 // Submit some work
76 for i := 0; i < 50; i++ {
77 pool.Submit(WorkItem{ClientAddr: addr, Packet: []byte{0x01}})
78 }
79
80 // Stop should wait for all work to complete
81 pool.Stop()
82
83 // All submitted work should be processed
84 if processed.Load() != 50 {
85 t.Errorf("expected 50 processed after Stop, got %d", processed.Load())
86 }
87}
88
89func TestWorkerPool_QueueSize(t *testing.T) {
90 pool := NewWorkerPool(1, 100, func(addr *net.UDPAddr, packet []byte) {

Callers

nothing calls this directly

Calls 4

StartMethod · 0.95
SubmitMethod · 0.95
StopMethod · 0.95
NewWorkerPoolFunction · 0.85

Tested by

no test coverage detected