(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func (s) TestBlockingPickNoSubAvailable(t *testing.T) { |
| 105 | bp := newPickerWrapper() |
| 106 | var finishedCount uint64 |
| 107 | bp.updatePicker(&testingPicker{err: balancer.ErrNoSubConnAvailable, maxCalled: goroutineCount}) |
| 108 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 109 | defer cancel() |
| 110 | // All goroutines should block because picker returns no subConn available. |
| 111 | wg := sync.WaitGroup{} |
| 112 | wg.Add(goroutineCount) |
| 113 | for i := goroutineCount; i > 0; i-- { |
| 114 | go func() { |
| 115 | if pick, err := bp.pick(ctx, true, balancer.PickInfo{}); err != nil || pick.transport != testT { |
| 116 | t.Errorf("bp.pick returned transport: %v, error: %v, want transport: %v, error: nil", pick.transport, err, testT) |
| 117 | } |
| 118 | atomic.AddUint64(&finishedCount, 1) |
| 119 | wg.Done() |
| 120 | }() |
| 121 | } |
| 122 | time.Sleep(50 * time.Millisecond) |
| 123 | if c := atomic.LoadUint64(&finishedCount); c != 0 { |
| 124 | t.Errorf("finished goroutines count: %v, want 0", c) |
| 125 | } |
| 126 | bp.updatePicker(&testingPicker{sc: testSC, maxCalled: goroutineCount}) |
| 127 | // Wait for all pickers to finish before the context is cancelled. |
| 128 | wg.Wait() |
| 129 | } |
| 130 | |
| 131 | func (s) TestBlockingPickTransientWaitforready(t *testing.T) { |
| 132 | bp := newPickerWrapper() |
nothing calls this directly
no test coverage detected