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

Method TestORCAOOBFallback

interop/orcalb_test.go:132–176  ·  view source on GitHub ↗

TestORCAOOBFallback verifies the fallback behavior: when a per-call report is present but has all zero fields, the picker uses the most recent OOB report instead.

(t *testing.T)

Source from the content-addressed store, hash-verified

130// is present but has all zero fields, the picker uses the most recent OOB
131// report instead.
132func (s) TestORCAOOBFallback(t *testing.T) {
133 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
134 defer cancel()
135
136 srv := startORCAServer(t)
137 if err := srv.StartClient(grpc.WithDefaultServiceConfig(orcaSvcConfig())); err != nil {
138 t.Fatalf("Error starting client: %v", err)
139 }
140
141 stream, err := srv.Client.FullDuplexCall(ctx)
142 if err != nil {
143 t.Fatalf("FullDuplexCall failed: %v", err)
144 }
145 req := &testpb.StreamingOutputCallRequest{
146 OrcaOobReport: &testpb.TestOrcaReport{
147 CpuUtilization: 0.73,
148 MemoryUtilization: 0.55,
149 Utilization: map[string]float64{"util": 0.42},
150 },
151 ResponseParameters: []*testpb.ResponseParameters{{Size: 1}},
152 }
153 if err := stream.Send(req); err != nil {
154 t.Fatalf("stream.Send failed: %v", err)
155 }
156 if _, err := stream.Recv(); err != nil {
157 t.Fatalf("stream.Recv failed: %v", err)
158 }
159
160 oobWant := &v3orcapb.OrcaLoadReport{
161 CpuUtilization: 0.73,
162 MemUtilization: 0.55,
163 Utilization: map[string]float64{"util": 0.42},
164 }
165 pollORCAResult(ctx, t, srv.Client, oobWant)
166
167 // OrcaPerQueryReport is nil: per-call report has all-zero fields,
168 // triggering the OOB fallback path in orcaPicker.
169 orcaRes := &v3orcapb.OrcaLoadReport{}
170 if _, err := srv.Client.UnaryCall(contextWithORCAResult(ctx, &orcaRes), &testpb.SimpleRequest{}); err != nil {
171 t.Fatalf("UnaryCall failed: %v", err)
172 }
173 if diff := cmp.Diff(orcaRes, oobWant, protocmp.Transform()); diff != "" {
174 t.Fatalf("ORCA load report with zero per-call mismatch (-got +want):\n%s", diff)
175 }
176}
177
178// TestEndpoints_MultipleAddresses verifies client behavior when an endpoint has
179// multiple addresses and the first is unreachable. It validates that the

Callers

nothing calls this directly

Calls 11

WithDefaultServiceConfigFunction · 0.92
startORCAServerFunction · 0.85
orcaSvcConfigFunction · 0.85
pollORCAResultFunction · 0.85
contextWithORCAResultFunction · 0.85
StartClientMethod · 0.80
FatalfMethod · 0.65
FullDuplexCallMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65
UnaryCallMethod · 0.65

Tested by

no test coverage detected