(t *testing.T, sopts []grpc.ServerOption, bopts balancer.BuildOptions, wantCode codes.Code, wantErrRegex *regexp.Regexp)
| 351 | } |
| 352 | |
| 353 | func testControlChannelCredsFailure(t *testing.T, sopts []grpc.ServerOption, bopts balancer.BuildOptions, wantCode codes.Code, wantErrRegex *regexp.Regexp) { |
| 354 | // StartFakeRouteLookupServer a fake server. |
| 355 | // |
| 356 | // Start an RLS server and set the throttler to never throttle requests. The |
| 357 | // creds failures happen before the RPC handler on the server is invoked. |
| 358 | // So, there is need to setup the request and responses on the fake server. |
| 359 | rlsServer, _ := rlstest.SetupFakeRLSServer(t, nil, sopts...) |
| 360 | overrideAdaptiveThrottler(t, neverThrottlingThrottler()) |
| 361 | |
| 362 | // Create the control channel to the fake server. |
| 363 | ctrlCh, err := newControlChannel(rlsServer.Address, "", defaultTestTimeout, bopts, nil) |
| 364 | if err != nil { |
| 365 | t.Fatalf("Failed to create control channel to RLS server: %v", err) |
| 366 | } |
| 367 | defer ctrlCh.close() |
| 368 | |
| 369 | // Perform the lookup and expect the callback to be invoked with an error. |
| 370 | errCh := make(chan error, 1) |
| 371 | ctrlCh.lookup(nil, rlspb.RouteLookupRequest_REASON_MISS, staleHeaderData, func(_ []string, _ string, err error) { |
| 372 | if st, ok := status.FromError(err); !ok || st.Code() != wantCode || !wantErrRegex.MatchString(st.String()) { |
| 373 | errCh <- fmt.Errorf("rlsClient.lookup() returned error: %v, wantCode: %v, wantErr: %s", err, wantCode, wantErrRegex.String()) |
| 374 | return |
| 375 | } |
| 376 | errCh <- nil |
| 377 | }) |
| 378 | |
| 379 | select { |
| 380 | case <-time.After(defaultTestTimeout): |
| 381 | t.Fatal("timeout when waiting for lookup callback to be invoked") |
| 382 | case err := <-errCh: |
| 383 | if err != nil { |
| 384 | t.Fatal(err) |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | // TestControlChannelCredsFailure tests creation of the control channel with |
| 390 | // different credentials, which are expected to fail. |
no test coverage detected