diff --git a/xds/internal/test/xds_server_integration_test.go b/xds/internal/test/xds_server_integration_test.go index 65abc90e19a..d39b728b126 100644 --- a/xds/internal/test/xds_server_integration_test.go +++ b/xds/internal/test/xds_server_integration_test.go @@ -439,7 +439,9 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { // "Fully-qualified RPC method name with leading slash. Same as :path header". }, // Incorrect Action, so RPC's that match this route should get denied. - Action: &v3routepb.Route_Route{}, + Action: &v3routepb.Route_Route{ + Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}}, + }, }, // Another routing rule that can be selectively triggered based on incoming RPC. { @@ -447,7 +449,9 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/UnaryCall"}, }, // Wrong action (!Non_Forwarding_Action) so RPC's that match this route should get denied. - Action: &v3routepb.Route_Route{}, + Action: &v3routepb.Route_Route{ + Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}}, + }, }, // Another routing rule that can be selectively triggered based on incoming RPC. { @@ -455,7 +459,9 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/StreamingInputCall"}, }, // Wrong action (!Non_Forwarding_Action) so RPC's that match this route should get denied. - Action: &v3routepb.Route_Route{}, + Action: &v3routepb.Route_Route{ + Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}}, + }, }, // Not matching route, this is be able to get invoked logically (i.e. doesn't have to match the Route configurations above). }}, diff --git a/xds/internal/xdsclient/rds_test.go b/xds/internal/xdsclient/rds_test.go index f5f906375c7..ca87c0b9771 100644 --- a/xds/internal/xdsclient/rds_test.go +++ b/xds/internal/xdsclient/rds_test.go @@ -1231,6 +1231,20 @@ func (s) TestRoutesProtoToSlice(t *testing.T) { }, wantErr: true, }, + { + name: "unsupported cluster specifier", + routes: []*v3routepb.Route{ + { + Match: &v3routepb.RouteMatch{ + PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/a/"}, + }, + Action: &v3routepb.Route_Route{ + Route: &v3routepb.RouteAction{ + ClusterSpecifier: &v3routepb.RouteAction_ClusterSpecifierPlugin{}}}, + }, + }, + wantErr: true, + }, { name: "default totalWeight is 100 in weighted clusters action", routes: []*v3routepb.Route{ diff --git a/xds/internal/xdsclient/xds.go b/xds/internal/xdsclient/xds.go index 6b172ac8aa2..28070d88cd5 100644 --- a/xds/internal/xdsclient/xds.go +++ b/xds/internal/xdsclient/xds.go @@ -564,6 +564,8 @@ func routesProtoToSlice(routes []*v3routepb.Route, logger *grpclog.PrefixLogger, } case *v3routepb.RouteAction_ClusterHeader: continue + default: + return nil, fmt.Errorf("route %+v, has an unknown ClusterSpecifier: %+v", r, a) } msd := action.GetMaxStreamDuration()