forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e test for Gateway with EnvoyProxy (envoyproxy#4548)
* e2e test for Gateway with EnvoyProxy Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * remove unnecessary comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit 217c6a5) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
- Loading branch information
1 parent
562efa9
commit 5514167
Showing
3 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: gateway-with-envoyproxy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
gatewayClassName: "{GATEWAY_CLASS_NAME}" | ||
infrastructure: | ||
parametersRef: | ||
group: gateway.envoyproxy.io | ||
kind: EnvoyProxy | ||
name: test | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: EnvoyProxy | ||
metadata: | ||
namespace: gateway-conformance-infra | ||
name: test | ||
spec: | ||
routingType: Service | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: http-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: gateway-with-envoyproxy | ||
rules: | ||
- matches: | ||
- path: | ||
value: / | ||
backendRefs: | ||
- name: infra-backend-v1 | ||
port: 8080 | ||
filters: | ||
- type: ResponseHeaderModifier | ||
responseHeaderModifier: | ||
add: | ||
- name: upstream-host | ||
value: '%UPSTREAM_HOST%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
"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, GatewayWithEnvoyProxy) | ||
} | ||
|
||
var GatewayWithEnvoyProxy = suite.ConformanceTest{ | ||
ShortName: "Gateway with EnvoyProxy", | ||
Description: "Attach an EnvoyProxy to a Gateway", | ||
Manifests: []string{"testdata/gateway-with-envoyproxy.yaml"}, | ||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { | ||
t.Run("Attach an EnvoyProxy to a Gateway and set RoutingType to Service", func(t *testing.T) { | ||
ns := "gateway-conformance-infra" | ||
routeNN := types.NamespacedName{Name: "http-route", Namespace: ns} | ||
gwNN := types.NamespacedName{Name: "gateway-with-envoyproxy", Namespace: ns} | ||
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) | ||
|
||
backendNN := types.NamespacedName{Name: "infra-backend-v1", Namespace: ns} | ||
svc := corev1.Service{} | ||
require.NoError(t, suite.Client.Get(context.Background(), backendNN, &svc)) | ||
|
||
expectedResponse := http.ExpectedResponse{ | ||
Request: http.Request{ | ||
Path: "/basic-auth-1", | ||
}, | ||
Response: http.Response{ | ||
StatusCode: 200, | ||
|
||
// Verify that the RouteType is set to Service by the attached EnvoyProxy | ||
Headers: map[string]string{ | ||
"upstream-host": svc.Spec.ClusterIP + ":8080", | ||
}, | ||
}, | ||
Namespace: ns, | ||
} | ||
|
||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse) | ||
}) | ||
}, | ||
} |