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

Method TestControlChannelThrottled

balancer/rls/control_channel_test.go:48–68  ·  view source on GitHub ↗

TestControlChannelThrottled tests the case where the adaptive throttler indicates that the control channel needs to be throttled.

(t *testing.T)

Source from the content-addressed store, hash-verified

46// TestControlChannelThrottled tests the case where the adaptive throttler
47// indicates that the control channel needs to be throttled.
48func (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.
71func (s) TestLookupFailure(t *testing.T) {

Callers

nothing calls this directly

Calls 7

newControlChannelFunction · 0.85
FatalfMethod · 0.65
FatalMethod · 0.65
closeMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected