MCPcopy
hub / github.com/grpc/grpc-go / TestRingPick

Method TestRingPick

balancer/ringhash/ring_test.go:85–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func (s) TestRingPick(t *testing.T) {
86 r := newRing(testEndpointStateMap, 10, 20, nil)
87 for _, h := range []uint64{xxhash.Sum64String("1"), xxhash.Sum64String("2"), xxhash.Sum64String("3"), xxhash.Sum64String("4")} {
88 t.Run(fmt.Sprintf("picking-hash-%v", h), func(t *testing.T) {
89 e := r.pick(h)
90 var low uint64
91 if e.idx > 0 {
92 low = r.items[e.idx-1].hash
93 }
94 high := e.hash
95 // h should be in [low, high).
96 if h < low || h >= high {
97 t.Fatalf("unexpected item picked, hash: %v, low: %v, high: %v", h, low, high)
98 }
99 })
100 }
101}
102
103func (s) TestRingNext(t *testing.T) {
104 r := newRing(testEndpointStateMap, 10, 20, nil)

Callers

nothing calls this directly

Calls 3

newRingFunction · 0.85
FatalfMethod · 0.65
pickMethod · 0.45

Tested by

no test coverage detected