TestServerSideXDS_RouteConfiguration is an e2e test which verifies routing functionality. The xDS enabled server will be set up with route configuration where the route configuration has routes with the correct routing actions (NonForwardingAction), and the RPC's matching those routes should proceed
(t *testing.T)
| 62 | // (NonForwardingAction), and the RPC's matching those routes should proceed as |
| 63 | // normal. |
| 64 | func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { |
| 65 | managementServer, nodeID, bootstrapContents, xdsResolver := setup.ManagementServerAndResolver(t) |
| 66 | |
| 67 | lis, cleanup2 := setupGRPCServer(t, bootstrapContents) |
| 68 | defer cleanup2() |
| 69 | |
| 70 | host, port, err := hostPortFromListener(lis) |
| 71 | if err != nil { |
| 72 | t.Fatalf("failed to retrieve host and port of server: %v", err) |
| 73 | } |
| 74 | const serviceName = "my-service-fallback" |
| 75 | resources := e2e.DefaultClientResources(e2e.ResourceParams{ |
| 76 | DialTarget: serviceName, |
| 77 | NodeID: nodeID, |
| 78 | Host: host, |
| 79 | Port: port, |
| 80 | SecLevel: e2e.SecurityLevelNone, |
| 81 | }) |
| 82 | |
| 83 | // Create an inbound xDS listener resource with route configuration which |
| 84 | // selectively will allow RPC's through or not. This will test routing in |
| 85 | // xds(Unary|Stream)Interceptors. |
| 86 | vhs := []*v3routepb.VirtualHost{ |
| 87 | // Virtual host that will never be matched to test Virtual Host selection. |
| 88 | { |
| 89 | Domains: []string{"this will not match*"}, |
| 90 | Routes: []*v3routepb.Route{ |
| 91 | { |
| 92 | Match: &v3routepb.RouteMatch{ |
| 93 | PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/"}, |
| 94 | }, |
| 95 | Action: &v3routepb.Route_NonForwardingAction{}, |
| 96 | }, |
| 97 | }, |
| 98 | }, |
| 99 | // This Virtual Host will actually get matched to. |
| 100 | { |
| 101 | Domains: []string{"*"}, |
| 102 | Routes: []*v3routepb.Route{ |
| 103 | // A routing rule that can be selectively triggered based on properties about incoming RPC. |
| 104 | { |
| 105 | Match: &v3routepb.RouteMatch{ |
| 106 | PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/EmptyCall"}, |
| 107 | // "Fully-qualified RPC method name with leading slash. Same as :path header". |
| 108 | }, |
| 109 | // Correct Action, so RPC's that match this route should proceed to interceptor processing. |
| 110 | Action: &v3routepb.Route_NonForwardingAction{}, |
| 111 | }, |
| 112 | // This routing rule is matched the same way as the one above, |
| 113 | // except has an incorrect action for the server side. However, |
| 114 | // since routing chooses the first route which matches an |
| 115 | // incoming RPC, this should never get invoked (iteration |
| 116 | // through this route slice is deterministic). |
| 117 | { |
| 118 | Match: &v3routepb.RouteMatch{ |
| 119 | PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/EmptyCall"}, |
| 120 | // "Fully-qualified RPC method name with leading slash. Same as :path header". |
| 121 | }, |
nothing calls this directly
no test coverage detected