-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet_test.go
More file actions
55 lines (44 loc) · 1002 Bytes
/
Copy pathnet_test.go
File metadata and controls
55 lines (44 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package vault
import (
"testing"
"github.com/stretchr/testify/assert"
)
func genWarehouse() Warehouse {
whr := &SimpleWarehouse{}
whr.Add("dummy://node0")
whr.Add("dummy://node1")
whr.Add("dummy://node2")
//whr.Add("redis://127.0.0.1:6379")
//whr.Add("redis://127.0.0.1:6380")
//whr.Add("redis://127.0.0.1:6381")
return whr
}
func TestWriteRead(t *testing.T) {
whr := genWarehouse()
net := &netImpl{wr: whr}
err := net.Put("qwe", []byte("1234567890"), 2)
assert.NoError(t, err)
data, err := net.Get("qwe")
assert.NoError(t, err)
assert.Equal(t, "1234567890", string(data))
var redundancy = 0
for _, nd := range whr.All() {
items, err := nd.List()
assert.NoError(t, err)
if len(items) > 0 {
redundancy++
}
}
assert.Equal(t, 2, redundancy)
err = net.Sync(3)
assert.NoError(t, err)
redundancy = 0
for _, nd := range whr.All() {
items, err := nd.List()
assert.NoError(t, err)
if len(items) > 0 {
redundancy++
}
}
assert.Equal(t, 3, redundancy)
}