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 a8bba8f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions xds/internal/balancer/edsbalancer/edsbalancer_test.go
Expand Up @@ -409,25 +409,35 @@ 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")
case <-time.After(time.Microsecond * 100):
}

// Test roundrobin with two subconns.
// Test roundrobin with the subconns.
p1 := <-cc.newPickerCh
want := readySCs
if err := isRoundRobin(want, func() balancer.SubConn {
Expand Down

0 comments on commit a8bba8f

Please sign in to comment.