-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e & misc fixes for EnvoyPatchPolicy #1738
Changes from all commits
2c71ee5
0d0d3d3
850a744
0023d92
eaebbab
f3662d5
c78dcc9
45afb18
0bac038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,6 @@ spec: | |
- JSONPatch | ||
type: string | ||
required: | ||
- priority | ||
- targetRef | ||
- type | ||
type: object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,8 @@ data: | |
type: Kubernetes | ||
gateway: | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
extensionApis: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems not related to an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the yaml used in e2e to update the startup config, I can start renaming and breaking things in separate files, would you prefer that ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we can do that later |
||
enableEnvoyPatchPolicy: true | ||
rateLimit: | ||
backend: | ||
type: Redis | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1beta1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: http-envoy-patch-policy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- backendRefs: | ||
- name: infra-backend-v1 | ||
port: 8080 | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: /foo | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: EnvoyPatchPolicy | ||
metadata: | ||
name: custom-response-patch-policy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: same-namespace | ||
namespace: gateway-conformance-infra | ||
type: JSONPatch | ||
jsonPatches: | ||
- type: "type.googleapis.com/envoy.config.listener.v3.Listener" | ||
name: "gateway-conformance-infra/same-namespace/http" | ||
operation: | ||
op: add | ||
path: "/default_filter_chain/filters/0/typed_config/local_reply_config" | ||
value: | ||
mappers: | ||
- filter: | ||
status_code_filter: | ||
comparison: | ||
op: EQ | ||
value: | ||
default_value: 404 | ||
runtime_key: key_b | ||
status_code: 406 | ||
body: | ||
inline_string: "not acceptable" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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, EnvoyPatchPolicyTest) | ||
} | ||
|
||
var EnvoyPatchPolicyTest = suite.ConformanceTest{ | ||
ShortName: "EnvoyPatchPolicy", | ||
Description: "update xds using EnvoyPatchPolicy", | ||
Manifests: []string{"testdata/envoy-patch-policy.yaml"}, | ||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { | ||
t.Run("envoy patch policy", func(t *testing.T) { | ||
ns := "gateway-conformance-infra" | ||
routeNN := types.NamespacedName{Name: "http-envoy-patch-policy", Namespace: ns} | ||
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} | ||
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) | ||
OkResp := http.ExpectedResponse{ | ||
Request: http.Request{ | ||
Path: "/foo", | ||
}, | ||
Response: http.Response{ | ||
StatusCode: 200, | ||
}, | ||
Namespace: ns, | ||
} | ||
|
||
// Send a request to an valid path and expect a successful response | ||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp) | ||
|
||
customResp := http.ExpectedResponse{ | ||
Request: http.Request{ | ||
Path: "/bar", | ||
}, | ||
Response: http.Response{ | ||
StatusCode: 406, | ||
}, | ||
Namespace: ns, | ||
} | ||
|
||
// Send a request to an invalid path and expect a custom response | ||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, customResp) | ||
}) | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this's OK to me, but I recall the api guide said should be a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its still required internally,
omitempty
allows the user to skip setting it when creating the resource and use the default value /0
instead