Skip to content

Commit

Permalink
feat: keep core features supported when skipping extended tests (envo…
Browse files Browse the repository at this point in the history
…yproxy#3520)

Signed-off-by: Kobi Levi <kobilevi503@gmail.com>
Co-authored-by: zirain <zirain2009@gmail.com>
  • Loading branch information
levikobi and zirain authored Jun 5, 2024
1 parent cdd4e06 commit 516a27d
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayPort8080
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayPort8080
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
],
"supportedFeatures": [
"GRPCRoute",
"Gateway",
"GatewayPort8080",
"HTTPRoute",
"HTTPRouteBackendProtocolH2C",
"HTTPRouteBackendProtocolWebSocket",
"HTTPRouteBackendTimeout",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayPort8080
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayPort8080
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ gatewayClass:
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayPort8080
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
Expand Down
File renamed without changes.
55 changes: 55 additions & 0 deletions internal/gatewayapi/conformance/support_level.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package conformance

import (
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
)

// SupportLevel represents the level of support for a feature.
// See https://gateway-api.sigs.k8s.io/concepts/conformance/#2-support-levels.
type SupportLevel string

const (
// Core features are portable and expected to be supported by every implementation of Gateway-API.
Core SupportLevel = "core"

// Extended features are those that are portable but not universally supported across implementations.
// Those implementations that support the feature will have the same behavior and semantics.
// It is expected that some number of roadmap features will eventually migrate into the Core.
Extended SupportLevel = "extended"
)

// ExtendedFeatures is a list of supported Gateway-API features that are considered Extended.
var ExtendedFeatures = sets.New[features.SupportedFeature]().
Insert(features.GatewayExtendedFeatures.UnsortedList()...).
Insert(features.HTTPRouteExtendedFeatures.UnsortedList()...).
Insert(features.MeshExtendedFeatures.UnsortedList()...)

// GetTestSupportLevel returns the SupportLevel for a conformance test.
// The support level is determined by the highest support level of the features.
func GetTestSupportLevel(test suite.ConformanceTest) SupportLevel {
supportLevel := Core

if ExtendedFeatures.HasAny(test.Features...) {
supportLevel = Extended
}

return supportLevel
}

// GetFeatureSupportLevel returns the SupportLevel for a feature.
func GetFeatureSupportLevel(feature features.SupportedFeature) SupportLevel {
supportLevel := Core

if ExtendedFeatures.Has(feature) {
supportLevel = Extended
}

return supportLevel
}
29 changes: 22 additions & 7 deletions internal/gatewayapi/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"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"

"github.com/envoyproxy/gateway/internal/gatewayapi/conformance"
)
Expand Down Expand Up @@ -73,17 +74,31 @@ var GatewaySupportedFeatures = getSupportedFeatures(conformance.EnvoyGatewaySuit

func getSupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []suite.ConformanceTest) []gwapiv1.SupportedFeature {
supportedFeatures := gatewaySuite.SupportedFeatures.Clone()
supportedFeatures.Delete(gatewaySuite.ExemptFeatures.UnsortedList()...)

for _, skippedTest := range skippedTests {
for _, feature := range skippedTest.Features {
supportedFeatures.Delete(feature)
}
}
unsupportedFeatures := getUnsupportedFeatures(gatewaySuite, skippedTests)
supportedFeatures.Delete(unsupportedFeatures...)

ret := sets.New[gwapiv1.SupportedFeature]()
for _, feature := range supportedFeatures.UnsortedList() {
ret.Insert(gwapiv1.SupportedFeature(feature))
}
return sets.List(ret)
}

func getUnsupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []suite.ConformanceTest) []features.SupportedFeature {
unsupportedFeatures := gatewaySuite.ExemptFeatures.UnsortedList()

for _, skippedTest := range skippedTests {
switch conformance.GetTestSupportLevel(skippedTest) {
case conformance.Core:
unsupportedFeatures = append(unsupportedFeatures, skippedTest.Features...)
case conformance.Extended:
for _, feature := range skippedTest.Features {
if conformance.GetFeatureSupportLevel(feature) == conformance.Extended {
unsupportedFeatures = append(unsupportedFeatures, feature)
}
}
}
}

return unsupportedFeatures
}
24 changes: 24 additions & 0 deletions internal/gatewayapi/status/gatewayclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ func TestGetSupportedFeatures(t *testing.T) {
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway"},
},
{
name: "Core features remain supported with skipped extended tests",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GatewayHTTPListenerIsolation"),
},
skippedTests: []suite.ConformanceTest{
{
Features: []features.SupportedFeature{"Gateway", "GatewayHTTPListenerIsolation", "HTTPRoute"},
},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"},
},
{
name: "Core feature removed when skipping core test",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"),
},
skippedTests: []suite.ConformanceTest{
{
Features: []features.SupportedFeature{"HTTPRoute"},
},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway"},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 516a27d

Please sign in to comment.