Skip to content

Commit

Permalink
opt lb unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglei28 committed Nov 7, 2024
1 parent dee077b commit bbfcc98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lb/weightRoundRobinLb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestWeightRingSelector(t *testing.T) {
// max node size of WR
checkKWR(t, lb, 256, 15, round, 1, 1, 0, url)

// same nodes are unavailable
// some nodes are unavailable
maxRatio := 0.4
avgRatio := 0.1
checkKWR(t, lb, 46, 75, round, float64(round)*maxRatio, float64(round)*avgRatio, 5, url)
Expand Down Expand Up @@ -322,6 +322,9 @@ func buildTestEps(size int, sameStaticWeight bool, maxWeight int64, adjust bool,
weight := maxWeight
if !sameStaticWeight {
weight = int64(rand.Float64() * float64(maxWeight))
if weight == 1 { //When the weight is 1, the difference ratio will be larger
weight += int64(rand.Float64() * float64(maxWeight-1))
}
}
if adjust {
weight = doAdjust(weight)
Expand Down

0 comments on commit bbfcc98

Please sign in to comment.