diff --git a/internal/cmd/egctl/testdata/translate/out/default-resources.all.yaml b/internal/cmd/egctl/testdata/translate/out/default-resources.all.yaml index 004faeb81f82..09dcb0a608fa 100644 --- a/internal/cmd/egctl/testdata/translate/out/default-resources.all.yaml +++ b/internal/cmd/egctl/testdata/translate/out/default-resources.all.yaml @@ -160,14 +160,9 @@ gatewayClass: type: Accepted supportedFeatures: - GRPCRoute - - Gateway - - GatewayHTTPListenerIsolation - GatewayPort8080 - - GatewayStaticAddresses - - HTTPRoute - HTTPRouteBackendProtocolH2C - HTTPRouteBackendProtocolWebSocket - - HTTPRouteBackendRequestHeaderModification - HTTPRouteBackendTimeout - HTTPRouteDestinationPortMatching - HTTPRouteHostRewrite @@ -182,8 +177,6 @@ gatewayClass: - HTTPRouteRequestTimeout - HTTPRouteResponseHeaderModification - HTTPRouteSchemeRedirect - - MeshClusterIPMatching - - MeshConsumerRoute - ReferenceGrant - TLSRoute gateways: diff --git a/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.cluster.yaml b/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.cluster.yaml index ca591b6d8e54..6afabda49f4c 100644 --- a/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.cluster.yaml +++ b/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.cluster.yaml @@ -14,14 +14,9 @@ gatewayClass: type: Accepted supportedFeatures: - GRPCRoute - - Gateway - - GatewayHTTPListenerIsolation - GatewayPort8080 - - GatewayStaticAddresses - - HTTPRoute - HTTPRouteBackendProtocolH2C - HTTPRouteBackendProtocolWebSocket - - HTTPRouteBackendRequestHeaderModification - HTTPRouteBackendTimeout - HTTPRouteDestinationPortMatching - HTTPRouteHostRewrite @@ -36,8 +31,6 @@ gatewayClass: - HTTPRouteRequestTimeout - HTTPRouteResponseHeaderModification - HTTPRouteSchemeRedirect - - MeshClusterIPMatching - - MeshConsumerRoute - ReferenceGrant - TLSRoute gateways: diff --git a/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.route.json b/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.route.json index fb5f8b3b547b..472c02fcfdbd 100644 --- a/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.route.json +++ b/internal/cmd/egctl/testdata/translate/out/echo-gateway-api.route.json @@ -20,14 +20,9 @@ ], "supportedFeatures": [ "GRPCRoute", - "Gateway", - "GatewayHTTPListenerIsolation", "GatewayPort8080", - "GatewayStaticAddresses", - "HTTPRoute", "HTTPRouteBackendProtocolH2C", "HTTPRouteBackendProtocolWebSocket", - "HTTPRouteBackendRequestHeaderModification", "HTTPRouteBackendTimeout", "HTTPRouteDestinationPortMatching", "HTTPRouteHostRewrite", @@ -42,8 +37,6 @@ "HTTPRouteRequestTimeout", "HTTPRouteResponseHeaderModification", "HTTPRouteSchemeRedirect", - "MeshClusterIPMatching", - "MeshConsumerRoute", "ReferenceGrant", "TLSRoute" ] diff --git a/internal/cmd/egctl/testdata/translate/out/invalid-envoyproxy.all.yaml b/internal/cmd/egctl/testdata/translate/out/invalid-envoyproxy.all.yaml index 2e29c3c96934..a15d2481e9a1 100644 --- a/internal/cmd/egctl/testdata/translate/out/invalid-envoyproxy.all.yaml +++ b/internal/cmd/egctl/testdata/translate/out/invalid-envoyproxy.all.yaml @@ -40,14 +40,9 @@ gatewayClass: type: Accepted supportedFeatures: - GRPCRoute - - Gateway - - GatewayHTTPListenerIsolation - GatewayPort8080 - - GatewayStaticAddresses - - HTTPRoute - HTTPRouteBackendProtocolH2C - HTTPRouteBackendProtocolWebSocket - - HTTPRouteBackendRequestHeaderModification - HTTPRouteBackendTimeout - HTTPRouteDestinationPortMatching - HTTPRouteHostRewrite @@ -62,8 +57,6 @@ gatewayClass: - HTTPRouteRequestTimeout - HTTPRouteResponseHeaderModification - HTTPRouteSchemeRedirect - - MeshClusterIPMatching - - MeshConsumerRoute - ReferenceGrant - TLSRoute gateways: diff --git a/internal/cmd/egctl/testdata/translate/out/rejected-http-route.route.yaml b/internal/cmd/egctl/testdata/translate/out/rejected-http-route.route.yaml index c88a57f4bdeb..f45a99fa577c 100644 --- a/internal/cmd/egctl/testdata/translate/out/rejected-http-route.route.yaml +++ b/internal/cmd/egctl/testdata/translate/out/rejected-http-route.route.yaml @@ -14,14 +14,9 @@ gatewayClass: type: Accepted supportedFeatures: - GRPCRoute - - Gateway - - GatewayHTTPListenerIsolation - GatewayPort8080 - - GatewayStaticAddresses - - HTTPRoute - HTTPRouteBackendProtocolH2C - HTTPRouteBackendProtocolWebSocket - - HTTPRouteBackendRequestHeaderModification - HTTPRouteBackendTimeout - HTTPRouteDestinationPortMatching - HTTPRouteHostRewrite @@ -36,8 +31,6 @@ gatewayClass: - HTTPRouteRequestTimeout - HTTPRouteResponseHeaderModification - HTTPRouteSchemeRedirect - - MeshClusterIPMatching - - MeshConsumerRoute - ReferenceGrant - TLSRoute gateways: diff --git a/internal/cmd/egctl/testdata/translate/out/valid-envoyproxy.all.yaml b/internal/cmd/egctl/testdata/translate/out/valid-envoyproxy.all.yaml index 5e37d6b1f06e..feef2037c5b8 100644 --- a/internal/cmd/egctl/testdata/translate/out/valid-envoyproxy.all.yaml +++ b/internal/cmd/egctl/testdata/translate/out/valid-envoyproxy.all.yaml @@ -33,14 +33,9 @@ gatewayClass: type: Accepted supportedFeatures: - GRPCRoute - - Gateway - - GatewayHTTPListenerIsolation - GatewayPort8080 - - GatewayStaticAddresses - - HTTPRoute - HTTPRouteBackendProtocolH2C - HTTPRouteBackendProtocolWebSocket - - HTTPRouteBackendRequestHeaderModification - HTTPRouteBackendTimeout - HTTPRouteDestinationPortMatching - HTTPRouteHostRewrite @@ -55,8 +50,6 @@ gatewayClass: - HTTPRouteRequestTimeout - HTTPRouteResponseHeaderModification - HTTPRouteSchemeRedirect - - MeshClusterIPMatching - - MeshConsumerRoute - ReferenceGrant - TLSRoute gateways: diff --git a/internal/gatewayapi/status/gatewayclass.go b/internal/gatewayapi/status/gatewayclass.go index 37c7f75f49ca..f5d677a606fd 100644 --- a/internal/gatewayapi/status/gatewayclass.go +++ b/internal/gatewayapi/status/gatewayclass.go @@ -19,6 +19,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + "sigs.k8s.io/gateway-api/conformance/utils/suite" "github.com/envoyproxy/gateway/test/conformance" ) @@ -68,11 +69,17 @@ func computeGatewayClassAcceptedCondition(gatewayClass *gwapiv1.GatewayClass, // GatewaySupportedFeatures is a list of supported Gateway-API features, // based on the running conformance tests suite. -var GatewaySupportedFeatures = getSupportedFeatures() +var GatewaySupportedFeatures = getSupportedFeatures(conformance.EnvoyGatewaySuite, conformance.SkipTests) -func getSupportedFeatures() []gwapiv1.SupportedFeature { - supportedFeatures := conformance.EnvoyGatewaySuite.SupportedFeatures - supportedFeatures.Delete(conformance.EnvoyGatewaySuite.ExemptFeatures.UnsortedList()...) +func getSupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []suite.ConformanceTest) []gwapiv1.SupportedFeature { + supportedFeatures := gatewaySuite.SupportedFeatures + supportedFeatures.Delete(gatewaySuite.ExemptFeatures.UnsortedList()...) + + for _, skippedTest := range skippedTests { + for _, feature := range skippedTest.Features { + supportedFeatures.Delete(feature) + } + } ret := sets.New[gwapiv1.SupportedFeature]() for _, feature := range supportedFeatures.UnsortedList() { diff --git a/internal/gatewayapi/status/gatewayclass_test.go b/internal/gatewayapi/status/gatewayclass_test.go index 7b845408eccb..0ccce4263531 100644 --- a/internal/gatewayapi/status/gatewayclass_test.go +++ b/internal/gatewayapi/status/gatewayclass_test.go @@ -10,7 +10,11 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/sets" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/pkg/features" ) func TestComputeGatewayClassAcceptedCondition(t *testing.T) { @@ -66,3 +70,58 @@ func TestComputeGatewayClassAcceptedCondition(t *testing.T) { assert.Equal(t, gc.Generation, got.ObservedGeneration) } } + +func TestGetSupportedFeatures(t *testing.T) { + testCases := []struct { + name string + gatewaySuite suite.ConformanceOptions + skippedTests []suite.ConformanceTest + expectedResult []gwapiv1.SupportedFeature + }{ + { + name: "No exempt features", + gatewaySuite: suite.ConformanceOptions{ + SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"), + ExemptFeatures: sets.New[features.SupportedFeature](), + }, + expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"}, + }, + { + name: "All features exempt", + gatewaySuite: suite.ConformanceOptions{ + SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"), + ExemptFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"), + }, + expectedResult: []gwapiv1.SupportedFeature{}, + }, + { + name: "Some features exempt", + gatewaySuite: suite.ConformanceOptions{ + SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GRPCRoute"), + ExemptFeatures: sets.New[features.SupportedFeature]("GRPCRoute"), + }, + expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"}, + }, + { + name: "Some features exempt with skipped tests", + gatewaySuite: suite.ConformanceOptions{ + SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GRPCRoute"), + ExemptFeatures: sets.New[features.SupportedFeature]("GRPCRoute"), + }, + skippedTests: []suite.ConformanceTest{ + { + Features: []features.SupportedFeature{"HTTPRoute"}, + }, + }, + expectedResult: []gwapiv1.SupportedFeature{"Gateway"}, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := getSupportedFeatures(tc.gatewaySuite, tc.skippedTests) + + assert.ElementsMatch(t, tc.expectedResult, result, "The result should match the expected output for the test case.") + }) + } +} diff --git a/test/conformance/conformance_features.go b/test/conformance/conformance_features.go index dbeb989d7f83..93b13751d7cc 100644 --- a/test/conformance/conformance_features.go +++ b/test/conformance/conformance_features.go @@ -6,17 +6,32 @@ package conformance import ( + "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/gateway-api/conformance/tests" "sigs.k8s.io/gateway-api/conformance/utils/suite" "sigs.k8s.io/gateway-api/pkg/features" ) +// SkipTests is a list of tests that are skipped in the conformance suite. +var SkipTests = []suite.ConformanceTest{ + tests.GatewayStaticAddresses, + tests.GatewayHTTPListenerIsolation, // https://github.com/kubernetes-sigs/gateway-api/issues/3049 + tests.HTTPRouteBackendRequestHeaderModifier, // https://github.com/envoyproxy/gateway/issues/3338 +} + +func skipTestsShortNames(skipTests []suite.ConformanceTest) []string { + shortNames := make([]string, len(skipTests)) + for i, test := range skipTests { + shortNames[i] = test.ShortName + } + return shortNames +} + +// EnvoyGatewaySuite is the conformance suite configuration for the Gateway API. var EnvoyGatewaySuite = suite.ConformanceOptions{ SupportedFeatures: features.AllFeatures, - ExemptFeatures: features.MeshCoreFeatures, - SkipTests: []string{ - tests.GatewayStaticAddresses.ShortName, - tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049 - tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338 - }, + ExemptFeatures: sets.New[features.SupportedFeature](). + Insert(features.MeshCoreFeatures.UnsortedList()...). + Insert(features.MeshExtendedFeatures.UnsortedList()...), + SkipTests: skipTestsShortNames(SkipTests), }