(t *testing.T)
| 548 | } |
| 549 | |
| 550 | func (s) TestBalancerExitIdleOne(t *testing.T) { |
| 551 | const balancerName = "stub-balancer-test-balancergroup-exit-idle-one" |
| 552 | exitIdleCh := make(chan struct{}, 1) |
| 553 | stub.Register(balancerName, stub.BalancerFuncs{ |
| 554 | ExitIdle: func(*stub.BalancerData) { |
| 555 | exitIdleCh <- struct{}{} |
| 556 | }, |
| 557 | }) |
| 558 | cc := testutils.NewBalancerClientConn(t) |
| 559 | bg := balancergroup.New(balancergroup.Options{ |
| 560 | CC: cc, |
| 561 | BuildOpts: balancer.BuildOptions{}, |
| 562 | StateAggregator: nil, |
| 563 | Logger: nil, |
| 564 | }) |
| 565 | defer bg.Close() |
| 566 | |
| 567 | // Add the stub balancer build above as a child policy. |
| 568 | builder := balancer.Get(balancerName) |
| 569 | bg.Add(testBalancerIDs[0], builder) |
| 570 | |
| 571 | // Call ExitIdleOne on the child policy. |
| 572 | bg.ExitIdleOne(testBalancerIDs[0]) |
| 573 | select { |
| 574 | case <-time.After(time.Second): |
| 575 | t.Fatal("Timeout when waiting for ExitIdle to be invoked on child policy") |
| 576 | case <-exitIdleCh: |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | func (s) TestBalancerGroup_ExitIdleOne_AfterClose(t *testing.T) { |
| 581 | balancerName := t.Name() |
nothing calls this directly
no test coverage detected