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

Function TestGroupE2E

internal/hierarchy/hierarchy_ext_test.go:136–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

134}
135
136func TestGroupE2E(t *testing.T) {
137 testHierarchy := map[string]map[string][]string{
138 "p0": {
139 "wt0": {"addr0", "addr1"},
140 "wt1": {"addr2", "addr3"},
141 },
142 "p1": {
143 "wt10": {"addr10", "addr11"},
144 "wt11": {"addr12", "addr13"},
145 },
146 }
147
148 var epsWithHierarchy []resolver.Endpoint
149 for p, wts := range testHierarchy {
150 path1 := []string{p}
151 for wt, addrs := range wts {
152 path2 := append([]string(nil), path1...)
153 path2 = append(path2, wt)
154 for _, addr := range addrs {
155 a := hierarchy.SetInEndpoint(resolver.Endpoint{Addresses: []resolver.Address{{Addr: addr}}}, path2)
156 epsWithHierarchy = append(epsWithHierarchy, a)
157 }
158 }
159 }
160
161 gotHierarchy := make(map[string]map[string][]string)
162 for p1, wts := range hierarchy.Group(epsWithHierarchy) {
163 gotHierarchy[p1] = make(map[string][]string)
164 for p2, eps := range hierarchy.Group(wts) {
165 for _, ep := range eps {
166 gotHierarchy[p1][p2] = append(gotHierarchy[p1][p2], ep.Addresses[0].Addr)
167 }
168 }
169 }
170
171 if !cmp.Equal(gotHierarchy, testHierarchy) {
172 t.Errorf("diff: %v", cmp.Diff(gotHierarchy, testHierarchy))
173 }
174}

Callers

nothing calls this directly

Calls 4

SetInEndpointFunction · 0.92
GroupFunction · 0.92
EqualMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected