TestControlChannelThrottled tests the case where the adaptive throttler indicates that the control channel needs to be throttled.
(t *testing.T)
| 46 | // TestControlChannelThrottled tests the case where the adaptive throttler |
| 47 | // indicates that the control channel needs to be throttled. |
| 48 | func (s) TestControlChannelThrottled(t *testing.T) { |
| 49 | // Start an RLS server and set the throttler to always throttle requests. |
| 50 | rlsServer, rlsReqCh := rlstest.SetupFakeRLSServer(t, nil) |
| 51 | overrideAdaptiveThrottler(t, alwaysThrottlingThrottler()) |
| 52 | |
| 53 | // Create a control channel to the fake RLS server. |
| 54 | ctrlCh, err := newControlChannel(rlsServer.Address, "", defaultTestTimeout, balancer.BuildOptions{}, nil) |
| 55 | if err != nil { |
| 56 | t.Fatalf("Failed to create control channel to RLS server: %v", err) |
| 57 | } |
| 58 | defer ctrlCh.close() |
| 59 | |
| 60 | // Perform the lookup and expect the attempt to be throttled. |
| 61 | ctrlCh.lookup(nil, rlspb.RouteLookupRequest_REASON_MISS, staleHeaderData, nil) |
| 62 | |
| 63 | select { |
| 64 | case <-rlsReqCh: |
| 65 | t.Fatal("RouteLookup RPC invoked when control channel is throttled") |
| 66 | case <-time.After(defaultTestShortTimeout): |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // TestLookupFailure tests the case where the RLS server responds with an error. |
| 71 | func (s) TestLookupFailure(t *testing.T) { |
nothing calls this directly
no test coverage detected