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

Function testRingAndEndpointStates

balancer/ringhash/picker_test.go:76–102  ·  view source on GitHub ↗
(states []connectivity.State)

Source from the content-addressed store, hash-verified

74}
75
76func testRingAndEndpointStates(states []connectivity.State) (*ring, map[string]endpointState) {
77 var items []*ringEntry
78 epStates := map[string]endpointState{}
79 for i, st := range states {
80 testSC := testSubConns[i]
81 items = append(items, &ringEntry{
82 idx: i,
83 hash: math.MaxUint64 / uint64(len(states)) * uint64(i),
84 hashKey: testSC.String(),
85 })
86 epState := endpointState{
87 state: balancer.State{
88 ConnectivityState: st,
89 Picker: &fakeChildPicker{
90 connectivityState: st,
91 tfError: fmt.Errorf("%d: %w", i, errPicker),
92 subConn: testSC,
93 },
94 },
95 balancer: &fakeExitIdler{
96 sc: testSC,
97 },
98 }
99 epStates[testSC.String()] = epState
100 }
101 return &ring{items: items}, epStates
102}
103
104func (s) TestPickerPickFirstTwo(t *testing.T) {
105 tests := []struct {

Callers 4

TestPickerRandomHashMethod · 0.85

Calls 2

StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected