TestPickFirst_InitialResolverError sends a resolver error to the balancer before a valid resolver update. It verifies that the clientconn state is updated to TRANSIENT_FAILURE.
(t *testing.T)
| 53 | // before a valid resolver update. It verifies that the clientconn state is |
| 54 | // updated to TRANSIENT_FAILURE. |
| 55 | func (s) TestPickFirst_InitialResolverError(t *testing.T) { |
| 56 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 57 | defer cancel() |
| 58 | cc := testutils.NewBalancerClientConn(t) |
| 59 | bal := balancer.Get(Name).Build(cc, balancer.BuildOptions{}) |
| 60 | defer bal.Close() |
| 61 | bal.ResolverError(errors.New("resolution failed: test error")) |
| 62 | |
| 63 | if err := cc.WaitForConnectivityState(ctx, connectivity.TransientFailure); err != nil { |
| 64 | t.Fatalf("cc.WaitForConnectivityState(%v) returned error: %v", connectivity.TransientFailure, err) |
| 65 | } |
| 66 | |
| 67 | // After sending a valid update, the LB policy should report CONNECTING. |
| 68 | ccState := balancer.ClientConnState{ |
| 69 | ResolverState: resolver.State{ |
| 70 | Endpoints: []resolver.Endpoint{ |
| 71 | {Addresses: []resolver.Address{{Addr: "1.1.1.1:1"}}}, |
| 72 | {Addresses: []resolver.Address{{Addr: "2.2.2.2:2"}}}, |
| 73 | }, |
| 74 | }, |
| 75 | } |
| 76 | if err := bal.UpdateClientConnState(ccState); err != nil { |
| 77 | t.Fatalf("UpdateClientConnState(%v) returned error: %v", ccState, err) |
| 78 | } |
| 79 | |
| 80 | if err := cc.WaitForConnectivityState(ctx, connectivity.Connecting); err != nil { |
| 81 | t.Fatalf("cc.WaitForConnectivityState(%v) returned error: %v", connectivity.Connecting, err) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // TestPickFirst_ResolverErrorinTF sends a resolver error to the balancer |
| 86 | // before when it's attempting to connect to a SubConn TRANSIENT_FAILURE. It |
nothing calls this directly
no test coverage detected