Skip to content

Commit

Permalink
[xds_eds_endpoint_health] check new sc addrs
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Nov 4, 2019
1 parent 4c225d3 commit 1669f79
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions xds/internal/balancer/edsbalancer/edsbalancer_test.go
Expand Up @@ -409,18 +409,28 @@ func TestEDS_EndpointsHealth(t *testing.T) {
})
edsb.HandleEDSResponse(clab1.build())

var readySCs []balancer.SubConn
var (
readySCs []balancer.SubConn

wantNewSubConnAddrStrs = []string{
testEndpointAddrs[0],
testEndpointAddrs[2],
testEndpointAddrs[6],
testEndpointAddrs[8],
}
)
for i := 0; i < 4; i++ {
addr := <-cc.newSubConnAddrsCh
if addr[0].Addr != wantNewSubConnAddrStrs[i] {
t.Fatalf("want newSubConn with address %q, got %v", wantNewSubConnAddrStrs[i], addr)
}
sc := <-cc.newSubConnCh
edsb.HandleSubConnStateChange(sc, connectivity.Connecting)
edsb.HandleSubConnStateChange(sc, connectivity.Ready)
readySCs = append(readySCs, sc)
}
// There should be exactly 4 new SubConns. Check to make sure there's no
// more subconns being created.
//
// This is check is very necessary. The pick later won't fail even if eds
// doesn't respect health status, because pick only returns Ready subconn.
select {
case <-cc.newSubConnCh:
t.Fatalf("Got unexpected new subconn")
Expand Down

0 comments on commit 1669f79

Please sign in to comment.