Skip to content

Commit

Permalink
add weighted_lb feature
Browse files Browse the repository at this point in the history
  • Loading branch information
liangwei3 committed Apr 3, 2024
1 parent 7af8144 commit cae619f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lb/weightRoundRobinLb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func TestRoundRobinSelector(t *testing.T) {
func checkRR(t *testing.T, lb *WeightRoundRobinLB, size int, initialMaxWeight int64,
round int, expectMaxDelta float64, expectAvgDelta float64, unavailableSize int, url *core.URL) {
eps := buildTestDynamicEpsWithUnavailable(size, true, initialMaxWeight, true, unavailableSize, url)
rand.Seed(time.Now().UnixNano())
eps = core.EndpointShuffle(eps)
lb.OnRefresh(eps)
_, ok := lb.getSelector().(*roundRobinSelector)
Expand Down Expand Up @@ -213,6 +214,7 @@ func TestWeightRingSelector(t *testing.T) {
func checkKWR(t *testing.T, lb *WeightRoundRobinLB, size int, initialMaxWeight int64,
round int, expectMaxDelta float64, expectAvgDelta float64, unavailableSize int, url *core.URL) {
eps := buildTestDynamicEpsWithUnavailable(size, false, initialMaxWeight, true, unavailableSize, url)
rand.Seed(time.Now().UnixNano())
eps = core.EndpointShuffle(eps)
lb.OnRefresh(eps)
_, ok := lb.getSelector().(*weightedRingSelector)
Expand Down Expand Up @@ -256,6 +258,7 @@ func TestSlidingWindowWeightedRoundRobinSelector(t *testing.T) {
func checkSWWRR(t *testing.T, lb *WeightRoundRobinLB, size int, initialMaxWeight int64,
round int, expectMaxDelta float64, expectAvgDelta float64, unavailableSize int, url *core.URL) {
eps := buildTestDynamicEpsWithUnavailable(size, false, initialMaxWeight, true, unavailableSize, url)
rand.Seed(time.Now().UnixNano())
eps = core.EndpointShuffle(eps)
lb.OnRefresh(eps)
_, ok := lb.getSelector().(*slidingWindowWeightedRoundRobinSelector)
Expand Down

0 comments on commit cae619f

Please sign in to comment.