registerBlockingBalancer registers a stub balancer that delegates to pick_first. It wraps the ClientConn to intercept state updates and wraps the picker to detect calls to Pick. This guarantees the "Delayed LB pick complete" event is emitted reliably.
(t *testing.T, balancerName string)
| 1446 | // the picker to detect calls to Pick. This guarantees the "Delayed LB pick |
| 1447 | // complete" event is emitted reliably. |
| 1448 | func registerBlockingBalancer(t *testing.T, balancerName string) { |
| 1449 | t.Helper() |
| 1450 | stub.Register(balancerName, stub.BalancerFuncs{ |
| 1451 | Init: func(bd *stub.BalancerData) { |
| 1452 | cc := &testCCWrapper{ |
| 1453 | ClientConn: bd.ClientConn, |
| 1454 | pickInvoked: grpcsync.NewEvent(), |
| 1455 | } |
| 1456 | bd.ChildBalancer = balancer.Get(pickfirst.Name).Build(cc, bd.BuildOptions) |
| 1457 | }, |
| 1458 | Close: func(bd *stub.BalancerData) { |
| 1459 | bd.ChildBalancer.Close() |
| 1460 | }, |
| 1461 | UpdateClientConnState: func(bd *stub.BalancerData, ccs balancer.ClientConnState) error { |
| 1462 | return bd.ChildBalancer.UpdateClientConnState(ccs) |
| 1463 | }, |
| 1464 | ExitIdle: func(bd *stub.BalancerData) { |
| 1465 | bd.ChildBalancer.ExitIdle() |
| 1466 | }, |
| 1467 | }) |
| 1468 | } |
| 1469 | |
| 1470 | // TestTraceSpan_WithRetriesAndNameResolutionDelay verifies that |
| 1471 | // "Delayed name resolution complete" event is recorded in the call trace span |
no test coverage detected