Skip to content

Commit 7cf7e44

Browse files
author
auxten
committed
fix consistent test
1 parent 9c9654c commit 7cf7e44

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

consistent/consistent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func InitConsistent(storePath string, initBP bool) (c *Consistent, err error) {
9999
return
100100
}
101101
c = &Consistent{
102+
//TODO(auxten): reduce NumberOfReplicas
102103
NumberOfReplicas: 20,
103104
circle: make(map[proto.NodeKey]proto.Node),
104105
}

consistent/consistent_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func TestNew(t *testing.T) {
5656
if x == nil {
5757
t.Errorf("expected obj")
5858
}
59-
utils.CheckNum(x.NumberOfReplicas, 20, t)
6059
}
6160

6261
func TestAdd(t *testing.T) {
@@ -67,14 +66,14 @@ func TestAdd(t *testing.T) {
6766
x, _ := InitConsistent(testStorePath, false)
6867
defer os.Remove(testStorePath)
6968
x.Add(NewNodeFromID("abcdefg"))
70-
utils.CheckNum(len(x.circle), 20, t)
71-
utils.CheckNum(len(x.sortedHashes), 20, t)
69+
utils.CheckNum(len(x.circle), x.NumberOfReplicas, t)
70+
utils.CheckNum(len(x.sortedHashes), x.NumberOfReplicas, t)
7271
if sort.IsSorted(x.sortedHashes) == false {
7372
t.Errorf("expected sorted hashes to be sorted")
7473
}
7574
x.Add(NewNodeFromID(("qwer")))
76-
utils.CheckNum(len(x.circle), 40, t)
77-
utils.CheckNum(len(x.sortedHashes), 40, t)
75+
utils.CheckNum(len(x.circle), 2*x.NumberOfReplicas, t)
76+
utils.CheckNum(len(x.sortedHashes), 2*x.NumberOfReplicas, t)
7877
if sort.IsSorted(x.sortedHashes) == false {
7978
t.Errorf("expected sorted hashes to be sorted")
8079
}
@@ -102,7 +101,7 @@ func TestRemoveNonExisting(t *testing.T) {
102101
defer os.Remove(testStorePath)
103102
x.Add(NewNodeFromID("abcdefg"))
104103
x.Remove("abcdefghijk")
105-
utils.CheckNum(len(x.circle), 20, t)
104+
utils.CheckNum(len(x.circle), x.NumberOfReplicas, t)
106105
}
107106

108107
func TestGetEmpty(t *testing.T) {

0 commit comments

Comments
 (0)