MCPcopy Create free account
hub / github.com/chainreactors/spray / TestAddAddition_ConcurrentShutdown

Function TestAddAddition_ConcurrentShutdown

core/pool/pool_test.go:352–379  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

350}
351
352func TestAddAddition_ConcurrentShutdown(t *testing.T) {
353 ctx, cancel := context.WithCancel(context.Background())
354 pool := newTestBasePool(ctx, cancel)
355
356 var ext sync.WaitGroup
357 for i := 0; i < 200; i++ {
358 ext.Add(1)
359 go func() {
360 defer ext.Done()
361 pool.addAddition(&Unit{path: "/c", source: parsers.WordSource})
362 }()
363 }
364
365 time.Sleep(2 * time.Millisecond)
366 cancel()
367
368 // drain so senders can unblock
369 go func() {
370 for range pool.additionCh {
371 pool.wg.Done()
372 }
373 }()
374
375 mustFinish(t, 5*time.Second, "concurrent addAddition+cancel hung", func() {
376 ext.Wait()
377 })
378 close(pool.additionCh)
379}
380
381// ---------------------------------------------------------------------------
382// sendProcess

Callers

nothing calls this directly

Calls 4

newTestBasePoolFunction · 0.85
mustFinishFunction · 0.85
addAdditionMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected