@@ -262,10 +262,9 @@ func TestBuildConfiguration(t *testing.T) {
262
262
secretPath := "/etc/nginx/secrets/secret"
263
263
264
264
tests := []struct {
265
- graph * graph.Graph
266
- expWarns Warnings
267
- msg string
268
- expConf Configuration
265
+ graph * graph.Graph
266
+ msg string
267
+ expConf Configuration
269
268
}{
270
269
{
271
270
graph : & graph.Graph {
@@ -371,15 +370,6 @@ func TestBuildConfiguration(t *testing.T) {
371
370
"invalid-listener" : {
372
371
Source : invalidListener ,
373
372
Valid : false ,
374
- Routes : map [types.NamespacedName ]* graph.Route {
375
- {Namespace : "test" , Name : "https-hr-1" }: httpsRouteHR1 ,
376
- {Namespace : "test" , Name : "https-hr-2" }: httpsRouteHR2 ,
377
- },
378
- AcceptedHostnames : map [string ]struct {}{
379
- "foo.example.com" : {},
380
- "bar.example.com" : {},
381
- },
382
- SecretPath : "" ,
383
373
},
384
374
},
385
375
},
@@ -392,10 +382,6 @@ func TestBuildConfiguration(t *testing.T) {
392
382
HTTPServers : []VirtualServer {},
393
383
SSLServers : []VirtualServer {},
394
384
},
395
- expWarns : Warnings {
396
- httpsHR1 : []string {"cannot configure routes for listener invalid-listener; listener is invalid" },
397
- httpsHR2 : []string {"cannot configure routes for listener invalid-listener; listener is invalid" },
398
- },
399
385
msg : "invalid listener" ,
400
386
},
401
387
{
@@ -978,7 +964,7 @@ func TestBuildConfiguration(t *testing.T) {
978
964
979
965
for _ , test := range tests {
980
966
t .Run (test .msg , func (t * testing.T ) {
981
- result , warns := BuildConfiguration (context .TODO (), test .graph , fakeResolver )
967
+ result := BuildConfiguration (context .TODO (), test .graph , fakeResolver )
982
968
983
969
sort .Slice (result .BackendGroups , func (i , j int ) bool {
984
970
return result .BackendGroups [i ].GroupName () < result .BackendGroups [j ].GroupName ()
@@ -991,10 +977,6 @@ func TestBuildConfiguration(t *testing.T) {
991
977
if diff := cmp .Diff (test .expConf , result ); diff != "" {
992
978
t .Errorf ("BuildConfiguration() %q mismatch for configuration (-want +got):\n %s" , test .msg , diff )
993
979
}
994
-
995
- if diff := cmp .Diff (test .expWarns , warns ); diff != "" {
996
- t .Errorf ("BuildConfiguration() %q mismatch for warnings (-want +got):\n %s" , test .msg , diff )
997
- }
998
980
})
999
981
}
1000
982
}
@@ -1471,96 +1453,6 @@ func TestBuildBackendGroups(t *testing.T) {
1471
1453
g .Expect (result ).To (ConsistOf (expGroups ))
1472
1454
}
1473
1455
1474
- func TestBuildWarnings (t * testing.T ) {
1475
- createBackendRefs := func (names ... string ) []graph.BackendRef {
1476
- backends := make ([]graph.BackendRef , len (names ))
1477
- for idx , name := range names {
1478
- backends [idx ] = graph.BackendRef {Name : name }
1479
- }
1480
-
1481
- return backends
1482
- }
1483
-
1484
- createBackendGroup := func (sourceName string , backends []graph.BackendRef ) graph.BackendGroup {
1485
- return graph.BackendGroup {
1486
- Source : types.NamespacedName {Namespace : "test" , Name : sourceName },
1487
- Backends : backends ,
1488
- }
1489
- }
1490
-
1491
- hrBackendGroup0 := createBackendGroup (
1492
- "hr" ,
1493
- createBackendRefs ("" ), // empty backend name should be skipped
1494
- )
1495
-
1496
- hrBackendGroup1 := createBackendGroup (
1497
- "hr" ,
1498
- createBackendRefs ("dne" ),
1499
- )
1500
-
1501
- hrInvalidGroup := createBackendGroup (
1502
- "hr-invalid" ,
1503
- createBackendRefs ("invalid" ),
1504
- )
1505
-
1506
- hr := & v1beta1.HTTPRoute {ObjectMeta : metav1.ObjectMeta {Name : "hr" , Namespace : "test" }}
1507
- hrInvalid := & v1beta1.HTTPRoute {ObjectMeta : metav1.ObjectMeta {Name : "hr-invalid" , Namespace : "test" }}
1508
-
1509
- invalidRoutes := map [types.NamespacedName ]* graph.Route {
1510
- {Name : "invalid" , Namespace : "test" }: {
1511
- Source : hrInvalid ,
1512
- Rules : groupsToValidRules (hrInvalidGroup ),
1513
- },
1514
- }
1515
-
1516
- routes := map [types.NamespacedName ]* graph.Route {
1517
- {Name : "hr" , Namespace : "test" }: {
1518
- Source : hr ,
1519
- Rules : groupsToValidRules (hrBackendGroup0 , hrBackendGroup1 ),
1520
- },
1521
- }
1522
-
1523
- upstreamMap := map [string ]Upstream {
1524
- "foo" : {},
1525
- "bar" : {},
1526
- "resolve-error" : {ErrorMsg : "resolve error" },
1527
- }
1528
-
1529
- graph := & graph.Graph {
1530
- Gateway : & graph.Gateway {
1531
- Listeners : map [string ]* graph.Listener {
1532
- "invalid-listener" : {
1533
- Source : v1beta1.Listener {
1534
- Name : "invalid" ,
1535
- },
1536
- Valid : false ,
1537
- Routes : invalidRoutes ,
1538
- },
1539
- "listener" : {
1540
- Source : v1beta1.Listener {
1541
- Name : "valid" ,
1542
- },
1543
- Valid : true ,
1544
- Routes : routes ,
1545
- },
1546
- },
1547
- },
1548
- }
1549
-
1550
- expWarns := Warnings {
1551
- hr : []string {
1552
- "cannot resolve backend ref; internal error: upstream dne not found in map" ,
1553
- },
1554
- hrInvalid : []string {"cannot configure routes for listener invalid; listener is invalid" },
1555
- }
1556
-
1557
- g := NewGomegaWithT (t )
1558
-
1559
- warns := buildWarnings (graph , upstreamMap )
1560
-
1561
- g .Expect (helpers .Diff (warns , expWarns )).To (BeEmpty ())
1562
- }
1563
-
1564
1456
func TestUpstreamsMapToSlice (t * testing.T ) {
1565
1457
fooUpstream := Upstream {
1566
1458
Name : "foo" ,
0 commit comments