diff --git a/conformance/utils/suite/suite.go b/conformance/utils/suite/suite.go index 31db06c596..0fce3d201b 100644 --- a/conformance/utils/suite/suite.go +++ b/conformance/utils/suite/suite.go @@ -227,6 +227,22 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite, return nil, fmt.Errorf("no supported features were determined for test suite") } + extendedSupportedFeatures := make(map[ConformanceProfileName]FeaturesSet, 0) + extendedUnsupportedFeatures := make(map[ConformanceProfileName]FeaturesSet, 0) + + for _, conformanceProfileName := range options.ConformanceProfiles.UnsortedList() { + conformanceProfile, err := getConformanceProfileForName(conformanceProfileName) + if err != nil { + return nil, fmt.Errorf("failed to retrieve conformance profile: %w", err) + } + // the use of a conformance profile implicitly enables any features of + // that profile which are supported at a Core level of support. + supportedFeatures = supportedFeatures.Union(conformanceProfile.CoreFeatures) + + extendedSupportedFeatures[conformanceProfileName] = conformanceProfile.ExtendedFeatures.Intersection(supportedFeatures) + extendedUnsupportedFeatures[conformanceProfileName] = conformanceProfile.ExtendedFeatures.Difference(supportedFeatures) + } + config.SetupTimeoutConfig(&options.TimeoutConfig) roundTripper := options.RoundTripper @@ -284,8 +300,8 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite, UsableNetworkAddresses: options.UsableNetworkAddresses, UnusableNetworkAddresses: options.UnusableNetworkAddresses, results: make(map[string]testResult), - extendedUnsupportedFeatures: make(map[ConformanceProfileName]sets.Set[features.FeatureName]), - extendedSupportedFeatures: make(map[ConformanceProfileName]sets.Set[features.FeatureName]), + extendedUnsupportedFeatures: extendedUnsupportedFeatures, + extendedSupportedFeatures: extendedSupportedFeatures, conformanceProfiles: options.ConformanceProfiles, implementation: options.Implementation, mode: mode, @@ -295,37 +311,6 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite, Hook: options.Hook, } - for _, conformanceProfileName := range options.ConformanceProfiles.UnsortedList() { - conformanceProfile, err := getConformanceProfileForName(conformanceProfileName) - if err != nil { - return nil, fmt.Errorf("failed to retrieve conformance profile: %w", err) - } - // the use of a conformance profile implicitly enables any features of - // that profile which are supported at a Core level of support. - for _, f := range conformanceProfile.CoreFeatures.UnsortedList() { - if !options.SupportedFeatures.Has(f) { - suite.SupportedFeatures.Insert(f) - } - } - for _, f := range conformanceProfile.ExtendedFeatures.UnsortedList() { - if options.SupportedFeatures.Has(f) { - if suite.extendedSupportedFeatures[conformanceProfileName] == nil { - suite.extendedSupportedFeatures[conformanceProfileName] = FeaturesSet{} - } - suite.extendedSupportedFeatures[conformanceProfileName].Insert(f) - } else { - if suite.extendedUnsupportedFeatures[conformanceProfileName] == nil { - suite.extendedUnsupportedFeatures[conformanceProfileName] = FeaturesSet{} - } - suite.extendedUnsupportedFeatures[conformanceProfileName].Insert(f) - } - // Add Exempt Features into unsupported features list - if options.ExemptFeatures.Has(f) { - suite.extendedUnsupportedFeatures[conformanceProfileName].Insert(f) - } - } - } - // apply defaults if suite.BaseManifests == "" { suite.BaseManifests = "base/manifests.yaml" diff --git a/conformance/utils/suite/suite_test.go b/conformance/utils/suite/suite_test.go index 778afa7180..179e038cdb 100644 --- a/conformance/utils/suite/suite_test.go +++ b/conformance/utils/suite/suite_test.go @@ -418,20 +418,21 @@ var statusFeatureNames = []string{ "HTTPRouteHostRewrite", "HTTPRouteMethodMatching", "HTTPRoutePathRewrite", - "TTPRouteQueryParamMatching", + "HTTPRouteQueryParamMatching", "HTTPRouteResponseHeaderModification", "ReferenceGrant", } func TestInferSupportedFeatures(t *testing.T) { testCases := []struct { - name string - allowAllFeatures bool - supportedFeatures FeaturesSet - exemptFeatures FeaturesSet - ConformanceProfile sets.Set[ConformanceProfileName] - expectedFeatures FeaturesSet - expectedSource supportedFeaturesSource + name string + allowAllFeatures bool + supportedFeatures FeaturesSet + exemptFeatures FeaturesSet + ConformanceProfile sets.Set[ConformanceProfileName] + expectedFeatures FeaturesSet + expectedExtendedFeatures map[ConformanceProfileName]sets.Set[features.FeatureName] + expectedSource supportedFeaturesSource }{ { name: "properly infer supported features", @@ -458,10 +459,32 @@ func TestInferSupportedFeatures(t *testing.T) { expectedSource: supportedFeaturesSourceManual, }, { - name: "supports conformance profile - core", + name: "supports conformance profile core with specified extended features", + ConformanceProfile: sets.New(GatewayHTTPConformanceProfileName), + supportedFeatures: sets.New[features.FeatureName]("GatewayPort8080"), + expectedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute", "GatewayPort8080", "ReferenceGrant"), + expectedSource: supportedFeaturesSourceManual, + expectedExtendedFeatures: map[ConformanceProfileName]sets.Set[features.FeatureName]{ + GatewayHTTPConformanceProfileName: namesToFeatureSet([]string{ + "GatewayPort8080", + }), + }, + }, + { + name: "supports conformance profile core with inferred extended features", ConformanceProfile: sets.New(GatewayHTTPConformanceProfileName), expectedFeatures: namesToFeatureSet(statusFeatureNames), expectedSource: supportedFeaturesSourceInferred, + expectedExtendedFeatures: map[ConformanceProfileName]sets.Set[features.FeatureName]{ + GatewayHTTPConformanceProfileName: namesToFeatureSet([]string{ + "GatewayPort8080", + "HTTPRouteHostRewrite", + "HTTPRouteMethodMatching", + "HTTPRoutePathRewrite", + "HTTPRouteQueryParamMatching", + "HTTPRouteResponseHeaderModification", + }), + }, }, } @@ -520,6 +543,11 @@ func TestInferSupportedFeatures(t *testing.T) { if equal := cSuite.SupportedFeatures.Equal(tc.expectedFeatures); !equal { t.Errorf("SupportedFeatures mismatch: got %v, want %v", cSuite.SupportedFeatures.UnsortedList(), tc.expectedFeatures.UnsortedList()) } + + if tc.expectedExtendedFeatures == nil { + tc.expectedExtendedFeatures = make(map[ConformanceProfileName]sets.Set[features.FeatureName]) + } + assert.Equal(t, tc.expectedExtendedFeatures, cSuite.extendedSupportedFeatures, "expectedExtendedFeatures mismatch") }) } }