@@ -250,6 +250,49 @@ func TestMergeLowestTunnelMTU(t *testing.T) {
250250 }
251251}
252252
253+ func TestLearnedGatewayTransitPathCaps (t * testing.T ) {
254+ path := []unboundednetv1alpha1.GatewayNodePathHop {
255+ {Type : "Site" , Name : "site-b" },
256+ {Type : "GatewayPool" , Name : "pool-h" },
257+ {Type : "GatewayPool" , Name : "pool-j" },
258+ {Type : "GatewayPool" , Name : "pool-g" },
259+ }
260+ routes := map [string ]unboundednetv1alpha1.GatewayNodeRoute {
261+ "10.0.0.0/24" : {Paths : [][]unboundednetv1alpha1.GatewayNodePathHop {path }},
262+ }
263+
264+ for _ , tc := range []struct {
265+ name string
266+ sites map [string ]int
267+ pools map [string ]int
268+ assignments []unboundednetv1alpha1.SiteGatewayPoolAssignment
269+ peerings []unboundednetv1alpha1.GatewayPoolPeering
270+ want int
271+ }{
272+ {name : "origin Site" , sites : map [string ]int {"site-b" : 1200 , "unrelated" : 900 }, want : 1200 },
273+ {name : "downstream pool" , pools : map [string ]int {"pool-h" : 1250 , "unrelated" : 900 }, want : 1250 },
274+ {name : "assignment edge" , assignments : []unboundednetv1alpha1.SiteGatewayPoolAssignment {
275+ {Spec : unboundednetv1alpha1.SiteGatewayPoolAssignmentSpec {Sites : []string {"site-b" }, GatewayPools : []string {"pool-h" }, TunnelMTU : ptrInt32 (1100 )}},
276+ }, want : 1100 },
277+ {name : "assignment nonadjacent" , assignments : []unboundednetv1alpha1.SiteGatewayPoolAssignment {
278+ {Spec : unboundednetv1alpha1.SiteGatewayPoolAssignmentSpec {Sites : []string {"site-b" }, GatewayPools : []string {"pool-g" }, TunnelMTU : ptrInt32 (1100 )}},
279+ }},
280+ {name : "adjacent peering" , peerings : []unboundednetv1alpha1.GatewayPoolPeering {
281+ {Spec : unboundednetv1alpha1.GatewayPoolPeeringSpec {GatewayPools : []string {"pool-h" , "pool-j" }, TunnelMTU : ptrInt32 (1300 )}},
282+ }, want : 1300 },
283+ {name : "nonadjacent peering" , peerings : []unboundednetv1alpha1.GatewayPoolPeering {
284+ {Spec : unboundednetv1alpha1.GatewayPoolPeeringSpec {GatewayPools : []string {"pool-h" , "pool-g" }, TunnelMTU : ptrInt32 (1000 )}},
285+ }},
286+ } {
287+ t .Run (tc .name , func (t * testing.T ) {
288+ got := learnedGatewayTransitTunnelMTU (routes , tc .sites , tc .pools , tc .assignments , tc .peerings )
289+ if got != tc .want {
290+ t .Fatalf ("transit MTU=%d want=%d" , got , tc .want )
291+ }
292+ })
293+ }
294+ }
295+
253296func TestForwardingAwareTunnelMTU (t * testing.T ) {
254297 siteMTUs := map [string ]int {
255298 "site-a" : 1450 ,
@@ -296,11 +339,11 @@ func TestForwardingAwareTunnelMTU(t *testing.T) {
296339 }},
297340 },
298341 }
299- if got := learnedGatewayTransitTunnelMTU ("pool-g" , learnedRoutes , []unboundednetv1alpha1.GatewayPoolPeering {peering }); got != 1200 {
342+ if got := learnedGatewayTransitTunnelMTU (learnedRoutes , nil , nil , nil , []unboundednetv1alpha1.GatewayPoolPeering {peering }); got != 1200 {
300343 t .Fatalf ("worker learned gateway transit MTU = %d, want 1200" , got )
301344 }
302345
303- if got := learnedGatewayTransitTunnelMTU ("pool-g" , nil , []unboundednetv1alpha1.GatewayPoolPeering {peering }); got != 0 {
346+ if got := learnedGatewayTransitTunnelMTU (nil , nil , nil , nil , []unboundednetv1alpha1.GatewayPoolPeering {peering }); got != 0 {
304347 t .Fatalf ("gateway peering without a learned forwarding path constrained worker MTU: %d" , got )
305348 }
306349
0 commit comments