(t *testing.T)
| 1474 | } |
| 1475 | |
| 1476 | func (s) TestUpdateStatePauses(t *testing.T) { |
| 1477 | cc := &tcc{BalancerClientConn: testutils.NewBalancerClientConn(t)} |
| 1478 | |
| 1479 | balFuncs := stub.BalancerFuncs{ |
| 1480 | UpdateClientConnState: func(bd *stub.BalancerData, _ balancer.ClientConnState) error { |
| 1481 | bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.TransientFailure, Picker: nil}) |
| 1482 | bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: nil}) |
| 1483 | return nil |
| 1484 | }, |
| 1485 | } |
| 1486 | stub.Register("update_state_balancer", balFuncs) |
| 1487 | |
| 1488 | wtb := wtbBuilder.Build(cc, balancer.BuildOptions{}) |
| 1489 | defer wtb.Close() |
| 1490 | |
| 1491 | config, err := wtbParser.ParseConfig([]byte(` |
| 1492 | { |
| 1493 | "targets": { |
| 1494 | "cluster_1": { |
| 1495 | "weight":1, |
| 1496 | "childPolicy": [{"update_state_balancer": ""}] |
| 1497 | } |
| 1498 | } |
| 1499 | }`)) |
| 1500 | if err != nil { |
| 1501 | t.Fatalf("failed to parse balancer config: %v", err) |
| 1502 | } |
| 1503 | |
| 1504 | // Send the config, and an address with hierarchy path ["cluster_1"]. |
| 1505 | addrs := []resolver.Address{{Addr: testBackendAddrStrs[0], Attributes: nil}} |
| 1506 | if err := wtb.UpdateClientConnState(balancer.ClientConnState{ |
| 1507 | ResolverState: resolver.State{Endpoints: []resolver.Endpoint{ |
| 1508 | hierarchy.SetInEndpoint(resolver.Endpoint{Addresses: []resolver.Address{addrs[0]}}, []string{"cds:cluster_1"}), |
| 1509 | }}, |
| 1510 | BalancerConfig: config, |
| 1511 | }); err != nil { |
| 1512 | t.Fatalf("failed to update ClientConn state: %v", err) |
| 1513 | } |
| 1514 | |
| 1515 | // Verify that the only state update is the second one called by the child. |
| 1516 | if len(cc.states) != 1 || cc.states[0].ConnectivityState != connectivity.Ready { |
| 1517 | t.Fatalf("cc.states = %v; want [connectivity.Ready]", cc.states) |
| 1518 | } |
| 1519 | } |
nothing calls this directly
no test coverage detected