Skip to content

Commit

Permalink
Remove cc.Connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal authored Dec 17, 2024
1 parent c71b79d commit cc0aa2e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions balancer/grpclb/grpclb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,16 +1107,16 @@ func (s) TestGRPCLB_PickFirst(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create a client for the backend: %v", err)
}
cc.Connect()
defer cc.Close()

// Push a service config with grpclb as the load balancing policy and
// configure pick_first as its child policy.
rs := resolver.State{ServiceConfig: r.CC.ParseServiceConfig(`{"loadBalancingConfig":[{"grpclb":{"childPolicy":[{"pick_first":{}}]}}]}`)}
svcCfg := `{"loadBalancingConfig":[{"grpclb":{"childPolicy":[{"pick_first":{}}]}}]}`
rs := resolver.State{ServiceConfig: internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(svcCfg)}

// Push a resolver update with the remote balancer address specified via
// attributes.
r.UpdateState(grpclbstate.Set(rs, &grpclbstate.State{BalancerAddresses: []resolver.Address{{Addr: tss.lbAddr, ServerName: lbServerName}}}))
r.InitialState(grpclbstate.Set(rs, &grpclbstate.State{BalancerAddresses: []resolver.Address{{Addr: tss.lbAddr, ServerName: lbServerName}}}))

// Push all three backend addresses to the remote balancer, and verify that
// RPCs are routed to the first backend.
Expand Down Expand Up @@ -1247,7 +1247,6 @@ func testGRPCLBEmptyServerList(t *testing.T, svcfg string) {
if err != nil {
t.Fatalf("Failed to create a client for the backend %v", err)
}
cc.Connect()
defer cc.Close()
testC := testgrpc.NewTestServiceClient(cc)

Expand All @@ -1261,8 +1260,8 @@ func testGRPCLBEmptyServerList(t *testing.T, svcfg string) {
},
},
}
rs := grpclbstate.Set(resolver.State{ServiceConfig: r.CC.ParseServiceConfig(svcfg)}, s)
r.UpdateState(rs)
rs := grpclbstate.Set(resolver.State{ServiceConfig: internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(svcfg)}, s)
r.InitialState(rs)
t.Log("Perform an initial RPC and expect it to succeed...")
if _, err := testC.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
t.Fatalf("Initial _.EmptyCall(_, _) = _, %v, want _, <nil>", err)
Expand Down Expand Up @@ -1429,11 +1428,10 @@ func runAndCheckStats(t *testing.T, drop bool, statsChan chan *lbpb.ClientStats,
if err != nil {
t.Fatalf("Failed to create a client for the backend %v", err)
}
cc.Connect()
defer cc.Close()

rstate := resolver.State{ServiceConfig: r.CC.ParseServiceConfig(grpclbConfig)}
r.UpdateState(grpclbstate.Set(rstate, &grpclbstate.State{BalancerAddresses: []resolver.Address{{
rstate := resolver.State{ServiceConfig: internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(grpclbConfig)}
r.InitialState(grpclbstate.Set(rstate, &grpclbstate.State{BalancerAddresses: []resolver.Address{{
Addr: tss.lbAddr,
ServerName: lbServerName,
}}}))
Expand Down Expand Up @@ -1621,7 +1619,8 @@ func (s) TestGRPCLBStatsStreamingFailedToSend(t *testing.T) {
func (s) TestGRPCLBStatsQuashEmpty(t *testing.T) {
ch := make(chan *lbpb.ClientStats)
defer close(ch)
if err := runAndCheckStats(t, false, ch, func(*grpc.ClientConn) {
if err := runAndCheckStats(t, false, ch, func(cc *grpc.ClientConn) {
cc.Connect()
// Perform no RPCs; wait for load reports to start, which should be
// zero, then expect no other load report within 5x the update
// interval.
Expand Down

0 comments on commit cc0aa2e

Please sign in to comment.