MCPcopy
hub / github.com/grpc/grpc-go / TestBalancerExitIdleOne

Method TestBalancerExitIdleOne

internal/balancergroup/balancergroup_test.go:550–578  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

548}
549
550func (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
580func (s) TestBalancerGroup_ExitIdleOne_AfterClose(t *testing.T) {
581 balancerName := t.Name()

Callers

nothing calls this directly

Calls 8

RegisterFunction · 0.92
NewBalancerClientConnFunction · 0.92
NewFunction · 0.92
GetFunction · 0.92
CloseMethod · 0.65
AddMethod · 0.65
ExitIdleOneMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected