(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func (s) TestBlockingPickTransientWaitforready(t *testing.T) { |
| 132 | bp := newPickerWrapper() |
| 133 | bp.updatePicker(&testingPicker{err: balancer.ErrTransientFailure, maxCalled: goroutineCount}) |
| 134 | var finishedCount uint64 |
| 135 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 136 | defer cancel() |
| 137 | // All goroutines should block because picker returns transientFailure and |
| 138 | // picks are not failfast. |
| 139 | wg := sync.WaitGroup{} |
| 140 | wg.Add(goroutineCount) |
| 141 | for i := goroutineCount; i > 0; i-- { |
| 142 | go func() { |
| 143 | if pick, err := bp.pick(ctx, false, balancer.PickInfo{}); err != nil || pick.transport != testT { |
| 144 | t.Errorf("bp.pick returned transport: %v, error: %v, want transport: %v, error: nil", pick.transport, err, testT) |
| 145 | } |
| 146 | atomic.AddUint64(&finishedCount, 1) |
| 147 | wg.Done() |
| 148 | }() |
| 149 | } |
| 150 | time.Sleep(time.Millisecond) |
| 151 | if c := atomic.LoadUint64(&finishedCount); c != 0 { |
| 152 | t.Errorf("finished goroutines count: %v, want 0", c) |
| 153 | } |
| 154 | bp.updatePicker(&testingPicker{sc: testSC, maxCalled: goroutineCount}) |
| 155 | // Wait for all pickers to finish before the context is cancelled. |
| 156 | wg.Wait() |
| 157 | } |
| 158 | |
| 159 | func (s) TestBlockingPickSCNotReady(t *testing.T) { |
| 160 | bp := newPickerWrapper() |
nothing calls this directly
no test coverage detected