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

Method TestConfigUpdate_BadChildPolicyConfigs

balancer/rls/balancer_test.go:521–558  ·  view source on GitHub ↗

TestConfigUpdate_BadChildPolicyConfigs tests the scenario where a config update is rejected by the child policy. Verifies that the child policy wrapper goes "lame" and the error from the child policy is reported back to the caller of the RPC.

(t *testing.T)

Source from the content-addressed store, hash-verified

519// wrapper goes "lame" and the error from the child policy is reported back to
520// the caller of the RPC.
521func (s) TestConfigUpdate_BadChildPolicyConfigs(t *testing.T) {
522 // Start an RLS server and set the throttler to never throttle requests.
523 rlsServer, rlsReqCh := rlstest.SetupFakeRLSServer(t, nil)
524 overrideAdaptiveThrottler(t, neverThrottlingThrottler())
525
526 // Set up the RLS server to respond with a bad target field which is expected
527 // to cause the child policy's ParseTarget to fail and should result in the LB
528 // policy creating a lame child policy wrapper.
529 rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
530 return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{e2e.RLSChildPolicyBadTarget}}}
531 })
532
533 // Build RLS service config with a default target. This default backend is
534 // expected to be healthy (even though we don't attempt to route RPCs to it)
535 // and ensures that the overall connectivity state of the RLS LB policy is not
536 // TRANSIENT_FAILURE. This is required to make sure that the pick for the bad
537 // child policy actually gets delegated to the child policy picker.
538 rlsConfig := buildBasicRLSConfigWithChildPolicy(t, t.Name(), rlsServer.Address)
539 _, addr := startBackend(t)
540 rlsConfig.RouteLookupConfig.DefaultTarget = addr
541
542 // Register a manual resolver and push the RLS service config through it.
543 r := startManualResolverWithConfig(t, rlsConfig)
544
545 cc, err := grpc.NewClient(r.Scheme()+":///", grpc.WithResolvers(r), grpc.WithTransportCredentials(insecure.NewCredentials()))
546 if err != nil {
547 t.Fatalf("Failed to create gRPC client: %v", err)
548 }
549 defer cc.Close()
550
551 // Make an RPC and ensure that if fails with the expected error.
552 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
553 defer cancel()
554 makeTestRPCAndVerifyError(ctx, t, cc, codes.Unavailable, e2e.ErrParseConfigBadTarget)
555
556 // Make sure an RLS request is sent out.
557 verifyRLSRequest(t, rlsReqCh, true)
558}
559
560// TestConfigUpdate_DataCacheSizeDecrease tests the scenario where a config
561// update decreases the data cache size. Verifies that entries are evicted from

Callers

nothing calls this directly

Calls 15

NewClientFunction · 0.92
WithResolversFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
neverThrottlingThrottlerFunction · 0.85
startBackendFunction · 0.85
verifyRLSRequestFunction · 0.85
SetResponseCallbackMethod · 0.80

Tested by

no test coverage detected