@@ -146,7 +146,78 @@ func (s) TestBuildXDSClientConfig_Success(t *testing.T) {
146146 }` , testXDSServerURL , testNodeID )),
147147 wantXDSClientConfig : func (c * bootstrap.Config ) xdsclient.Config {
148148 node , serverCfg := c .Node (), c .XDSServers ()[0 ]
149- expectedServer := xdsclient.ServerConfig {ServerIdentifier : clients.ServerIdentifier {ServerURI : serverCfg .ServerURI (), Extensions : grpctransport.ServerIdentifierExtension {ConfigName : "insecure" }}, IgnoreResourceDeletion : true }
149+ serverFeature := xdsclient .ServerFeatureIgnoreResourceDeletion
150+ expectedServer := xdsclient.ServerConfig {
151+ ServerIdentifier : clients.ServerIdentifier {ServerURI : serverCfg .ServerURI (), Extensions : grpctransport.ServerIdentifierExtension {ConfigName : "insecure" }},
152+ ServerFeature : serverFeature }
153+ gServerCfgMap := map [xdsclient.ServerConfig ]* bootstrap.ServerConfig {expectedServer : serverCfg }
154+ return xdsclient.Config {
155+ Servers : []xdsclient.ServerConfig {expectedServer },
156+ Node : clients.Node {ID : node .GetId (), Cluster : node .GetCluster (), Metadata : node .Metadata , UserAgentName : node .UserAgentName , UserAgentVersion : node .GetUserAgentVersion ()},
157+ Authorities : map [string ]xdsclient.Authority {},
158+ ResourceTypes : map [string ]xdsclient.ResourceType {
159+ version .V3ListenerURL : {TypeURL : version .V3ListenerURL , TypeName : xdsresource .ListenerResourceTypeName , AllResourcesRequiredInSotW : true , Decoder : xdsresource .NewListenerResourceTypeDecoder (c )},
160+ version .V3RouteConfigURL : {TypeURL : version .V3RouteConfigURL , TypeName : xdsresource .RouteConfigTypeName , AllResourcesRequiredInSotW : false , Decoder : xdsresource .NewRouteConfigResourceTypeDecoder (c )},
161+ version .V3ClusterURL : {TypeURL : version .V3ClusterURL , TypeName : xdsresource .ClusterResourceTypeName , AllResourcesRequiredInSotW : true , Decoder : xdsresource .NewClusterResourceTypeDecoder (c , gServerCfgMap )},
162+ version .V3EndpointsURL : {TypeURL : version .V3EndpointsURL , TypeName : xdsresource .EndpointsResourceTypeName , AllResourcesRequiredInSotW : false , Decoder : xdsresource .NewEndpointsResourceTypeDecoder (c )},
163+ },
164+ MetricsReporter : & metricsReporter {recorder : stats .NewTestMetricsRecorder (), target : testTargetName },
165+ TransportBuilder : grpctransport .NewBuilder (map [string ]grpctransport.Config {
166+ "insecure" : {
167+ Credentials : insecure .NewBundle (),
168+ GRPCNewClient : func (target string , opts ... grpc.DialOption ) (* grpc.ClientConn , error ) {
169+ opts = append (opts , serverCfg .DialOptions ()... )
170+ return grpc .NewClient (target , opts ... )
171+ }},
172+ }),
173+ }
174+ },
175+ },
176+ {
177+ name : "server features with trusted_xds_server" ,
178+ bootstrapContents : []byte (fmt .Sprintf (`{
179+ "xds_servers": [{"server_uri": "%s", "channel_creds": [{"type": "insecure"}], "server_features": ["trusted_xds_server"]}],
180+ "node": {"id": "%s"}
181+ }` , testXDSServerURL , testNodeID )),
182+ wantXDSClientConfig : func (c * bootstrap.Config ) xdsclient.Config {
183+ node , serverCfg := c .Node (), c .XDSServers ()[0 ]
184+ serverFeature := xdsclient .ServerFeatureTrustedXDSServer
185+ expectedServer := xdsclient.ServerConfig {ServerIdentifier : clients.ServerIdentifier {ServerURI : serverCfg .ServerURI (), Extensions : grpctransport.ServerIdentifierExtension {ConfigName : "insecure" }},
186+ ServerFeature : serverFeature }
187+ gServerCfgMap := map [xdsclient.ServerConfig ]* bootstrap.ServerConfig {expectedServer : serverCfg }
188+ return xdsclient.Config {
189+ Servers : []xdsclient.ServerConfig {expectedServer },
190+ Node : clients.Node {ID : node .GetId (), Cluster : node .GetCluster (), Metadata : node .Metadata , UserAgentName : node .UserAgentName , UserAgentVersion : node .GetUserAgentVersion ()},
191+ Authorities : map [string ]xdsclient.Authority {},
192+ ResourceTypes : map [string ]xdsclient.ResourceType {
193+ version .V3ListenerURL : {TypeURL : version .V3ListenerURL , TypeName : xdsresource .ListenerResourceTypeName , AllResourcesRequiredInSotW : true , Decoder : xdsresource .NewListenerResourceTypeDecoder (c )},
194+ version .V3RouteConfigURL : {TypeURL : version .V3RouteConfigURL , TypeName : xdsresource .RouteConfigTypeName , AllResourcesRequiredInSotW : false , Decoder : xdsresource .NewRouteConfigResourceTypeDecoder (c )},
195+ version .V3ClusterURL : {TypeURL : version .V3ClusterURL , TypeName : xdsresource .ClusterResourceTypeName , AllResourcesRequiredInSotW : true , Decoder : xdsresource .NewClusterResourceTypeDecoder (c , gServerCfgMap )},
196+ version .V3EndpointsURL : {TypeURL : version .V3EndpointsURL , TypeName : xdsresource .EndpointsResourceTypeName , AllResourcesRequiredInSotW : false , Decoder : xdsresource .NewEndpointsResourceTypeDecoder (c )},
197+ },
198+ MetricsReporter : & metricsReporter {recorder : stats .NewTestMetricsRecorder (), target : testTargetName },
199+ TransportBuilder : grpctransport .NewBuilder (map [string ]grpctransport.Config {
200+ "insecure" : {
201+ Credentials : insecure .NewBundle (),
202+ GRPCNewClient : func (target string , opts ... grpc.DialOption ) (* grpc.ClientConn , error ) {
203+ opts = append (opts , serverCfg .DialOptions ()... )
204+ return grpc .NewClient (target , opts ... )
205+ }},
206+ }),
207+ }
208+ },
209+ },
210+ {
211+ name : "server features with ignore_resource_deletion and trusted_xds_server" ,
212+ bootstrapContents : []byte (fmt .Sprintf (`{
213+ "xds_servers": [{"server_uri": "%s", "channel_creds": [{"type": "insecure"}], "server_features": ["ignore_resource_deletion", "trusted_xds_server"]}],
214+ "node": {"id": "%s"}
215+ }` , testXDSServerURL , testNodeID )),
216+ wantXDSClientConfig : func (c * bootstrap.Config ) xdsclient.Config {
217+ node , serverCfg := c .Node (), c .XDSServers ()[0 ]
218+ serverFeature := xdsclient .ServerFeatureTrustedXDSServer | xdsclient .ServerFeatureIgnoreResourceDeletion
219+ expectedServer := xdsclient.ServerConfig {ServerIdentifier : clients.ServerIdentifier {ServerURI : serverCfg .ServerURI (), Extensions : grpctransport.ServerIdentifierExtension {ConfigName : "insecure" }},
220+ ServerFeature : serverFeature }
150221 gServerCfgMap := map [xdsclient.ServerConfig ]* bootstrap.ServerConfig {expectedServer : serverCfg }
151222 return xdsclient.Config {
152223 Servers : []xdsclient.ServerConfig {expectedServer },
0 commit comments