-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathcmd_cluster_test.go
More file actions
82 lines (70 loc) · 1.59 KB
/
cmd_cluster_test.go
File metadata and controls
82 lines (70 loc) · 1.59 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package miniredis
import (
"fmt"
"strconv"
"testing"
"github.com/alicebob/miniredis/v2/proto"
)
// Test CLUSTER *.
func TestCluster(t *testing.T) {
s, c := runWithClient(t)
t.Run("slots", func(t *testing.T) {
port, err := strconv.Atoi(s.Port())
ok(t, err)
mustDo(t, c,
"CLUSTER", "SLOTS",
proto.Array(
proto.Array(
proto.Int(0),
proto.Int(16383),
proto.Array(
proto.String(s.Host()),
proto.Int(port),
proto.String("09dbe9720cda62f7865eabc5fd8857c5d2678366"),
),
),
),
)
})
t.Run("nodes", func(t *testing.T) {
mustDo(t, c,
"CLUSTER", "NODES",
proto.String(fmt.Sprintf("e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca %s:%s@%s myself,master - 0 0 1 connected 0-16383", s.Host(), s.Port(), s.Port())),
)
})
t.Run("shards", func(t *testing.T) {
mustDo(t, c,
"CLUSTER", "SHARDS",
proto.Array(
proto.Array(
proto.String("slots"), proto.Array(
proto.Int(0),
proto.Int(16383),
),
proto.String("nodes"), proto.Array(
proto.Array(
proto.String("id"),
proto.String("13f84e686106847b76671957dd348fde540a77bb"),
proto.String("ip"),
proto.String(s.srv.Addr().IP.String()),
proto.String("port"),
proto.Int(s.srv.Addr().Port),
proto.String("role"),
proto.String("master"),
proto.String("replication-offset"),
proto.Int(0),
proto.String("health"),
proto.String("online"),
),
),
),
),
)
})
t.Run("keyslot", func(t *testing.T) {
mustDo(t, c,
"CLUSTER", "keyslot", "{test_key}",
proto.Int(163),
)
})
}