代码拉取完成,页面将自动刷新
package client
import (
"gitee.com/Gogo-gitee/registry"
"strconv"
"testing"
"time"
)
func TestDiscoveryNode(t *testing.T) {
hash := New(3, func(key []byte) uint32 {
i, _ := strconv.Atoi(string(key))
return uint32(i)
})
exit := make(chan struct{})
zooKeeperRegistry := registry.ZooKeeperRegistry{
Host: []string{"118.25.250.196"},
}
DiscoveryNode("118.25.250.196", "/test", exit, hash)
zooKeeperRegistry.Register("/test", "6", nil)
zooKeeperRegistry.Register("/test", "2", nil)
zooKeeperRegistry.Register("/test", "4", nil)
time.Sleep(time.Millisecond * 1000)
testCases := map[string]string{
"2": "2",
"11": "2",
"23": "4",
"27": "2",
}
for k, v := range testCases {
if hash.Get(k) != v {
t.Errorf("Asking for %s, should have yielded %s,but got %v", k, v, hash.Get(k))
}
}
zooKeeperRegistry.Register("/test", "8", nil)
time.Sleep(time.Millisecond * 1000)
// 27 should now map to 8.
testCases["27"] = "8"
for k, v := range testCases {
if hash.Get(k) != v {
t.Errorf("Asking for %s, should have yielded %s", k, v)
}
}
exit <- struct{}{}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。