@@ -28,6 +28,7 @@ import (
28
28
"sigs.k8s.io/controller-runtime/pkg/client/fake"
29
29
30
30
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
31
+ xmeshv1alpha1 "sigs.k8s.io/gateway-api/apisx/v1alpha1"
31
32
confv1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
32
33
"sigs.k8s.io/gateway-api/pkg/consts"
33
34
"sigs.k8s.io/gateway-api/pkg/features"
@@ -411,7 +412,7 @@ func TestSuiteReport(t *testing.T) {
411
412
}
412
413
}
413
414
414
- var statusFeatureNames = []string {
415
+ var gwcStatusFeatureNames = []string {
415
416
"Gateway" ,
416
417
"GatewayPort8080" ,
417
418
"HTTPRoute" ,
@@ -423,7 +424,7 @@ var statusFeatureNames = []string{
423
424
"ReferenceGrant" ,
424
425
}
425
426
426
- func TestInferSupportedFeatures (t * testing.T ) {
427
+ func TestInferGWCSupportedFeatures (t * testing.T ) {
427
428
testCases := []struct {
428
429
name string
429
430
allowAllFeatures bool
@@ -435,7 +436,7 @@ func TestInferSupportedFeatures(t *testing.T) {
435
436
}{
436
437
{
437
438
name : "properly infer supported features" ,
438
- expectedFeatures : namesToFeatureSet (statusFeatureNames ),
439
+ expectedFeatures : namesToFeatureSet (gwcStatusFeatureNames ),
439
440
expectedSource : supportedFeaturesSourceInferred ,
440
441
},
441
442
{
@@ -460,7 +461,7 @@ func TestInferSupportedFeatures(t *testing.T) {
460
461
{
461
462
name : "supports conformance profile - core" ,
462
463
ConformanceProfile : sets .New (GatewayHTTPConformanceProfileName ),
463
- expectedFeatures : namesToFeatureSet (statusFeatureNames ),
464
+ expectedFeatures : namesToFeatureSet (gwcStatusFeatureNames ),
464
465
expectedSource : supportedFeaturesSourceInferred ,
465
466
},
466
467
}
@@ -482,7 +483,7 @@ func TestInferSupportedFeatures(t *testing.T) {
482
483
Message : "GatewayClass is accepted and ready for use" ,
483
484
},
484
485
},
485
- SupportedFeatures : featureNamesToSet (statusFeatureNames ),
486
+ SupportedFeatures : featureNamesToSet (gwcStatusFeatureNames ),
486
487
},
487
488
}
488
489
scheme := runtime .NewScheme ()
@@ -524,6 +525,113 @@ func TestInferSupportedFeatures(t *testing.T) {
524
525
}
525
526
}
526
527
528
+ var meshStatusFeatureNames = []string {
529
+ "Mesh" ,
530
+ "MeshClusterIPMatching" ,
531
+ "MeshNamespaceSelector" ,
532
+ "MeshServiceAccountSelector" ,
533
+ "MeshTLS" ,
534
+ "MeshTLSClientCert" ,
535
+ "MeshTrafficSplit" ,
536
+ "MeshAccessControl" ,
537
+ "HTTPRoute" ,
538
+ }
539
+
540
+ func TestXMeshInferSupportedFeatures (t * testing.T ) {
541
+ testCases := []struct {
542
+ name string
543
+ allowAllFeatures bool
544
+ supportedFeatures FeaturesSet
545
+ exemptFeatures FeaturesSet
546
+ ConformanceProfile sets.Set [ConformanceProfileName ]
547
+ expectedFeatures FeaturesSet
548
+ expectedSource supportedFeaturesSource
549
+ }{
550
+ {
551
+ name : "properly infer mesh supported features" ,
552
+ expectedFeatures : namesToFeatureSet (meshStatusFeatureNames ),
553
+ expectedSource : supportedFeaturesSourceInferred ,
554
+ },
555
+ {
556
+ name : "no features" ,
557
+ supportedFeatures : sets.New [features.FeatureName ]("Mesh" ),
558
+ expectedFeatures : sets.New [features.FeatureName ]("Mesh" ),
559
+ expectedSource : supportedFeaturesSourceManual ,
560
+ },
561
+ {
562
+ name : "remove exempt features" ,
563
+ supportedFeatures : sets .New [features.FeatureName ]("MeshTLS" , "MeshAccessControl" ),
564
+ exemptFeatures : sets.New [features.FeatureName ]("MeshAccessControl" ),
565
+ expectedFeatures : sets.New [features.FeatureName ]("MeshTLS" ),
566
+ expectedSource : supportedFeaturesSourceManual ,
567
+ },
568
+ {
569
+ name : "supports conformance profile - core" ,
570
+ ConformanceProfile : sets .New (MeshHTTPConformanceProfileName ),
571
+ expectedFeatures : namesToFeatureSet (meshStatusFeatureNames ),
572
+ expectedSource : supportedFeaturesSourceInferred ,
573
+ },
574
+ }
575
+
576
+ meshName := "xochopintre"
577
+ xmesh := & xmeshv1alpha1.XMesh {
578
+ ObjectMeta : metav1.ObjectMeta {
579
+ Name : meshName ,
580
+ },
581
+ Spec : xmeshv1alpha1.MeshSpec {
582
+ ControllerName : "example.com/mesh-controller" ,
583
+ },
584
+ Status : xmeshv1alpha1.MeshStatus {
585
+ Conditions : []metav1.Condition {
586
+ {
587
+ Type : string (xmeshv1alpha1 .MeshConditionAccepted ),
588
+ Status : metav1 .ConditionTrue ,
589
+ Reason : "Accepted" ,
590
+ Message : "XMesh is accepted and ready for use" ,
591
+ },
592
+ },
593
+ SupportedFeatures : featureNamesToSet (meshStatusFeatureNames ),
594
+ },
595
+ }
596
+ scheme := runtime .NewScheme ()
597
+ scheme .AddKnownTypes (xmeshv1alpha1 .SchemeGroupVersion , & xmeshv1alpha1.XMesh {})
598
+ fakeClient := fake .NewClientBuilder ().
599
+ WithScheme (scheme ).
600
+ WithObjects (xmesh ).
601
+ WithLists (& apiextensionsv1.CustomResourceDefinitionList {}).
602
+ Build ()
603
+
604
+ xmeshv1alpha1 .Install (fakeClient .Scheme ())
605
+ apiextensionsv1 .AddToScheme (fakeClient .Scheme ())
606
+
607
+ for _ , tc := range testCases {
608
+ options := ConformanceOptions {
609
+ AllowCRDsMismatch : true ,
610
+ MeshName : meshName ,
611
+ EnableAllSupportedFeatures : tc .allowAllFeatures ,
612
+ SupportedFeatures : tc .supportedFeatures ,
613
+ ExemptFeatures : tc .exemptFeatures ,
614
+ ConformanceProfiles : tc .ConformanceProfile ,
615
+ Client : fakeClient ,
616
+ }
617
+
618
+ t .Run (tc .name , func (t * testing.T ) {
619
+ cSuite , err := NewConformanceTestSuite (options )
620
+ if err != nil {
621
+ t .Fatalf ("error initializing conformance suite: %v" , err )
622
+ }
623
+
624
+ if cSuite .supportedFeaturesSource != tc .expectedSource {
625
+ t .Errorf ("InferredSupportedFeatures mismatch: got %v, want %v" , cSuite .supportedFeaturesSource , tc .expectedSource )
626
+ }
627
+
628
+ if equal := cSuite .SupportedFeatures .Equal (tc .expectedFeatures ); ! equal {
629
+ t .Errorf ("SupportedFeatures mismatch: got %v, want %v" , cSuite .SupportedFeatures .UnsortedList (), tc .expectedFeatures .UnsortedList ())
630
+ }
631
+ })
632
+ }
633
+ }
634
+
527
635
func TestGWCPublishedMeshFeatures (t * testing.T ) {
528
636
gwcName := "ochopintre"
529
637
gwc := & gatewayv1.GatewayClass {
0 commit comments