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

Function TestGroupCache

pkg/topom/topom_cache_test.go:46–91  ·  view source on GitHub ↗
(x *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestGroupCache(x *testing.T) {
47 t := openTopom()
48 defer t.Close()
49
50 const gid = 100
51
52 check := func(exists bool, state string) {
53 ctx, err := t.newContext()
54 assert.MustNoError(err)
55 if !exists {
56 assert.Must(ctx.group[gid] == nil)
57 } else {
58 g, err := ctx.getGroup(gid)
59 assert.MustNoError(err)
60 assert.Must(g.Id == gid && g.Promoting.State == state)
61 }
62 }
63
64 g := &models.Group{Id: gid}
65 check(false, "")
66
67 t.dirtyGroupCache(gid)
68 check(false, "")
69
70 t.dirtyGroupCache(gid)
71 assert.MustNoError(t.storeCreateGroup(g))
72 check(true, models.ActionNothing)
73
74 t.dirtyGroupCache(gid)
75 g.Promoting.State = models.ActionPreparing
76 check(true, models.ActionNothing)
77
78 t.dirtyGroupCache(gid)
79 g.Promoting.State = models.ActionPreparing
80 assert.MustNoError(t.storeUpdateGroup(g))
81 check(true, models.ActionPreparing)
82
83 t.dirtyCacheAll()
84 g.Promoting.State = models.ActionPrepared
85 assert.MustNoError(t.storeUpdateGroup(g))
86 check(true, models.ActionPrepared)
87
88 t.dirtyGroupCache(gid)
89 assert.MustNoError(t.storeRemoveGroup(g))
90 check(false, "")
91}
92
93func TestProxyCache(x *testing.T) {
94 t := openTopom()

Callers

nothing calls this directly

Calls 9

openTopomFunction · 0.85
getGroupMethod · 0.80
dirtyGroupCacheMethod · 0.80
storeCreateGroupMethod · 0.80
storeUpdateGroupMethod · 0.80
dirtyCacheAllMethod · 0.80
storeRemoveGroupMethod · 0.80
CloseMethod · 0.65
newContextMethod · 0.45

Tested by

no test coverage detected