diff --git a/xds/internal/balancer/edsbalancer/eds_impl_test.go b/xds/internal/balancer/edsbalancer/eds_impl_test.go index 9db07cf1fa72..97a7db838570 100644 --- a/xds/internal/balancer/edsbalancer/eds_impl_test.go +++ b/xds/internal/balancer/edsbalancer/eds_impl_test.go @@ -19,6 +19,7 @@ package edsbalancer import ( "fmt" "reflect" + "runtime/debug" "sort" "testing" "time" @@ -746,6 +747,7 @@ func (s) TestDropPicker(t *testing.T) { } func (s) TestEDS_LoadReport(t *testing.T) { + debug.PrintStack() origCircuitBreakingSupport := env.CircuitBreakingSupport env.CircuitBreakingSupport = true defer func() { env.CircuitBreakingSupport = origCircuitBreakingSupport }() @@ -762,10 +764,9 @@ func (s) TestEDS_LoadReport(t *testing.T) { edsb := newEDSBalancerImpl(cc, nil, lsWrapper, nil) edsb.enqueueChildBalancerStateUpdate = edsb.updateState - const ( - testServiceName = "test-service" - cbMaxRequests = 20 - ) + // var testServiceName = fmt.Sprintf("test-service-%v", time.Now().UnixNano()) + var testServiceName = "test-service" + const cbMaxRequests = 20 var maxRequestsTemp uint32 = cbMaxRequests client.SetMaxRequests(testServiceName, &maxRequestsTemp) edsb.updateServiceRequestsCounter(testServiceName) @@ -808,27 +809,13 @@ func (s) TestEDS_LoadReport(t *testing.T) { // In the remaining RPCs, only cbMaxRequests are allowed by circuit // breaking. Others will be dropped by CB. dropWithCB = rpcCount - dropWithCategory - cbMaxRequests - - rpcInProgress = cbMaxRequests / 2 // 50% of RPCs will be never done. - rpcSucceeded = cbMaxRequests / 2 // 50% of RPCs will succeed. ) - wantStoreData := []*load.Data{{ - Cluster: testClusterNames[0], - Service: "", - LocalityStats: map[string]load.LocalityData{ - locality1JSON: {RequestStats: load.RequestData{InProgress: rpcInProgress}}, - locality2JSON: {RequestStats: load.RequestData{Succeeded: rpcSucceeded}}, - }, - TotalDrops: dropWithCategory + dropWithCB, - Drops: map[string]uint64{ - testDropCategory: dropWithCategory, - }, - }} var rpcsToBeDone []balancer.PickResult // Run the picks, but only pick with sc1 will be done later. for i := 0; i < rpcCount; i++ { - scst, _ := p1.Pick(balancer.PickInfo{}) + scst, err := p1.Pick(balancer.PickInfo{}) + fmt.Println(i, scst, err) if scst.Done != nil && scst.SubConn != sc1 { rpcsToBeDone = append(rpcsToBeDone, scst) } @@ -837,6 +824,23 @@ func (s) TestEDS_LoadReport(t *testing.T) { for _, scst := range rpcsToBeDone { scst.Done(balancer.DoneInfo{}) } + var ( + rpcSucceeded = len(rpcsToBeDone) + rpcInProgress = rpcCount - dropWithCategory - dropWithCB - rpcSucceeded + ) + + wantStoreData := []*load.Data{{ + Cluster: testClusterNames[0], + Service: "", + LocalityStats: map[string]load.LocalityData{ + locality1JSON: {RequestStats: load.RequestData{InProgress: uint64(rpcInProgress)}}, + locality2JSON: {RequestStats: load.RequestData{Succeeded: uint64(rpcSucceeded)}}, + }, + TotalDrops: dropWithCategory + dropWithCB, + Drops: map[string]uint64{ + testDropCategory: dropWithCategory, + }, + }} gotStoreData := loadStore.Stats(testClusterNames[0:1]) if diff := cmp.Diff(wantStoreData, gotStoreData, cmpopts.EquateEmpty(), cmpopts.IgnoreFields(load.Data{}, "ReportInterval")); diff != "" {