Skip to content

Commit ac08441

Browse files
committed
modifying test
1 parent 23c6cdd commit ac08441

1 file changed

Lines changed: 7 additions & 26 deletions

File tree

internal/xds/balancer/clusterimpl/tests/balancer_test.go

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ import (
4343
"google.golang.org/grpc/peer"
4444
"google.golang.org/grpc/resolver"
4545
"google.golang.org/grpc/status"
46+
"google.golang.org/protobuf/testing/protocmp"
4647
"google.golang.org/protobuf/types/known/durationpb"
4748
"google.golang.org/protobuf/types/known/wrapperspb"
48-
"google.golang.org/protobuf/testing/protocmp"
4949

5050
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
5151
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
@@ -632,21 +632,13 @@ func (s) TestDropByCategory(t *testing.T) {
632632
}
633633
mgmtServer.LRSServer.LRSResponseChan <- &resp
634634

635-
time.Sleep(time.Second)
636635
select {
637636
case req := <-mgmtServer.LRSServer.LRSRequestChan.C:
638637
loadStats := req.(*fakeserver.Request).Req.(*v3lrspb.LoadStatsRequest)
639638
for _, cs := range loadStats.ClusterStats {
640-
if len(cs.DroppedRequests) > 0 {
641-
if cs.DroppedRequests[0].Category != dropReason {
642-
t.Errorf("Unexpected drop category got: %q, want: %q", cs.DroppedRequests[0].Category, dropReason)
643-
}
644-
gotRPCDropRate := float64(cs.DroppedRequests[0].DroppedCount) / float64(rpcCount)
645-
if math.Abs(gotRPCDropRate-wantRPCDropRate) > errorTolerance {
646-
t.Errorf("Drop rate goes out of errortolerance got: %v, want: %v, totalDroppedRequest: %v, totalIssuesRequest: %v", math.Abs(gotRPCDropRate-wantRPCDropRate), errorTolerance, cs.TotalDroppedRequests, cs.UpstreamLocalityStats[0].TotalIssuedRequests)
647-
}
648-
} else {
649-
t.Errorf("No DroppedRequests reported, want at least one with category %q", dropReason)
639+
gotRPCDropRate := float64(cs.TotalDroppedRequests) / float64(rpcCount)
640+
if math.Abs(gotRPCDropRate-wantRPCDropRate) > errorTolerance {
641+
t.Errorf("Drop rate goes out of errortolerance got: %v, want: %v, totalDroppedRequest: %v, totalIssuesRequest: %v", math.Abs(gotRPCDropRate-wantRPCDropRate), errorTolerance, cs.TotalDroppedRequests, cs.UpstreamLocalityStats[0].TotalIssuedRequests)
650642
}
651643
}
652644
case <-ctx.Done():
@@ -700,24 +692,13 @@ func (s) TestDropByCategory(t *testing.T) {
700692
}
701693
}
702694

703-
time.Sleep(time.Second)
704695
select {
705696
case req := <-mgmtServer.LRSServer.LRSRequestChan.C:
706697
loadStats := req.(*fakeserver.Request).Req.(*v3lrspb.LoadStatsRequest)
707698
for _, cs := range loadStats.ClusterStats {
708-
found := false
709-
for _, dr := range cs.DroppedRequests {
710-
if dr.Category == dropReason2 {
711-
found = true
712-
gotRPCDropRate := float64(dr.DroppedCount) / float64(rpcCount)
713-
if math.Abs(gotRPCDropRate-wantRPCDropRate) > errorTolerance {
714-
t.Errorf("Drop rate goes out of errortolerance got: %v, want: %v, totalDroppedRequest: %v, totalIssuesRequest: %v", math.Abs(gotRPCDropRate-wantRPCDropRate), errorTolerance, cs.TotalDroppedRequests, cs.UpstreamLocalityStats[0].TotalIssuedRequests)
715-
}
716-
break
717-
}
718-
}
719-
if !found {
720-
t.Errorf("No DroppedRequests reported for expected category %q", dropReason2)
699+
gotRPCDropRate := float64(cs.TotalDroppedRequests) / float64(rpcCount)
700+
if math.Abs(gotRPCDropRate-wantRPCDropRate) > errorTolerance {
701+
t.Errorf("Drop rate goes out of errortolerance got: %v, want: %v, totalDroppedRequest: %v, totalIssuesRequest: %v", math.Abs(gotRPCDropRate-wantRPCDropRate), errorTolerance, cs.TotalDroppedRequests, cs.UpstreamLocalityStats[0].TotalIssuedRequests)
721702
}
722703
}
723704
case <-ctx.Done():

0 commit comments

Comments
 (0)