@@ -3344,52 +3344,60 @@ func TestBuildAdditions(t *testing.T) {
3344
3344
func TestCreatePassthroughServers (t * testing.T ) {
3345
3345
testGraph := graph.Graph {
3346
3346
Gateway : & graph.Gateway {
3347
- Listeners : make ([]* graph.Listener , 0 , 1 ),
3348
- },
3349
- }
3350
- l4routes := make (map [graph.L4RouteKey ]* graph.L4Route )
3351
-
3352
- nsname := types.NamespacedName {
3353
- Namespace : "default" ,
3354
- Name : "secure-app" ,
3355
- }
3356
-
3357
- key := graph.L4RouteKey {NamespacedName : nsname }
3358
- l4routes [key ] = & graph.L4Route {
3359
- Spec : graph.L4RouteSpec {
3360
- Hostnames : []v1.Hostname {"app.example.com" , "cafe.example.com" },
3361
- BackendRef : graph.BackendRef {
3362
- SvcNsName : nsname ,
3363
- ServicePort : apiv1.ServicePort {
3364
- Name : "https" ,
3365
- Protocol : "TCP" ,
3366
- AppProtocol : nil ,
3367
- Port : 8443 ,
3368
- TargetPort : intstr.IntOrString {
3369
- Type : intstr .Int ,
3370
- IntVal : 8443 ,
3347
+ Listeners : []* graph.Listener {
3348
+ {
3349
+ Name : "testingListener" ,
3350
+ Source : v1.Listener {
3351
+ Protocol : v1 .TLSProtocolType ,
3352
+ Port : 443 ,
3353
+ },
3354
+ Routes : make (map [graph.RouteKey ]* graph.L7Route ),
3355
+ L4Routes : map [graph.L4RouteKey ]* graph.L4Route {
3356
+ {NamespacedName : types.NamespacedName {
3357
+ Namespace : "default" ,
3358
+ Name : "secure-app" ,
3359
+ }}: {
3360
+ Spec : graph.L4RouteSpec {
3361
+ Hostnames : []v1.Hostname {"app.example.com" , "cafe.example.com" },
3362
+ BackendRef : graph.BackendRef {
3363
+ SvcNsName : types.NamespacedName {
3364
+ Namespace : "default" ,
3365
+ Name : "secure-app" ,
3366
+ },
3367
+ ServicePort : apiv1.ServicePort {
3368
+ Name : "https" ,
3369
+ Protocol : "TCP" ,
3370
+ Port : 8443 ,
3371
+ TargetPort : intstr.IntOrString {
3372
+ Type : intstr .Int ,
3373
+ IntVal : 8443 ,
3374
+ },
3375
+ },
3376
+ Valid : true ,
3377
+ },
3378
+ },
3379
+ Valid : true ,
3380
+ },
3381
+ {NamespacedName : types.NamespacedName {
3382
+ Namespace : "default" ,
3383
+ Name : "secure-app2" ,
3384
+ }}: {},
3385
+ {NamespacedName : types.NamespacedName {
3386
+ Namespace : "default" ,
3387
+ Name : "secure-app3" ,
3388
+ }}: {
3389
+ Valid : true ,
3390
+ Spec : graph.L4RouteSpec {
3391
+ Hostnames : []v1.Hostname {"test.example.com" },
3392
+ BackendRef : graph.BackendRef {},
3393
+ },
3394
+ },
3371
3395
},
3396
+ Valid : true ,
3372
3397
},
3373
- Valid : true ,
3374
3398
},
3375
3399
},
3376
- Valid : true ,
3377
3400
}
3378
- testGraph .Gateway .Listeners = append (testGraph .Gateway .Listeners , & graph.Listener {
3379
- Name : "testingListener" ,
3380
- Source : v1.Listener {
3381
- Protocol : v1 .TLSProtocolType ,
3382
- Port : 443 ,
3383
- },
3384
- Routes : make (map [graph.RouteKey ]* graph.L7Route ),
3385
- L4Routes : l4routes ,
3386
- AllowedRouteLabelSelector : nil ,
3387
- ResolvedSecret : nil ,
3388
- Conditions : nil ,
3389
- SupportedKinds : nil ,
3390
- Valid : true ,
3391
- Attachable : false ,
3392
- })
3393
3401
3394
3402
passthroughServers := buildPassthroughServers (& testGraph )
3395
3403
@@ -3414,61 +3422,95 @@ func TestCreatePassthroughServers(t *testing.T) {
3414
3422
func TestBuildStreamUpstreams (t * testing.T ) {
3415
3423
testGraph := graph.Graph {
3416
3424
Gateway : & graph.Gateway {
3417
- Listeners : make ([]* graph.Listener , 0 , 1 ),
3418
- },
3419
- }
3420
- l4routes := make (map [graph.L4RouteKey ]* graph.L4Route )
3421
-
3422
- nsname := types.NamespacedName {
3423
- Namespace : "default" ,
3424
- Name : "secure-app" ,
3425
- }
3426
-
3427
- key := graph.L4RouteKey {NamespacedName : nsname }
3428
- l4routes [key ] = & graph.L4Route {
3429
- Spec : graph.L4RouteSpec {
3430
- Hostnames : []v1.Hostname {"app.example.com" , "cafe.example.com" },
3431
- BackendRef : graph.BackendRef {
3432
- SvcNsName : nsname ,
3433
- ServicePort : apiv1.ServicePort {
3434
- Name : "https" ,
3435
- Protocol : "TCP" ,
3436
- AppProtocol : nil ,
3437
- Port : 8443 ,
3438
- TargetPort : intstr.IntOrString {
3439
- Type : intstr .Int ,
3440
- IntVal : 8443 ,
3425
+ Listeners : []* graph.Listener {
3426
+ {
3427
+ Name : "testingListener" ,
3428
+ Source : v1.Listener {
3429
+ Protocol : v1 .TLSProtocolType ,
3430
+ Port : 443 ,
3441
3431
},
3432
+ Routes : make (map [graph.RouteKey ]* graph.L7Route ),
3433
+ L4Routes : map [graph.L4RouteKey ]* graph.L4Route {
3434
+ {NamespacedName : types.NamespacedName {
3435
+ Namespace : "default" ,
3436
+ Name : "secure-app" ,
3437
+ }}: {
3438
+ Spec : graph.L4RouteSpec {
3439
+ Hostnames : []v1.Hostname {"app.example.com" , "cafe.example.com" },
3440
+ BackendRef : graph.BackendRef {
3441
+ SvcNsName : types.NamespacedName {
3442
+ Namespace : "default" ,
3443
+ Name : "secure-app" ,
3444
+ },
3445
+ ServicePort : apiv1.ServicePort {
3446
+ Name : "https" ,
3447
+ Protocol : "TCP" ,
3448
+ Port : 8443 ,
3449
+ TargetPort : intstr.IntOrString {
3450
+ Type : intstr .Int ,
3451
+ IntVal : 8443 ,
3452
+ },
3453
+ },
3454
+ Valid : true ,
3455
+ },
3456
+ },
3457
+ Valid : true ,
3458
+ },
3459
+ {NamespacedName : types.NamespacedName {
3460
+ Namespace : "default" ,
3461
+ Name : "secure-app2" ,
3462
+ }}: {},
3463
+ {NamespacedName : types.NamespacedName {
3464
+ Namespace : "default" ,
3465
+ Name : "secure-app3" ,
3466
+ }}: {
3467
+ Valid : true ,
3468
+ Spec : graph.L4RouteSpec {
3469
+ Hostnames : []v1.Hostname {"test.example.com" },
3470
+ BackendRef : graph.BackendRef {},
3471
+ },
3472
+ },
3473
+ {NamespacedName : types.NamespacedName {
3474
+ Namespace : "default" ,
3475
+ Name : "secure-app4" ,
3476
+ }}: {
3477
+ Spec : graph.L4RouteSpec {
3478
+ Hostnames : []v1.Hostname {"app.example.com" , "cafe.example.com" },
3479
+ BackendRef : graph.BackendRef {
3480
+ SvcNsName : types.NamespacedName {
3481
+ Namespace : "default" ,
3482
+ Name : "secure-app" ,
3483
+ },
3484
+ ServicePort : apiv1.ServicePort {
3485
+ Name : "https" ,
3486
+ Protocol : "TCP" ,
3487
+ Port : 8443 ,
3488
+ TargetPort : intstr.IntOrString {
3489
+ Type : intstr .Int ,
3490
+ IntVal : 8443 ,
3491
+ },
3492
+ },
3493
+ Valid : true ,
3494
+ },
3495
+ },
3496
+ Valid : true ,
3497
+ },
3498
+ },
3499
+ Valid : true ,
3442
3500
},
3443
- Valid : true ,
3444
3501
},
3445
3502
},
3446
- Valid : true ,
3447
3503
}
3448
3504
3449
3505
fakeResolver := resolverfakes.FakeServiceResolver {}
3450
- fakeResolver .ResolveReturns (nil , nil )
3451
- testGraph .Gateway .Listeners = append (testGraph .Gateway .Listeners , & graph.Listener {
3452
- Name : "testingListener" ,
3453
- Source : v1.Listener {
3454
- Protocol : v1 .TLSProtocolType ,
3455
- Port : 443 ,
3456
- },
3457
- Routes : make (map [graph.RouteKey ]* graph.L7Route ),
3458
- L4Routes : l4routes ,
3459
- AllowedRouteLabelSelector : nil ,
3460
- ResolvedSecret : nil ,
3461
- Conditions : nil ,
3462
- SupportedKinds : nil ,
3463
- Valid : true ,
3464
- Attachable : false ,
3465
- })
3506
+ fakeResolver .ResolveReturns (nil , errors .New ("error" ))
3466
3507
3467
3508
streamUpstreams := buildStreamUpstreams (context .Background (), testGraph .Gateway .Listeners , & fakeResolver )
3468
3509
3469
3510
expectedStreamUpstreams := []Upstream {
3470
3511
{
3471
- Name : "default_secure-app_8443" ,
3512
+ Name : "default_secure-app_8443" ,
3513
+ ErrorMsg : "error" ,
3472
3514
},
3473
3515
}
3474
3516
g := NewWithT (t )
0 commit comments