Skip to content

Commit

Permalink
try adding e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Edoardo Vacchi <[email protected]>
  • Loading branch information
evacchi committed Jun 6, 2024
1 parent 67e0a70 commit a03c362
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 8 deletions.
5 changes: 2 additions & 3 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ type EnvoyProxySpec struct {
// +optional
Concurrency *int32 `json:"concurrency,omitempty"`

// EndpointRoutingDisabled can be set to true to use
// the Service Cluster IP for routing to the backend
// instead.
// RoutingType can be set to "service" to use Service Cluster IP for routing to the backend,
// or it can be set to "endpoint" to use Endpoint routing. The default is "endpoint".
// +optional
RoutingType *RoutingType `json:"routingType,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10192,9 +10192,8 @@ spec:
type: object
routingType:
description: |-
EndpointRoutingDisabled can be set to true to use
the Service Cluster IP for routing to the backend
instead.
RoutingType can be set to "service" to use Service Cluster IP for routing to the backend,
or it can be set to "endpoint" to use Endpoint routing. The default is "endpoint".
type: string
shutdown:
description: Shutdown defines configuration for graceful envoy shutdown
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ _Appears in:_
| `telemetry` | _[ProxyTelemetry](#proxytelemetry)_ | false | Telemetry defines telemetry parameters for managed proxies. |
| `bootstrap` | _[ProxyBootstrap](#proxybootstrap)_ | false | Bootstrap defines the Envoy Bootstrap as a YAML string.<br />Visit https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-msg-config-bootstrap-v3-bootstrap<br />to learn more about the syntax.<br />If set, this is the Bootstrap configuration used for the managed Envoy Proxy fleet instead of the default Bootstrap configuration<br />set by Envoy Gateway.<br />Some fields within the Bootstrap that are required to communicate with the xDS Server (Envoy Gateway) and receive xDS resources<br />from it are not configurable and will result in the `EnvoyProxy` resource being rejected.<br />Backward compatibility across minor versions is not guaranteed.<br />We strongly recommend using `egctl x translate` to generate a `EnvoyProxy` resource with the `Bootstrap` field set to the default<br />Bootstrap configuration used. You can edit this configuration, and rerun `egctl x translate` to ensure there are no validation errors. |
| `concurrency` | _integer_ | false | Concurrency defines the number of worker threads to run. If unset, it defaults to<br />the number of cpuset threads on the platform. |
| `routingType` | _[RoutingType](#routingtype)_ | false | EndpointRoutingDisabled can be set to true to use<br />the Service Cluster IP for routing to the backend<br />instead. |
| `routingType` | _[RoutingType](#routingtype)_ | false | RoutingType can be set to "service" to use Service Cluster IP for routing to the backend,<br />or it can be set to "endpoint" to use Endpoint routing. The default is "endpoint". |
| `extraArgs` | _string array_ | false | ExtraArgs defines additional command line options that are provided to Envoy.<br />More info: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#command-line-options<br />Note: some command line options are used internally(e.g. --log-level) so they cannot be provided here. |
| `mergeGateways` | _boolean_ | false | MergeGateways defines if Gateway resources should be merged onto the same Envoy Proxy Infrastructure.<br />Setting this field to true would merge all Gateway Listeners under the parent Gateway Class.<br />This means that the port, protocol and hostname tuple must be unique for every listener.<br />If a duplicate listener is detected, the newer listener (based on timestamp) will be rejected and its status will be updated with a "Accepted=False" condition. |
| `shutdown` | _[ShutdownConfig](#shutdownconfig)_ | false | Shutdown defines configuration for graceful envoy shutdown process. |
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ _Appears in:_
| `telemetry` | _[ProxyTelemetry](#proxytelemetry)_ | false | Telemetry defines telemetry parameters for managed proxies. |
| `bootstrap` | _[ProxyBootstrap](#proxybootstrap)_ | false | Bootstrap defines the Envoy Bootstrap as a YAML string.<br />Visit https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-msg-config-bootstrap-v3-bootstrap<br />to learn more about the syntax.<br />If set, this is the Bootstrap configuration used for the managed Envoy Proxy fleet instead of the default Bootstrap configuration<br />set by Envoy Gateway.<br />Some fields within the Bootstrap that are required to communicate with the xDS Server (Envoy Gateway) and receive xDS resources<br />from it are not configurable and will result in the `EnvoyProxy` resource being rejected.<br />Backward compatibility across minor versions is not guaranteed.<br />We strongly recommend using `egctl x translate` to generate a `EnvoyProxy` resource with the `Bootstrap` field set to the default<br />Bootstrap configuration used. You can edit this configuration, and rerun `egctl x translate` to ensure there are no validation errors. |
| `concurrency` | _integer_ | false | Concurrency defines the number of worker threads to run. If unset, it defaults to<br />the number of cpuset threads on the platform. |
| `routingType` | _[RoutingType](#routingtype)_ | false | EndpointRoutingDisabled can be set to true to use<br />the Service Cluster IP for routing to the backend<br />instead. |
| `routingType` | _[RoutingType](#routingtype)_ | false | RoutingType can be set to "service" to use Service Cluster IP for routing to the backend,<br />or it can be set to "endpoint" to use Endpoint routing. The default is "endpoint". |
| `extraArgs` | _string array_ | false | ExtraArgs defines additional command line options that are provided to Envoy.<br />More info: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#command-line-options<br />Note: some command line options are used internally(e.g. --log-level) so they cannot be provided here. |
| `mergeGateways` | _boolean_ | false | MergeGateways defines if Gateway resources should be merged onto the same Envoy Proxy Infrastructure.<br />Setting this field to true would merge all Gateway Listeners under the parent Gateway Class.<br />This means that the port, protocol and hostname tuple must be unique for every listener.<br />If a duplicate listener is detected, the newer listener (based on timestamp) will be rejected and its status will be updated with a "Accepted=False" condition. |
| `shutdown` | _[ShutdownConfig](#shutdownconfig)_ | false | Shutdown defines configuration for graceful envoy shutdown process. |
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/testdata/httproute-routingtype.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: custom-proxy-config
namespace: gateway-conformance-infra
spec:
routingType: service
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: httproute-to-backend-fqdn
namespace: gateway-conformance-infra
spec:
parentRefs:
- name: same-namespace
rules:
- matches:
- path:
type: PathPrefix
value: /backend-fqdn
backendRefs:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-fqdn-http2
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-fqdn
namespace: gateway-conformance-infra
spec:
endpoints:
- fqdn:
hostname: infra-backend-v1.gateway-conformance-infra.svc.cluster.local
port: 8080
48 changes: 48 additions & 0 deletions test/e2e/tests/routingtype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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, EnvoyGatewayRoutingType)
}

var EnvoyGatewayRoutingType = suite.ConformanceTest{
ShortName: "EnvoyGatewayRoutingType",
Description: "Routes with a backend ref to a backend",
Manifests: []string{
"testdata/httproute-routingtype.yaml",
},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "httproute-to-backend-fqdn", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

expectedResponse := http.ExpectedResponse{
Request: http.Request{
Path: "/backend-fqdn",
},
Response: http.Response{
StatusCode: 200,
},
Namespace: ns,
}

http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)
},
}

0 comments on commit a03c362

Please sign in to comment.