(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func (s) TestBlockingPickSCNotReady(t *testing.T) { |
| 160 | bp := newPickerWrapper() |
| 161 | bp.updatePicker(&testingPicker{sc: testSCNotReady, maxCalled: goroutineCount}) |
| 162 | var finishedCount uint64 |
| 163 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 164 | defer cancel() |
| 165 | // All goroutines should block because subConn is not ready. |
| 166 | wg := sync.WaitGroup{} |
| 167 | wg.Add(goroutineCount) |
| 168 | for i := goroutineCount; i > 0; i-- { |
| 169 | go func() { |
| 170 | if pick, err := bp.pick(ctx, true, balancer.PickInfo{}); err != nil || pick.transport != testT { |
| 171 | t.Errorf("bp.pick returned transport: %v, error: %v, want transport: %v, error: nil", pick.transport, err, testT) |
| 172 | } |
| 173 | atomic.AddUint64(&finishedCount, 1) |
| 174 | wg.Done() |
| 175 | }() |
| 176 | } |
| 177 | time.Sleep(time.Millisecond) |
| 178 | if c := atomic.LoadUint64(&finishedCount); c != 0 { |
| 179 | t.Errorf("finished goroutines count: %v, want 0", c) |
| 180 | } |
| 181 | bp.updatePicker(&testingPicker{sc: testSC, maxCalled: goroutineCount}) |
| 182 | // Wait for all pickers to finish before the context is cancelled. |
| 183 | wg.Wait() |
| 184 | } |
nothing calls this directly
no test coverage detected