From bbfcc9801c20ff74a4c4ee39cf5243411e365017 Mon Sep 17 00:00:00 2001 From: zhanglei28 Date: Thu, 7 Nov 2024 10:25:06 +0800 Subject: [PATCH] opt lb unit test --- lb/weightRoundRobinLb_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lb/weightRoundRobinLb_test.go b/lb/weightRoundRobinLb_test.go index 370563d4..c94c61fd 100644 --- a/lb/weightRoundRobinLb_test.go +++ b/lb/weightRoundRobinLb_test.go @@ -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) @@ -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)