Skip to content

Commit

Permalink
[circuit_breaking_drop_reporting] test???
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Jan 22, 2021
1 parent 3e508a3 commit 0b5c5c0
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions xds/internal/balancer/edsbalancer/eds_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,27 +808,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)
}
Expand All @@ -837,6 +823,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 != "" {
Expand Down

0 comments on commit 0b5c5c0

Please sign in to comment.