(t *testing.T)
| 303 | } |
| 304 | |
| 305 | func testDoneLoads(t *testing.T) { |
| 306 | b := &testBalancer{} |
| 307 | balancer.Register(b) |
| 308 | |
| 309 | const testLoad = "test-load-,-should-be-orca" |
| 310 | |
| 311 | ss := &stubserver.StubServer{ |
| 312 | EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
| 313 | grpc.SetTrailer(ctx, metadata.Pairs(loadMDKey, testLoad)) |
| 314 | return &testpb.Empty{}, nil |
| 315 | }, |
| 316 | } |
| 317 | if err := ss.Start(nil, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, testBalancerName))); err != nil { |
| 318 | t.Fatalf("error starting testing server: %v", err) |
| 319 | } |
| 320 | defer ss.Stop() |
| 321 | |
| 322 | tc := testgrpc.NewTestServiceClient(ss.CC) |
| 323 | |
| 324 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 325 | defer cancel() |
| 326 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil { |
| 327 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, %v", err, nil) |
| 328 | } |
| 329 | |
| 330 | piWant := []balancer.PickInfo{ |
| 331 | {FullMethodName: "/grpc.testing.TestService/EmptyCall"}, |
| 332 | } |
| 333 | if !reflect.DeepEqual(b.pickInfos, piWant) { |
| 334 | t.Fatalf("b.pickInfos = %v; want %v", b.pickInfos, piWant) |
| 335 | } |
| 336 | |
| 337 | if len(b.doneInfo) < 1 { |
| 338 | t.Fatalf("b.doneInfo = %v, want length 1", b.doneInfo) |
| 339 | } |
| 340 | gotLoad, _ := b.doneInfo[0].ServerLoad.(string) |
| 341 | if gotLoad != testLoad { |
| 342 | t.Fatalf("b.doneInfo[0].ServerLoad = %v; want = %v", b.doneInfo[0].ServerLoad, testLoad) |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | type aiPicker struct { |
| 347 | result balancer.PickResult |
no test coverage detected