@@ -182,27 +182,12 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
182182 },
183183 },
184184 {
185- // TODO:
186185 name : "Delete LatticeService" ,
187186 wantIsDeleted : true ,
188187 wantErrIsNil : true ,
189188 gwClass : vpcLatticeGatewayClass ,
190189 gws : []gwv1.Gateway {
191- {
192- ObjectMeta : metav1.ObjectMeta {
193- Name : "gateway2" ,
194- Namespace : "ns1" ,
195- },
196- Spec : gwv1.GatewaySpec {
197- Listeners : []gwv1.Listener {
198- {
199- Name : httpSectionName ,
200- Port : 80 ,
201- Protocol : "HTTP" ,
202- },
203- },
204- },
205- },
190+ vpcLatticeGateway ,
206191 },
207192 route : core .NewHTTPRoute (gwv1.HTTPRoute {
208193 ObjectMeta : metav1.ObjectMeta {
@@ -215,7 +200,8 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
215200 CommonRouteSpec : gwv1.CommonRouteSpec {
216201 ParentRefs : []gwv1.ParentReference {
217202 {
218- Name : "gateway2" ,
203+ Name : gwv1 .ObjectName (vpcLatticeGateway .Name ),
204+ Namespace : namespacePtr (vpcLatticeGateway .Namespace ),
219205 SectionName : & httpSectionName ,
220206 },
221207 },
@@ -240,7 +226,7 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
240226 RouteNamespace : "ns1" ,
241227 RouteType : core .HttpRouteType ,
242228 },
243- ServiceNetworkNames : []string {"gateway2" },
229+ ServiceNetworkNames : []string {vpcLatticeGateway . Name },
244230 },
245231 },
246232 {
@@ -252,6 +238,7 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
252238 {
253239 ObjectMeta : vpcLatticeGateway .ObjectMeta ,
254240 Spec : gwv1.GatewaySpec {
241+ GatewayClassName : gwv1 .ObjectName (vpcLatticeGatewayClass .Name ),
255242 Listeners : []gwv1.Listener {
256243 {
257244 Name : "tls" ,
@@ -329,6 +316,7 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
329316 {
330317 ObjectMeta : vpcLatticeGateway .ObjectMeta ,
331318 Spec : gwv1.GatewaySpec {
319+ GatewayClassName : gwv1 .ObjectName (vpcLatticeGatewayClass .Name ),
332320 Listeners : []gwv1.Listener {
333321 {
334322 Name : "tls" ,
@@ -376,6 +364,15 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
376364 gwClass : vpcLatticeGatewayClass ,
377365 gws : []gwv1.Gateway {
378366 vpcLatticeGateway ,
367+ {
368+ ObjectMeta : metav1.ObjectMeta {
369+ Name : "gateway2" ,
370+ Namespace : "ns2" ,
371+ },
372+ Spec : gwv1.GatewaySpec {
373+ GatewayClassName : gwv1 .ObjectName (vpcLatticeGatewayClass .Name ),
374+ },
375+ },
379376 },
380377 route : core .NewHTTPRoute (gwv1.HTTPRoute {
381378 ObjectMeta : metav1.ObjectMeta {
@@ -406,45 +403,55 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
406403 ServiceNetworkNames : []string {vpcLatticeGateway .Name , "gateway2" },
407404 },
408405 },
409- //{
410- // name: "Multiple service networks with one different controller",
411- // wantIsDeleted: false,
412- // wantErrIsNil: true,
413- // gw: gwv1.Gateway{
414- // ObjectMeta: metav1.ObjectMeta{
415- // Name: "gateway1",
416- // Namespace: "default",
417- // },
418- // },
419- // route: core.NewHTTPRoute(gwv1.HTTPRoute{
420- // ObjectMeta: metav1.ObjectMeta{
421- // Name: "service1",
422- // Namespace: "default",
423- // },
424- // Spec: gwv1.HTTPRouteSpec{
425- // CommonRouteSpec: gwv1.CommonRouteSpec{
426- // ParentRefs: []gwv1.ParentReference{
427- // {
428- // Name: "gateway1",
429- // Namespace: namespacePtr("default"),
430- // },
431- // {
432- // Name: "not-lattice",
433- // Namespace: namespacePtr("ns2"),
434- // },
435- // },
436- // },
437- // },
438- // }),
439- // expected: model.ServiceSpec{
440- // ServiceTagFields: model.ServiceTagFields{
441- // RouteName: "service1",
442- // RouteNamespace: "default",
443- // RouteType: core.HttpRouteType,
444- // },
445- // ServiceNetworkNames: []string{"gateway1"},
446- // },
447- //},
406+ {
407+ name : "Multiple service networks with one different controller" ,
408+ wantIsDeleted : false ,
409+ wantErrIsNil : true ,
410+ gwClass : vpcLatticeGatewayClass ,
411+ gws : []gwv1.Gateway {
412+ vpcLatticeGateway ,
413+ // managed by different controller gateway
414+ {
415+ ObjectMeta : metav1.ObjectMeta {
416+ Name : "not-lattice" ,
417+ Namespace : "ns2" ,
418+ },
419+ Spec : gwv1.GatewaySpec {
420+ GatewayClassName : gwv1 .ObjectName ("not-lattice-gwClass" ),
421+ },
422+ },
423+ },
424+ route : core .NewHTTPRoute (gwv1.HTTPRoute {
425+ ObjectMeta : metav1.ObjectMeta {
426+ Name : "service1" ,
427+ Namespace : "default" ,
428+ },
429+ Spec : gwv1.HTTPRouteSpec {
430+ CommonRouteSpec : gwv1.CommonRouteSpec {
431+ // has two parent refs and one is not managed by lattice
432+ ParentRefs : []gwv1.ParentReference {
433+ {
434+ Name : gwv1 .ObjectName (vpcLatticeGateway .Name ),
435+ Namespace : namespacePtr (vpcLatticeGateway .Namespace ),
436+ },
437+ {
438+ Name : "not-lattice" ,
439+ Namespace : namespacePtr ("ns2" ),
440+ },
441+ },
442+ },
443+ },
444+ }),
445+ expected : model.ServiceSpec {
446+ ServiceTagFields : model.ServiceTagFields {
447+ RouteName : "service1" ,
448+ RouteNamespace : "default" ,
449+ RouteType : core .HttpRouteType ,
450+ },
451+ // only the lattice gateway is added
452+ ServiceNetworkNames : []string {vpcLatticeGateway .Name },
453+ },
454+ },
448455 }
449456
450457 for _ , tt := range tests {
0 commit comments