Skip to content

Commit 5f6f416

Browse files
committed
Increment: Add test case for action type 'RouteActionNonForwardingAction'
+ Minor refactors
1 parent cd24581 commit 5f6f416

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

xds/internal/resolver/serviceconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type configSelector struct {
142142
}
143143

144144
var errNoMatchedRouteFound = status.Errorf(codes.Unavailable, "no matched route was found")
145-
var errMatchedRouteTypeNotRouteActionRoute = status.Errorf(codes.Unavailable, "matched route does not have a supported route type")
145+
var errUnsupportedClientRouteAction = status.Errorf(codes.Unavailable, "matched route does not have a supported route action type")
146146

147147
func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RPCConfig, error) {
148148
if cs == nil {
@@ -162,7 +162,7 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP
162162
}
163163

164164
if rt.actionType != xdsresource.RouteActionRoute {
165-
return nil, errMatchedRouteTypeNotRouteActionRoute
165+
return nil, errUnsupportedClientRouteAction
166166
}
167167

168168
cluster, ok := rt.clusters.Next().(*routeCluster)

xds/internal/resolver/xds_resolver_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,13 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) {
18281828
"B": {Weight: 1},
18291829
},
18301830
ActionType: xdsresource.RouteActionUnsupported,
1831+
}, {
1832+
Prefix: newStringP("2"),
1833+
WeightedClusters: map[string]xdsresource.WeightedCluster{
1834+
"A": {Weight: 1},
1835+
"B": {Weight: 1},
1836+
},
1837+
ActionType: xdsresource.RouteActionNonForwardingAction,
18311838
}},
18321839
},
18331840
},
@@ -1836,8 +1843,11 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) {
18361843
"1": {
18371844
{"build:foo1", "override:foo2", "build:bar1", "override:bar2", "newstream:foo1", "newstream:bar1", "done:bar1", "done:foo1"},
18381845
},
1846+
"2": {
1847+
{"build:foo1", "override:foo2", "build:bar1", "override:bar2", "newstream:foo1", "newstream:bar1", "done:bar1", "done:foo1"},
1848+
},
18391849
},
1840-
selectErr: errMatchedRouteTypeNotRouteActionRoute.Error(),
1850+
selectErr: errUnsupportedClientRouteAction.Error(),
18411851
},
18421852
{
18431853
name: "NewStream error; ensure earlier interceptor Done is still called",
@@ -1857,13 +1867,6 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) {
18571867
"B": {Weight: 1},
18581868
},
18591869
ActionType: xdsresource.RouteActionRoute,
1860-
}, {
1861-
Prefix: newStringP("2"),
1862-
WeightedClusters: map[string]xdsresource.WeightedCluster{
1863-
"A": {Weight: 1},
1864-
"B": {Weight: 1},
1865-
},
1866-
ActionType: xdsresource.RouteActionRoute,
18671870
}},
18681871
},
18691872
},
@@ -1872,9 +1875,6 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) {
18721875
"1": {
18731876
{"build:foo1", "build:bar1", "newstream:foo1", "newstream:bar1" /* <err in bar1 NewStream> */, "done:foo1"},
18741877
},
1875-
"2": {
1876-
{"build:foo1", "build:bar1", "newstream:foo1", "newstream:bar1" /* <err in bar1 NewSteam> */, "done:foo1"},
1877-
},
18781878
},
18791879
newStreamErr: "bar newstream err",
18801880
},

0 commit comments

Comments
 (0)