@@ -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
@@ -436,7 +437,7 @@ func TestInferSupportedFeatures(t *testing.T) {
436
437
}{
437
438
{
438
439
name : "properly infer supported features" ,
439
- expectedFeatures : namesToFeatureSet (statusFeatureNames ),
440
+ expectedFeatures : namesToFeatureSet (gwcStatusFeatureNames ),
440
441
expectedSource : supportedFeaturesSourceInferred ,
441
442
},
442
443
{
@@ -473,7 +474,7 @@ func TestInferSupportedFeatures(t *testing.T) {
473
474
{
474
475
name : "supports conformance profile core with inferred extended features" ,
475
476
ConformanceProfile : sets .New (GatewayHTTPConformanceProfileName ),
476
- expectedFeatures : namesToFeatureSet (statusFeatureNames ),
477
+ expectedFeatures : namesToFeatureSet (gwcStatusFeatureNames ),
477
478
expectedSource : supportedFeaturesSourceInferred ,
478
479
expectedExtendedFeatures : map [ConformanceProfileName ]sets.Set [features.FeatureName ]{
479
480
GatewayHTTPConformanceProfileName : namesToFeatureSet ([]string {
@@ -505,7 +506,7 @@ func TestInferSupportedFeatures(t *testing.T) {
505
506
Message : "GatewayClass is accepted and ready for use" ,
506
507
},
507
508
},
508
- SupportedFeatures : featureNamesToSet (statusFeatureNames ),
509
+ SupportedFeatures : featureNamesToSet (gwcStatusFeatureNames ),
509
510
},
510
511
}
511
512
scheme := runtime .NewScheme ()
@@ -552,6 +553,113 @@ func TestInferSupportedFeatures(t *testing.T) {
552
553
}
553
554
}
554
555
556
+ var meshStatusFeatureNames = []string {
557
+ "Mesh" ,
558
+ "MeshClusterIPMatching" ,
559
+ "MeshNamespaceSelector" ,
560
+ "MeshServiceAccountSelector" ,
561
+ "MeshTLS" ,
562
+ "MeshTLSClientCert" ,
563
+ "MeshTrafficSplit" ,
564
+ "MeshAccessControl" ,
565
+ "HTTPRoute" ,
566
+ }
567
+
568
+ func TestXMeshInferSupportedFeatures (t * testing.T ) {
569
+ testCases := []struct {
570
+ name string
571
+ allowAllFeatures bool
572
+ supportedFeatures FeaturesSet
573
+ exemptFeatures FeaturesSet
574
+ ConformanceProfile sets.Set [ConformanceProfileName ]
575
+ expectedFeatures FeaturesSet
576
+ expectedSource supportedFeaturesSource
577
+ }{
578
+ {
579
+ name : "properly infer mesh supported features" ,
580
+ expectedFeatures : namesToFeatureSet (meshStatusFeatureNames ),
581
+ expectedSource : supportedFeaturesSourceInferred ,
582
+ },
583
+ {
584
+ name : "no features" ,
585
+ supportedFeatures : sets.New [features.FeatureName ]("Mesh" ),
586
+ expectedFeatures : sets.New [features.FeatureName ]("Mesh" ),
587
+ expectedSource : supportedFeaturesSourceManual ,
588
+ },
589
+ {
590
+ name : "remove exempt features" ,
591
+ supportedFeatures : sets .New [features.FeatureName ]("MeshTLS" , "MeshAccessControl" ),
592
+ exemptFeatures : sets.New [features.FeatureName ]("MeshAccessControl" ),
593
+ expectedFeatures : sets.New [features.FeatureName ]("MeshTLS" ),
594
+ expectedSource : supportedFeaturesSourceManual ,
595
+ },
596
+ {
597
+ name : "supports conformance profile - core" ,
598
+ ConformanceProfile : sets .New (MeshHTTPConformanceProfileName ),
599
+ expectedFeatures : namesToFeatureSet (meshStatusFeatureNames ),
600
+ expectedSource : supportedFeaturesSourceInferred ,
601
+ },
602
+ }
603
+
604
+ meshName := "xochopintre"
605
+ xmesh := & xmeshv1alpha1.XMesh {
606
+ ObjectMeta : metav1.ObjectMeta {
607
+ Name : meshName ,
608
+ },
609
+ Spec : xmeshv1alpha1.MeshSpec {
610
+ ControllerName : "example.com/mesh-controller" ,
611
+ },
612
+ Status : xmeshv1alpha1.MeshStatus {
613
+ Conditions : []metav1.Condition {
614
+ {
615
+ Type : string (xmeshv1alpha1 .MeshConditionAccepted ),
616
+ Status : metav1 .ConditionTrue ,
617
+ Reason : "Accepted" ,
618
+ Message : "XMesh is accepted and ready for use" ,
619
+ },
620
+ },
621
+ SupportedFeatures : featureNamesToSet (meshStatusFeatureNames ),
622
+ },
623
+ }
624
+ scheme := runtime .NewScheme ()
625
+ scheme .AddKnownTypes (xmeshv1alpha1 .SchemeGroupVersion , & xmeshv1alpha1.XMesh {})
626
+ fakeClient := fake .NewClientBuilder ().
627
+ WithScheme (scheme ).
628
+ WithObjects (xmesh ).
629
+ WithLists (& apiextensionsv1.CustomResourceDefinitionList {}).
630
+ Build ()
631
+
632
+ xmeshv1alpha1 .Install (fakeClient .Scheme ())
633
+ apiextensionsv1 .AddToScheme (fakeClient .Scheme ())
634
+
635
+ for _ , tc := range testCases {
636
+ options := ConformanceOptions {
637
+ AllowCRDsMismatch : true ,
638
+ MeshName : meshName ,
639
+ EnableAllSupportedFeatures : tc .allowAllFeatures ,
640
+ SupportedFeatures : tc .supportedFeatures ,
641
+ ExemptFeatures : tc .exemptFeatures ,
642
+ ConformanceProfiles : tc .ConformanceProfile ,
643
+ Client : fakeClient ,
644
+ }
645
+
646
+ t .Run (tc .name , func (t * testing.T ) {
647
+ cSuite , err := NewConformanceTestSuite (options )
648
+ if err != nil {
649
+ t .Fatalf ("error initializing conformance suite: %v" , err )
650
+ }
651
+
652
+ if cSuite .supportedFeaturesSource != tc .expectedSource {
653
+ t .Errorf ("InferredSupportedFeatures mismatch: got %v, want %v" , cSuite .supportedFeaturesSource , tc .expectedSource )
654
+ }
655
+
656
+ if equal := cSuite .SupportedFeatures .Equal (tc .expectedFeatures ); ! equal {
657
+ t .Errorf ("SupportedFeatures mismatch: got %v, want %v" , cSuite .SupportedFeatures .UnsortedList (), tc .expectedFeatures .UnsortedList ())
658
+ }
659
+ })
660
+ }
661
+ }
662
+
555
663
func TestGWCPublishedMeshFeatures (t * testing.T ) {
556
664
gwcName := "ochopintre"
557
665
gwc := & gatewayv1.GatewayClass {
0 commit comments