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

Method TestEndpoints_MultipleAddresses

interop/orcalb_test.go:182–220  ·  view source on GitHub ↗

TestEndpoints_MultipleAddresses verifies client behavior when an endpoint has multiple addresses and the first is unreachable. It validates that the pick_first falls through the address list and connects via the first reachable address, so per-call ORCA reports flow correctly.

(t *testing.T)

Source from the content-addressed store, hash-verified

180// pick_first falls through the address list and connects via the first
181// reachable address, so per-call ORCA reports flow correctly.
182func (s) TestEndpoints_MultipleAddresses(t *testing.T) {
183 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
184 defer cancel()
185
186 srv := startORCAServer(t)
187 if err := srv.StartClient(grpc.WithDefaultServiceConfig(orcaSvcConfig())); err != nil {
188 t.Fatalf("Error starting client: %v", err)
189 }
190
191 // First address is unreachable; pick_first falls through to the good one.
192 state := resolver.State{
193 Endpoints: []resolver.Endpoint{
194 {Addresses: []resolver.Address{
195 {Addr: "bad-address"},
196 {Addr: srv.Address},
197 }},
198 },
199 }
200 srv.R.UpdateState(state)
201 // Transient errors while pick_first probes the bad address are expected.
202 want := &v3orcapb.OrcaLoadReport{CpuUtilization: 0.42, MemUtilization: 0.21}
203 for ; ctx.Err() == nil; <-time.After(100 * time.Millisecond) {
204 orcaRes := &v3orcapb.OrcaLoadReport{}
205 req := &testpb.SimpleRequest{
206 OrcaPerQueryReport: &testpb.TestOrcaReport{
207 CpuUtilization: 0.42,
208 MemoryUtilization: 0.21,
209 },
210 }
211 if _, err := srv.Client.UnaryCall(contextWithORCAResult(ctx, &orcaRes), req); err != nil {
212 continue
213 }
214 if diff := cmp.Diff(orcaRes, want, protocmp.Transform()); diff != "" {
215 t.Fatalf("Per-RPC ORCA mismatch (-got +want):\n%s", diff)
216 }
217 return
218 }
219 t.Fatalf("timed out waiting for connection through good address")
220}
221
222// TestMultipleEndpoints_OOBListeners verifies that N endpoints produce N
223// independent pick_first instances and N independent OOB listeners, each

Callers

nothing calls this directly

Calls 9

WithDefaultServiceConfigFunction · 0.92
startORCAServerFunction · 0.85
orcaSvcConfigFunction · 0.85
contextWithORCAResultFunction · 0.85
StartClientMethod · 0.80
ErrMethod · 0.80
FatalfMethod · 0.65
UpdateStateMethod · 0.65
UnaryCallMethod · 0.65

Tested by

no test coverage detected