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

Function TestProxyStats

pkg/topom/topom_stats_test.go:19–65  ·  view source on GitHub ↗
(x *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestProxyStats(x *testing.T) {
20 t := openTopom()
21 defer t.Close()
22
23 check := func(succ, fail []string) {
24 w, err := t.RefreshProxyStats(time.Second * 5)
25 assert.MustNoError(err)
26 m := w.Wait()
27 assert.Must(len(m) == len(succ)+len(fail))
28 for _, t := range succ {
29 s, ok := m[t].(*ProxyStats)
30 assert.Must(ok && s != nil && s.Stats != nil)
31 }
32 for _, t := range fail {
33 s, ok := m[t].(*ProxyStats)
34 assert.Must(ok && s != nil && s.Stats == nil)
35 assert.Must(s.Error != nil)
36 }
37 }
38
39 p1, c1 := openProxy()
40 defer c1.Shutdown()
41
42 p2, c2 := openProxy()
43 defer c2.Shutdown()
44
45 contextCreateProxy(t, p1)
46 check([]string{p1.Token}, []string{})
47
48 contextCreateProxy(t, p2)
49 check([]string{p1.Token, p2.Token}, []string{})
50
51 assert.MustNoError(c1.Shutdown())
52 check([]string{p2.Token}, []string{p1.Token})
53
54 assert.MustNoError(c2.Shutdown())
55 check([]string{}, []string{p1.Token, p2.Token})
56
57 p3, c3 := openProxy()
58 defer c3.Shutdown()
59
60 contextCreateProxy(t, p3)
61 check([]string{p3.Token}, []string{p1.Token, p2.Token})
62
63 contextRemoveProxy(t, p1)
64 check([]string{p3.Token}, []string{p2.Token})
65}
66
67func TestRedisStats(x *testing.T) {
68 t := openTopom()

Callers

nothing calls this directly

Calls 8

openTopomFunction · 0.85
contextCreateProxyFunction · 0.85
contextRemoveProxyFunction · 0.85
RefreshProxyStatsMethod · 0.80
openProxyFunction · 0.70
CloseMethod · 0.65
WaitMethod · 0.45
ShutdownMethod · 0.45

Tested by

no test coverage detected