mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-15 02:40:01 +08:00
chore: refactor
This commit is contained in:
@@ -93,17 +93,6 @@ func TestConsistentHashTransferOnFailure(t *testing.T) {
|
|||||||
assert.True(t, ratio < 2.5/keySize, fmt.Sprintf("%d: %f", index, ratio))
|
assert.True(t, ratio < 2.5/keySize, fmt.Sprintf("%d: %f", index, ratio))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTransferRatioOnFailure(t *testing.T, index int) float32 {
|
|
||||||
keys, newKeys := getKeysBeforeAndAfterFailure(t, "localhost:", index)
|
|
||||||
var transferred int
|
|
||||||
for k, v := range newKeys {
|
|
||||||
if v != keys[k] {
|
|
||||||
transferred++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return float32(transferred) / float32(requestSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestConsistentHashLeastTransferOnFailure(t *testing.T) {
|
func TestConsistentHashLeastTransferOnFailure(t *testing.T) {
|
||||||
prefix := "localhost:"
|
prefix := "localhost:"
|
||||||
index := 13
|
index := 13
|
||||||
@@ -170,6 +159,17 @@ func getKeysBeforeAndAfterFailure(t *testing.T, prefix string, index int) (map[i
|
|||||||
return keys, newKeys
|
return keys, newKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTransferRatioOnFailure(t *testing.T, index int) float32 {
|
||||||
|
keys, newKeys := getKeysBeforeAndAfterFailure(t, "localhost:", index)
|
||||||
|
var transferred int
|
||||||
|
for k, v := range newKeys {
|
||||||
|
if v != keys[k] {
|
||||||
|
transferred++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return float32(transferred) / float32(requestSize)
|
||||||
|
}
|
||||||
|
|
||||||
type mockNode struct {
|
type mockNode struct {
|
||||||
addr string
|
addr string
|
||||||
id int
|
id int
|
||||||
|
|||||||
Reference in New Issue
Block a user