MCPcopy Create free account
hub / github.com/facebook/time / TestPopAllQueue

Function TestPopAllQueue

cmd/ziffy/node/sender_test.go:28–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestPopAllQueue(t *testing.T) {
29 s := Sender{
30 Config: &Config{QueueCap: 10000},
31 }
32 numInfos := 5
33 numRoutes := 2
34
35 s.inputQueue = make([]chan *SwitchTrafficInfo, numRoutes)
36
37 s.inputQueue[0] = make(chan *SwitchTrafficInfo, s.Config.QueueCap)
38 s.inputQueue[1] = make(chan *SwitchTrafficInfo, s.Config.QueueCap)
39
40 routes := []*PathInfo{
41 {switches: nil},
42 {switches: nil},
43 }
44
45 for i := 0; i <= numInfos; i++ {
46 routeIdx := i % numRoutes
47 s.inputQueue[routeIdx] <- &SwitchTrafficInfo{
48 hop: i,
49 routeIdx: routeIdx,
50 }
51 }
52 s.popAllQueue(routes)
53
54 require.Equal(t, 0, routes[0].switches[0].hop)
55 require.Equal(t, 2, routes[0].switches[1].hop)
56 require.Equal(t, 4, routes[0].switches[2].hop)
57
58 require.Equal(t, 1, routes[1].switches[0].hop)
59 require.Equal(t, 3, routes[1].switches[1].hop)
60 require.Equal(t, 5, routes[1].switches[2].hop)
61}
62
63func TestClearPaths(t *testing.T) {
64 s := Sender{

Callers

nothing calls this directly

Calls 1

popAllQueueMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…