(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func (s) TestBlockingPick(t *testing.T) { |
| 79 | bp := newPickerWrapper() |
| 80 | // All goroutines should block because picker is nil in bp. |
| 81 | var finishedCount uint64 |
| 82 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 83 | defer cancel() |
| 84 | wg := sync.WaitGroup{} |
| 85 | wg.Add(goroutineCount) |
| 86 | for i := goroutineCount; i > 0; i-- { |
| 87 | go func() { |
| 88 | if pick, err := bp.pick(ctx, true, balancer.PickInfo{}); err != nil || pick.transport != testT { |
| 89 | t.Errorf("bp.pick returned transport: %v, error: %v, want transport: %v, error: nil", pick.transport, err, testT) |
| 90 | } |
| 91 | atomic.AddUint64(&finishedCount, 1) |
| 92 | wg.Done() |
| 93 | }() |
| 94 | } |
| 95 | time.Sleep(50 * time.Millisecond) |
| 96 | if c := atomic.LoadUint64(&finishedCount); c != 0 { |
| 97 | t.Errorf("finished goroutines count: %v, want 0", c) |
| 98 | } |
| 99 | bp.updatePicker(&testingPicker{sc: testSC, maxCalled: goroutineCount}) |
| 100 | // Wait for all pickers to finish before the context is cancelled. |
| 101 | wg.Wait() |
| 102 | } |
| 103 | |
| 104 | func (s) TestBlockingPickNoSubAvailable(t *testing.T) { |
| 105 | bp := newPickerWrapper() |
nothing calls this directly
no test coverage detected