Skip to content

Commit

Permalink
Merge branch 'main' into backend-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
guydc authored Jun 5, 2024
2 parents c7d4158 + 516a27d commit 71a524f
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ jobs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# use `0.0.0` as the default latest version.
# use `Always` image pull policy for latest version.
run: IMAGE_PULL_POLICY=Always OCI_REGISTRY=oci://docker.io/envoyproxy CHART_VERSION=v0.0.0-latest TAG=latest make helm-package helm-push
run: IMAGE_PULL_POLICY=Always OCI_REGISTRY=oci://docker.io/envoyproxy CHART_VERSION=v0.0.0-latest TAG=latest make helm-push
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
2 changes: 1 addition & 1 deletion internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func buildXdsURLRewriteAction(destName string, urlRewrite *ir.URLRewrite, pathMa
if urlRewrite.Path.FullReplace != nil {
routeAction.RegexRewrite = &matcherv3.RegexMatchAndSubstitute{
Pattern: &matcherv3.RegexMatcher{
Regex: "/.+",
Regex: "^/.*$",
},
Substitution: *urlRewrite.Path.FullReplace,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
cluster: rewrite-route
regexRewrite:
pattern:
regex: /.+
regex: ^/.*$
substitution: /rewrite
upgradeConfigs:
- upgradeType: websocket
22 changes: 22 additions & 0 deletions test/e2e/testdata/httproute-rewrite-full-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: rewrite-full-path
namespace: gateway-conformance-infra
spec:
parentRefs:
- name: same-namespace
rules:
- matches:
- path:
type: PathPrefix
value: /
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplaceFullPath
replaceFullPath: /full-replace
backendRefs:
- name: infra-backend-v1
port: 8080
59 changes: 59 additions & 0 deletions test/e2e/tests/httproute-rewrite-full-path.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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.

//go:build e2e
// +build e2e

package tests

import (
"testing"

"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

func init() {
ConformanceTests = append(ConformanceTests, HTTPRouteRewriteFullPath)
}

var HTTPRouteRewriteFullPath = suite.ConformanceTest{
ShortName: "HTTPRouteRewriteFullPath",
Description: "An HTTPRoute with path rewrite filter to replace full path",
Manifests: []string{"testdata/httproute-rewrite-full-path.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "rewrite-full-path", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)

testCases := []http.ExpectedResponse{
{
Request: http.Request{
Path: "/",
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/full-replace",
},
},
Backend: "infra-backend-v1",
Namespace: ns,
},
}
for i := range testCases {
// Declare tc here to avoid loop variable
// reuse issues across parallel tests.
tc := testCases[i]
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
t.Parallel()
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, tc)
})
}
},
}

0 comments on commit 71a524f

Please sign in to comment.