Skip to content

Commit

Permalink
remove skipped test features from supported features list
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Levi <[email protected]>
  • Loading branch information
levikobi committed May 12, 2024
1 parent a15245e commit b0b5e20
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
Expand All @@ -182,8 +177,6 @@ gatewayClass:
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
Expand All @@ -36,8 +31,6 @@ gatewayClass:
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@
],
"supportedFeatures": [
"GRPCRoute",
"Gateway",
"GatewayHTTPListenerIsolation",
"GatewayPort8080",
"GatewayStaticAddresses",
"HTTPRoute",
"HTTPRouteBackendProtocolH2C",
"HTTPRouteBackendProtocolWebSocket",
"HTTPRouteBackendRequestHeaderModification",
"HTTPRouteBackendTimeout",
"HTTPRouteDestinationPortMatching",
"HTTPRouteHostRewrite",
Expand All @@ -42,8 +37,6 @@
"HTTPRouteRequestTimeout",
"HTTPRouteResponseHeaderModification",
"HTTPRouteSchemeRedirect",
"MeshClusterIPMatching",
"MeshConsumerRoute",
"ReferenceGrant",
"TLSRoute"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
Expand All @@ -62,8 +57,6 @@ gatewayClass:
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
Expand All @@ -36,8 +31,6 @@ gatewayClass:
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
Expand All @@ -55,8 +50,6 @@ gatewayClass:
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
Expand Down
15 changes: 11 additions & 4 deletions internal/gatewayapi/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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() {
Expand Down
59 changes: 59 additions & 0 deletions internal/gatewayapi/status/gatewayclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.")
})
}
}
27 changes: 21 additions & 6 deletions test/conformance/conformance_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

0 comments on commit b0b5e20

Please sign in to comment.