|
|
|
@ -13,9 +13,9 @@ func TestServerList(t *testing.T) {
|
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
|
|
|
|
|
list := NewServerList()
|
|
|
|
|
list.AddServer(NewServerSpec(nil, v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(1)), AlwaysValid()))
|
|
|
|
|
list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(1)), AlwaysValid()))
|
|
|
|
|
assert.Uint32(list.Size()).Equals(1)
|
|
|
|
|
list.AddServer(NewServerSpec(nil, v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(2)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(2)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
assert.Uint32(list.Size()).Equals(2)
|
|
|
|
|
|
|
|
|
|
server := list.GetServer(1)
|
|
|
|
@ -32,9 +32,9 @@ func TestServerPicker(t *testing.T) {
|
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
|
|
|
|
|
list := NewServerList()
|
|
|
|
|
list.AddServer(NewServerSpec(nil, v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(1)), AlwaysValid()))
|
|
|
|
|
list.AddServer(NewServerSpec(nil, v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(2)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
list.AddServer(NewServerSpec(nil, v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(3)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(1)), AlwaysValid()))
|
|
|
|
|
list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(2)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(3)), BeforeTime(time.Now().Add(time.Second))))
|
|
|
|
|
|
|
|
|
|
picker := NewRoundRobinServerPicker(list)
|
|
|
|
|
server := picker.PickServer()
|
|
|
|
|