MCPcopy
hub / github.com/CodisLabs/codis / player

Method player

extern/deprecated/redis-test/extra_incr.go:55–93  ·  view source on GitHub ↗
(gid int, tg *TestGroup, tags *ZeroTags)

Source from the content-addressed store, hash-verified

53}
54
55func (tc *ExtraIncrTestCase) player(gid int, tg *TestGroup, tags *ZeroTags) {
56 tg.PlayerWait()
57 defer tg.PlayerDone()
58 c := NewConn(tc.proxy)
59 defer c.Close()
60 us := UnitSlice(make([]*Unit, tc.nkeys))
61 for i := 0; i < len(us); i++ {
62 key := fmt.Sprintf("extra_incr_%d_%d_tag{%s}", gid, i, tags.Get(i))
63 us[i] = NewUnit(key)
64 }
65 for _, u := range us {
66 u.Del(c, false)
67 ops.Incr()
68 }
69 for i := 0; i < tc.round; i++ {
70 for _, u := range us {
71 u.Incr(c)
72 ops.Incr()
73 }
74 }
75 time.Sleep(time.Second * 5)
76 c1s, c1m := NewConn(tc.slave1), NewConn(tc.master1)
77 c2s, c2m := NewConn(tc.slave2), NewConn(tc.master2)
78 defer c1s.Close()
79 defer c1m.Close()
80 defer c2s.Close()
81 defer c2m.Close()
82 for _, u := range us {
83 s := tc.groupfetch(c1s, c2s, u.key)
84 m := tc.groupfetch(c1m, c2m, u.key)
85 if s != m || s != u.val {
86 Panic("check failed, key = %s, val = %d, master = %d, slave = %d", u.key, u.val, s, m)
87 }
88 }
89 for _, u := range us {
90 u.Del(c, true)
91 ops.Incr()
92 }
93}
94
95func (tc *ExtraIncrTestCase) groupfetch(c1, c2 redis.Conn, key string) int {
96 r1, e1 := c1.Do("get", key)

Callers 1

mainMethod · 0.95

Calls 12

CloseMethod · 0.95
groupfetchMethod · 0.95
UnitSliceTypeAlias · 0.85
NewUnitFunction · 0.85
PlayerWaitMethod · 0.80
PlayerDoneMethod · 0.80
NewConnFunction · 0.70
PanicFunction · 0.70
SleepMethod · 0.65
GetMethod · 0.45
DelMethod · 0.45
IncrMethod · 0.45

Tested by

no test coverage detected