MCPcopy
hub / github.com/grafana/tempo / TestOverloadingASmallPool

Function TestOverloadingASmallPool

tempodb/pool/pool_test.go:257–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

255}
256
257func TestOverloadingASmallPool(t *testing.T) {
258 prePoolOpts := goleak.IgnoreCurrent()
259
260 p := NewPool(&Config{
261 MaxWorkers: 1,
262 QueueDepth: 11,
263 })
264 opts := goleak.IgnoreCurrent()
265
266 wg := &sync.WaitGroup{}
267
268 for i := 0; i < 50; i++ {
269 wg.Add(1)
270 go func() {
271 fn := func(_ context.Context, _ interface{}) (interface{}, error) {
272 time.Sleep(time.Duration(rand.Uint32()%100) * time.Millisecond)
273 return nil, nil
274 }
275 payloads := []interface{}{1, 2}
276 _, _, _ = p.RunJobs(context.Background(), payloads, fn)
277
278 wg.Done()
279 }()
280 }
281
282 wg.Wait()
283 goleak.VerifyNone(t, opts)
284
285 p.Shutdown()
286 goleak.VerifyNone(t, prePoolOpts)
287}
288
289func TestShutdown(t *testing.T) {
290 prePoolOpts := goleak.IgnoreCurrent()

Callers

nothing calls this directly

Calls 8

RunJobsMethod · 0.95
ShutdownMethod · 0.95
DurationMethod · 0.80
NewPoolFunction · 0.70
AddMethod · 0.65
SleepMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected