Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Aug 19, 2020
1 parent 79d7b1a commit 22bda0a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions p2c/least_loaded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func TestLeastLoaded(t *testing.T) {
t.Run("0 item", func(t *testing.T) {
ll := p2c.NewLeastLoaded()
ll.Reset()
item, done := ll.Next()
done(balancer.DoneInfo{})
assert.Nil(t, item)
Expand Down
1 change: 1 addition & 0 deletions p2c/pewma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestPeakEwma(t *testing.T) {

t.Run("1 item", func(t *testing.T) {
ll := NewPeakEwma()
ll.Reset()
ll.Add(1, 1)
item, done := ll.Next()
done(balancer.DoneInfo{})
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ func TestSW_Next(t *testing.T) {
if results["server1"] != 500 || results["server2"] != 200 || results["server3"] != 300 {
t.Error("the algorithm is wrong")
}

w.(*smoothRoundrobin).items[0].EffectiveWeight = w.(*smoothRoundrobin).items[0].CurrentWeight - 1
s, _ = w.Next()
assert.Equal(t, "server3", s.(string))
}

0 comments on commit 22bda0a

Please sign in to comment.