// Package balance... // // Description : balance... // // Author : go_developer@163.com<白茶清欢> // // Date : 2021-10-19 2:39 下午 package balance import ( "fmt" "testing" "git.zhangdeman.cn/zhangdeman/gopkg/balance/define" ) // TestPoll_GetServerNode 轮询模式负载均衡单测 // // Author : go_developer@163.com<白茶清欢> // // Date : 2:39 下午 2021/10/19 func TestPoll_GetServerNode(t *testing.T) { t.Run("轮询模式负载均衡单元测试", func(t *testing.T) { p, _ := NewPoll([]*define.ServerNode{ {HostIP: "127.0.0.1", Port: 80, Status: 0, Weight: 0}, {HostIP: "127.0.0.1", Port: 81, Status: 0, Weight: 0}, {HostIP: "127.0.0.1", Port: 82, Status: 0, Weight: 0}, }) for i := 0; i < 100; i++ { got, err := p.GetServerNode() if nil != err { fmt.Println(err) return } fmt.Printf("%s:%d\n", got.HostIP, got.Port) } }) }