From 1f1dedfd31da4648cbfcd7f373b6e9bd18955cad Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Wed, 21 Feb 2024 18:02:40 +0800 Subject: [PATCH 01/16] add e2e test for merge gateways feature Signed-off-by: shawnh2 --- test/config/gatewayclass.yaml | 20 ++++ test/e2e/e2e_test.go | 24 +++++ test/e2e/testdata/basic-merge-gateways.yaml | 110 ++++++++++++++++++++ test/e2e/tests/merge-gateways.go | 92 ++++++++++++++++ test/e2e/tests/tests.go | 5 +- 5 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 test/e2e/testdata/basic-merge-gateways.yaml create mode 100644 test/e2e/tests/merge-gateways.go diff --git a/test/config/gatewayclass.yaml b/test/config/gatewayclass.yaml index 24985fa0874..f63f5696c4c 100644 --- a/test/config/gatewayclass.yaml +++ b/test/config/gatewayclass.yaml @@ -59,3 +59,23 @@ spec: environment: name: ENVOY_GATEWAY_NAMESPACE defaultValue: "envoy-gateway-system" +--- +kind: GatewayClass +apiVersion: gateway.networking.k8s.io/v1 +metadata: + name: merge-gateways +spec: + controllerName: gateway.envoyproxy.io/gatewayclass-controller + parametersRef: + group: gateway.envoyproxy.io + kind: EnvoyProxy + name: merge-gateways-config + namespace: envoy-gateway-system +--- +apiVersion: gateway.envoyproxy.io/v1alpha1 +kind: EnvoyProxy +metadata: + name: merge-gateways-config + namespace: envoy-gateway-system +spec: + mergeGateways: true diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 1c6d5b22f92..1fb642263c1 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -18,6 +18,7 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -51,4 +52,27 @@ func TestE2E(t *testing.T) { cSuite.Setup(t) t.Logf("Running %d E2E tests", len(tests.ConformanceTests)) cSuite.Run(t, tests.ConformanceTests) + + t.Run("MergeGateways E2E", func(t *testing.T) { + mergeGatewaysSuiteGatewayClassName := "merge-gateways" + + t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t\n supported features: [%v]\n exempt features: [%v]", + mergeGatewaysSuiteGatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.SupportedFeatures, *flags.ExemptFeatures) + + mergeGatewaysSuite := suite.New(suite.Options{ + Client: client, + GatewayClassName: mergeGatewaysSuiteGatewayClassName, + Debug: *flags.ShowDebug, + }) + + // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, + // since this test suite reuse the base resources of previous test suite. + mergeGatewaysSuite.Applier.FS = Manifests + mergeGatewaysSuite.Applier.GatewayClass = mergeGatewaysSuiteGatewayClassName + mergeGatewaysSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, mergeGatewaysSuite.Client, + mergeGatewaysSuite.TimeoutConfig, mergeGatewaysSuite.GatewayClassName) + + t.Logf("Running %d E2E tests for MergeGateways feature", len(tests.MergeGatewaysTests)) + mergeGatewaysSuite.Run(t, tests.MergeGatewaysTests) + }) } diff --git a/test/e2e/testdata/basic-merge-gateways.yaml b/test/e2e/testdata/basic-merge-gateways.yaml new file mode 100644 index 00000000000..502eb2092b0 --- /dev/null +++ b/test/e2e/testdata/basic-merge-gateways.yaml @@ -0,0 +1,110 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: merged-gateway-1 + namespace: gateway-conformance-infra +spec: + gatewayClassName: merge-gateways + listeners: + - allowedRoutes: + namespaces: + from: Same + name: http1 + port: 8080 + protocol: HTTP +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: merged-gateway-2 + namespace: gateway-conformance-infra +spec: + gatewayClassName: merge-gateways + listeners: + - allowedRoutes: + namespaces: + from: Same + name: http2 + port: 8081 + protocol: HTTP +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: merged-gateway-3 + namespace: gateway-conformance-infra +spec: + gatewayClassName: merge-gateways + listeners: + - allowedRoutes: + namespaces: + from: Same + name: http3 + port: 8082 + protocol: HTTP +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: merged-gateway-route-1 + namespace: gateway-conformance-infra +spec: + parentRefs: + - name: merged-gateway-1 + hostnames: + - "www.example1.com" + rules: + - backendRefs: + - group: "" + kind: Service + name: infra-backend-v1 + port: 8080 + weight: 1 + matches: + - path: + type: PathPrefix + value: /merge1 +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: merged-gateway-route-2 + namespace: gateway-conformance-infra +spec: + parentRefs: + - name: merged-gateway-2 + hostnames: + - "www.example2.com" + rules: + - backendRefs: + - group: "" + kind: Service + name: infra-backend-v2 + port: 8080 + weight: 1 + matches: + - path: + type: PathPrefix + value: /merge2 +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: merged-gateway-route-3 + namespace: gateway-conformance-infra +spec: + parentRefs: + - name: merged-gateway-3 + hostnames: + - "www.example3.com" + rules: + - backendRefs: + - group: "" + kind: Service + name: infra-backend-v3 + port: 8080 + weight: 1 + matches: + - path: + type: PathPrefix + value: /merge3 diff --git a/test/e2e/tests/merge-gateways.go b/test/e2e/tests/merge-gateways.go new file mode 100644 index 00000000000..971872d5bfb --- /dev/null +++ b/test/e2e/tests/merge-gateways.go @@ -0,0 +1,92 @@ +// 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 ( + "net" + "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() { + MergeGatewaysTests = append(MergeGatewaysTests, MergeGatewaysTest) +} + +var MergeGatewaysTest = suite.ConformanceTest{ + ShortName: "BasicMergeGateways", + Description: "Basic test for MergeGateways feature", + Manifests: []string{"testdata/basic-merge-gateways.yaml"}, + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + ns := "gateway-conformance-infra" + + route1NN := types.NamespacedName{Name: "merged-gateway-route-1", Namespace: ns} + gw1NN := types.NamespacedName{Name: "merged-gateway-1", Namespace: ns} + gw1HostPort := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gw1NN), route1NN) + + route2NN := types.NamespacedName{Name: "merged-gateway-route-2", Namespace: ns} + gw2NN := types.NamespacedName{Name: "merged-gateway-2", Namespace: ns} + gw2HostPort := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gw2NN), route2NN) + + route3NN := types.NamespacedName{Name: "merged-gateway-route-3", Namespace: ns} + gw3NN := types.NamespacedName{Name: "merged-gateway-3", Namespace: ns} + gw3HostPort := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gw3NN), route3NN) + + t.Run("merged three gateways under the same namespace with http routes", func(t *testing.T) { + gw1Addr, _, err := net.SplitHostPort(gw1HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw1HostPort, gw1NN.Name, err) + } + + gw2Addr, _, err := net.SplitHostPort(gw2HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw2HostPort, gw2NN.Name, err) + } + + gw3Addr, _, err := net.SplitHostPort(gw3HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw2HostPort, gw2NN.Name, err) + } + + if gw1Addr != gw2Addr { + t.Errorf("inconsistent gateway address %s and %s for %s and %s", gw1Addr, gw2Addr, gw1NN.String(), gw2NN.String()) + t.FailNow() + } + + if gw2Addr != gw3Addr { + t.Errorf("inconsistent gateway address %s and %s for %s and %s", gw2Addr, gw3Addr, gw2NN.String(), gw3NN.String()) + t.FailNow() + } + + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gw1HostPort, http.ExpectedResponse{ + Request: http.Request{Path: "/merge1", Host: "www.example1.com"}, + Response: http.Response{StatusCode: 200}, + Namespace: ns, + Backend: "infra-backend-v1", + }) + + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gw2HostPort, http.ExpectedResponse{ + Request: http.Request{Path: "/merge2", Host: "www.example2.com"}, + Response: http.Response{StatusCode: 200}, + Namespace: ns, + Backend: "infra-backend-v2", + }) + + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gw3HostPort, http.ExpectedResponse{ + Request: http.Request{Path: "/merge3", Host: "www.example3.com"}, + Response: http.Response{StatusCode: 200}, + Namespace: ns, + Backend: "infra-backend-v3", + }) + }) + }, +} diff --git a/test/e2e/tests/tests.go b/test/e2e/tests/tests.go index 7343ee0ced3..8c2c45a6ea4 100644 --- a/test/e2e/tests/tests.go +++ b/test/e2e/tests/tests.go @@ -10,4 +10,7 @@ package tests import "sigs.k8s.io/gateway-api/conformance/utils/suite" -var ConformanceTests []suite.ConformanceTest +var ( + ConformanceTests []suite.ConformanceTest + MergeGatewaysTests []suite.ConformanceTest +) From f7161d9064e1e0cd57625625b114764dcc6c9c71 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Wed, 21 Feb 2024 22:28:40 +0800 Subject: [PATCH 02/16] address comments Signed-off-by: shawnh2 --- test/e2e/tests/merge-gateways.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/e2e/tests/merge-gateways.go b/test/e2e/tests/merge-gateways.go index 971872d5bfb..5e8659bb5dd 100644 --- a/test/e2e/tests/merge-gateways.go +++ b/test/e2e/tests/merge-gateways.go @@ -54,16 +54,12 @@ var MergeGatewaysTest = suite.ConformanceTest{ gw3Addr, _, err := net.SplitHostPort(gw3HostPort) if err != nil { - t.Errorf("failed to split hostport %s of gateway %s: %v", gw2HostPort, gw2NN.Name, err) - } - - if gw1Addr != gw2Addr { - t.Errorf("inconsistent gateway address %s and %s for %s and %s", gw1Addr, gw2Addr, gw1NN.String(), gw2NN.String()) - t.FailNow() + t.Errorf("failed to split hostport %s of gateway %s: %v", gw3HostPort, gw3NN.Name, err) } - if gw2Addr != gw3Addr { - t.Errorf("inconsistent gateway address %s and %s for %s and %s", gw2Addr, gw3Addr, gw2NN.String(), gw3NN.String()) + if gw1Addr != gw2Addr || gw2Addr != gw3Addr { + t.Errorf("inconsistent gateway address %s: %s, %s: %s and %s: %s", + gw1NN.String(), gw1Addr, gw2NN.String(), gw2Addr, gw3NN.String(), gw3Addr) t.FailNow() } From 5ea21e52782ff0bdcd63c838fa8cf129d77df350 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Sat, 24 Feb 2024 17:30:56 +0800 Subject: [PATCH 03/16] add e2e test for conflicted merge gateways case Signed-off-by: shawnh2 --- test/e2e/testdata/basic-merge-gateways.yaml | 37 +++++++++ test/e2e/tests/merge-gateways.go | 88 ++++++++++++++++----- 2 files changed, 107 insertions(+), 18 deletions(-) diff --git a/test/e2e/testdata/basic-merge-gateways.yaml b/test/e2e/testdata/basic-merge-gateways.yaml index 502eb2092b0..f32fddb29ee 100644 --- a/test/e2e/testdata/basic-merge-gateways.yaml +++ b/test/e2e/testdata/basic-merge-gateways.yaml @@ -44,6 +44,21 @@ spec: protocol: HTTP --- apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: merged-gateway-4 + namespace: gateway-conformance-infra +spec: + gatewayClassName: merge-gateways + listeners: + - allowedRoutes: + namespaces: + from: Same + name: http3 + port: 8082 + protocol: HTTP +--- +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: merged-gateway-route-1 @@ -108,3 +123,25 @@ spec: - path: type: PathPrefix value: /merge3 +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: merged-gateway-route-4 + namespace: gateway-conformance-infra +spec: + parentRefs: + - name: merged-gateway-4 + hostnames: + - "www.example4.com" + rules: + - backendRefs: + - group: "" + kind: Service + name: infra-backend-v3 + port: 8080 + weight: 1 + matches: + - path: + type: PathPrefix + value: /merge4 diff --git a/test/e2e/tests/merge-gateways.go b/test/e2e/tests/merge-gateways.go index 5e8659bb5dd..9553907c5c2 100644 --- a/test/e2e/tests/merge-gateways.go +++ b/test/e2e/tests/merge-gateways.go @@ -12,7 +12,9 @@ import ( "net" "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -41,28 +43,28 @@ var MergeGatewaysTest = suite.ConformanceTest{ gw3NN := types.NamespacedName{Name: "merged-gateway-3", Namespace: ns} gw3HostPort := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gw3NN), route3NN) - t.Run("merged three gateways under the same namespace with http routes", func(t *testing.T) { - gw1Addr, _, err := net.SplitHostPort(gw1HostPort) - if err != nil { - t.Errorf("failed to split hostport %s of gateway %s: %v", gw1HostPort, gw1NN.Name, err) - } + gw1Addr, _, err := net.SplitHostPort(gw1HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw1HostPort, gw1NN.String(), err) + } - gw2Addr, _, err := net.SplitHostPort(gw2HostPort) - if err != nil { - t.Errorf("failed to split hostport %s of gateway %s: %v", gw2HostPort, gw2NN.Name, err) - } + gw2Addr, _, err := net.SplitHostPort(gw2HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw2HostPort, gw2NN.String(), err) + } - gw3Addr, _, err := net.SplitHostPort(gw3HostPort) - if err != nil { - t.Errorf("failed to split hostport %s of gateway %s: %v", gw3HostPort, gw3NN.Name, err) - } + gw3Addr, _, err := net.SplitHostPort(gw3HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw3HostPort, gw3NN.String(), err) + } - if gw1Addr != gw2Addr || gw2Addr != gw3Addr { - t.Errorf("inconsistent gateway address %s: %s, %s: %s and %s: %s", - gw1NN.String(), gw1Addr, gw2NN.String(), gw2Addr, gw3NN.String(), gw3Addr) - t.FailNow() - } + if gw1Addr != gw2Addr || gw2Addr != gw3Addr { + t.Errorf("inconsistent gateway address %s: %s, %s: %s and %s: %s", + gw1NN.String(), gw1Addr, gw2NN.String(), gw2Addr, gw3NN.String(), gw3Addr) + t.FailNow() + } + t.Run("merged three gateways under the same namespace with http routes", func(t *testing.T) { http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gw1HostPort, http.ExpectedResponse{ Request: http.Request{Path: "/merge1", Host: "www.example1.com"}, Response: http.Response{StatusCode: 200}, @@ -84,5 +86,55 @@ var MergeGatewaysTest = suite.ConformanceTest{ Backend: "infra-backend-v3", }) }) + + t.Run("gateway with conflicted listener cannot be merged", func(t *testing.T) { + route4NN := types.NamespacedName{Name: "merged-gateway-route-4", Namespace: ns} + gw4NN := types.NamespacedName{Name: "merged-gateway-4", Namespace: ns} + + gw4HostPort, err := kubernetes.WaitForGatewayAddress(t, suite.Client, suite.TimeoutConfig, gw4NN) + if err != nil { + t.Errorf("failed to get the address of gateway %s", gw4NN.String()) + } + + // Even the gateway cannot be merged, it still has the consistent address. + gw4Addr, _, err := net.SplitHostPort(gw4HostPort) + if err != nil { + t.Errorf("failed to split hostport %s of gateway %s: %v", gw4HostPort, gw4NN.String(), err) + t.FailNow() + } + + if gw4Addr != gw1Addr { + t.Errorf("gateway %s has inconsistent address %s with other gateways %s", + gw4NN.String(), gw4Addr, gw1Addr) + t.FailNow() + } + + conflictedListener := []gwapiv1.ListenerStatus{{ + Name: gwapiv1.SectionName("http3"), + SupportedKinds: []gwapiv1.RouteGroupKind{}, + Conditions: []metav1.Condition{{ + Type: string(gwapiv1.ListenerConditionConflicted), + Status: metav1.ConditionTrue, + Reason: string(gwapiv1.ListenerReasonHostnameConflict), + }}, + AttachedRoutes: 1, + }} + kubernetes.GatewayStatusMustHaveListeners(t, suite.Client, suite.TimeoutConfig, gw4NN, conflictedListener) + + expectedHTTPRouteCondition := metav1.Condition{ + Type: string(gwapiv1.RouteConditionAccepted), + Status: metav1.ConditionFalse, + Reason: "NoReadyListeners", + } + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, route4NN, gw4NN, expectedHTTPRouteCondition) + + // Not merged gateway should not receive any traffic. + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gw4HostPort, http.ExpectedResponse{ + Request: http.Request{Path: "/merge4", Host: "www.example4.com"}, + Response: http.Response{StatusCode: 404}, + Namespace: ns, + }) + }) + }, } From 4ef12328619efae70f2b9cca22f55a672d9daee1 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Sat, 24 Feb 2024 17:52:26 +0800 Subject: [PATCH 04/16] add supportedKinds for listener status Signed-off-by: shawnh2 --- test/e2e/tests/merge-gateways.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/e2e/tests/merge-gateways.go b/test/e2e/tests/merge-gateways.go index 9553907c5c2..9b725cb40f2 100644 --- a/test/e2e/tests/merge-gateways.go +++ b/test/e2e/tests/merge-gateways.go @@ -18,6 +18,8 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + + "github.com/envoyproxy/gateway/internal/gatewayapi" ) func init() { @@ -110,8 +112,17 @@ var MergeGatewaysTest = suite.ConformanceTest{ } conflictedListener := []gwapiv1.ListenerStatus{{ - Name: gwapiv1.SectionName("http3"), - SupportedKinds: []gwapiv1.RouteGroupKind{}, + Name: gwapiv1.SectionName("http3"), + SupportedKinds: []gwapiv1.RouteGroupKind{ + { + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), + Kind: gatewayapi.KindHTTPRoute, + }, + { + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), + Kind: gatewayapi.KindGRPCRoute, + }, + }, Conditions: []metav1.Condition{{ Type: string(gwapiv1.ListenerConditionConflicted), Status: metav1.ConditionTrue, From 8df3a0df435cc23ee9911600492834a49e8992cc Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Wed, 28 Feb 2024 09:00:51 +0800 Subject: [PATCH 05/16] abstract new e2e test for gateway class as a function Signed-off-by: shawnh2 --- test/e2e/e2e_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 1fb642263c1..036a24daf97 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -53,26 +53,30 @@ func TestE2E(t *testing.T) { t.Logf("Running %d E2E tests", len(tests.ConformanceTests)) cSuite.Run(t, tests.ConformanceTests) - t.Run("MergeGateways E2E", func(t *testing.T) { - mergeGatewaysSuiteGatewayClassName := "merge-gateways" + // E2E tests for other GatewayClasses. + NewE2ETestForGatewayClass(t, "MergeGateways E2E", "merge-gateways", client, tests.MergeGatewaysTests) +} +// NewE2ETestForGatewayClass creates a new e2e test for gateway class based on the base e2e resources. +func NewE2ETestForGatewayClass(t *testing.T, testName, gatewayClassName string, client client.Client, testSet []suite.ConformanceTest) { + t.Run(testName, func(t *testing.T) { t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t\n supported features: [%v]\n exempt features: [%v]", - mergeGatewaysSuiteGatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.SupportedFeatures, *flags.ExemptFeatures) + gatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.SupportedFeatures, *flags.ExemptFeatures) - mergeGatewaysSuite := suite.New(suite.Options{ + newSuite := suite.New(suite.Options{ Client: client, - GatewayClassName: mergeGatewaysSuiteGatewayClassName, + GatewayClassName: gatewayClassName, Debug: *flags.ShowDebug, }) // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, // since this test suite reuse the base resources of previous test suite. - mergeGatewaysSuite.Applier.FS = Manifests - mergeGatewaysSuite.Applier.GatewayClass = mergeGatewaysSuiteGatewayClassName - mergeGatewaysSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, mergeGatewaysSuite.Client, - mergeGatewaysSuite.TimeoutConfig, mergeGatewaysSuite.GatewayClassName) + newSuite.Applier.FS = Manifests + newSuite.Applier.GatewayClass = gatewayClassName + newSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, + newSuite.Client, newSuite.TimeoutConfig, newSuite.GatewayClassName) - t.Logf("Running %d E2E tests for MergeGateways feature", len(tests.MergeGatewaysTests)) - mergeGatewaysSuite.Run(t, tests.MergeGatewaysTests) + t.Logf("Running %d E2E tests for GatewayClass: %s", len(testSet), gatewayClassName) + newSuite.Run(t, testSet) }) } From 8647f62f33f21e9d01c5b71c75ba2fae9c09f520 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Fri, 8 Mar 2024 10:50:28 +0800 Subject: [PATCH 06/16] update code Signed-off-by: shawnh2 --- test/e2e/e2e_test.go | 40 +++++++++++-------- ...{backend-upgrade.go => backend_upgrade.go} | 0 .../{merge-gateways.go => merge_gateways.go} | 0 ...{oidc-testclient.go => oidc_testclient.go} | 0 4 files changed, 24 insertions(+), 16 deletions(-) rename test/e2e/tests/{backend-upgrade.go => backend_upgrade.go} (100%) rename test/e2e/tests/{merge-gateways.go => merge_gateways.go} (100%) rename test/e2e/tests/{oidc-testclient.go => oidc_testclient.go} (100%) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 3b11afc5b73..8e14478e905 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -58,30 +58,38 @@ func TestE2E(t *testing.T) { t.Logf("Running %d E2E tests", len(tests.ConformanceTests)) cSuite.Run(t, tests.ConformanceTests) - // E2E tests for other GatewayClasses. - NewE2ETestForGatewayClass(t, "MergeGateways E2E", "merge-gateways", client, tests.MergeGatewaysTests) + // E2E tests for all the other GatewayClasses. + // Mainly for Multiple GatewayClass per controller and MergeGateways related features. + RunE2ETestForGatewayClass(t, "MergeGateways E2E", "merge-gateways", c, tests.MergeGatewaysTests) } -// NewE2ETestForGatewayClass creates a new e2e test for gateway class based on the base e2e resources. -func NewE2ETestForGatewayClass(t *testing.T, testName, gatewayClassName string, client client.Client, testSet []suite.ConformanceTest) { +// RunE2ETestForGatewayClass creates a new e2e test for gatewayclass based on the base e2e resources. +func RunE2ETestForGatewayClass(t *testing.T, testName, gatewayClassName string, c client.Client, testSet []suite.ConformanceTest) { t.Run(testName, func(t *testing.T) { t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t\n supported features: [%v]\n exempt features: [%v]", gatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.SupportedFeatures, *flags.ExemptFeatures) - newSuite := suite.New(suite.Options{ - Client: client, - GatewayClassName: gatewayClassName, - Debug: *flags.ShowDebug, - }) - - // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, - // since this test suite reuse the base resources of previous test suite. - newSuite.Applier.FS = Manifests - newSuite.Applier.GatewayClass = gatewayClassName - newSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, - newSuite.Client, newSuite.TimeoutConfig, newSuite.GatewayClassName) + newSuite := newE2ETestSuiteForGatewayClass(t, gatewayClassName, c) t.Logf("Running %d E2E tests for GatewayClass: %s", len(testSet), gatewayClassName) newSuite.Run(t, testSet) }) } + +// newE2ETestSuiteForGatewayClass returns a new e2e test suite for gatewayclass based on the base e2e resources. +func newE2ETestSuiteForGatewayClass(t *testing.T, gatewayClassName string, c client.Client) *suite.ConformanceTestSuite { + newSuite := suite.New(suite.Options{ + Client: c, + GatewayClassName: gatewayClassName, + Debug: *flags.ShowDebug, + }) + + // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, + // since this test suite reuse the base resources of previous test suite. + newSuite.Applier.FS = Manifests + newSuite.Applier.GatewayClass = gatewayClassName + newSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, + newSuite.Client, newSuite.TimeoutConfig, newSuite.GatewayClassName) + + return newSuite +} diff --git a/test/e2e/tests/backend-upgrade.go b/test/e2e/tests/backend_upgrade.go similarity index 100% rename from test/e2e/tests/backend-upgrade.go rename to test/e2e/tests/backend_upgrade.go diff --git a/test/e2e/tests/merge-gateways.go b/test/e2e/tests/merge_gateways.go similarity index 100% rename from test/e2e/tests/merge-gateways.go rename to test/e2e/tests/merge_gateways.go diff --git a/test/e2e/tests/oidc-testclient.go b/test/e2e/tests/oidc_testclient.go similarity index 100% rename from test/e2e/tests/oidc-testclient.go rename to test/e2e/tests/oidc_testclient.go From 16bd4dd44e3a84e6d95673590d98ba3ef06036e3 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Thu, 14 Mar 2024 11:30:47 +0800 Subject: [PATCH 07/16] add a test-suite for merge-gateways Signed-off-by: shawnh2 --- test/e2e/e2e_test.go | 36 ----------- .../e2e/merge-gateways/merge_gateways_test.go | 60 +++++++++++++++++++ test/e2e/tests/eg_upgrade.go | 4 ++ test/e2e/upgrade/eg_upgrade_test.go | 8 +-- tools/make/kube.mk | 6 +- 5 files changed, 72 insertions(+), 42 deletions(-) create mode 100644 test/e2e/merge-gateways/merge_gateways_test.go diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 8e14478e905..46e0fb30bec 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -18,7 +18,6 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" - "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -57,39 +56,4 @@ func TestE2E(t *testing.T) { cSuite.Setup(t) t.Logf("Running %d E2E tests", len(tests.ConformanceTests)) cSuite.Run(t, tests.ConformanceTests) - - // E2E tests for all the other GatewayClasses. - // Mainly for Multiple GatewayClass per controller and MergeGateways related features. - RunE2ETestForGatewayClass(t, "MergeGateways E2E", "merge-gateways", c, tests.MergeGatewaysTests) -} - -// RunE2ETestForGatewayClass creates a new e2e test for gatewayclass based on the base e2e resources. -func RunE2ETestForGatewayClass(t *testing.T, testName, gatewayClassName string, c client.Client, testSet []suite.ConformanceTest) { - t.Run(testName, func(t *testing.T) { - t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t\n supported features: [%v]\n exempt features: [%v]", - gatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.SupportedFeatures, *flags.ExemptFeatures) - - newSuite := newE2ETestSuiteForGatewayClass(t, gatewayClassName, c) - - t.Logf("Running %d E2E tests for GatewayClass: %s", len(testSet), gatewayClassName) - newSuite.Run(t, testSet) - }) -} - -// newE2ETestSuiteForGatewayClass returns a new e2e test suite for gatewayclass based on the base e2e resources. -func newE2ETestSuiteForGatewayClass(t *testing.T, gatewayClassName string, c client.Client) *suite.ConformanceTestSuite { - newSuite := suite.New(suite.Options{ - Client: c, - GatewayClassName: gatewayClassName, - Debug: *flags.ShowDebug, - }) - - // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, - // since this test suite reuse the base resources of previous test suite. - newSuite.Applier.FS = Manifests - newSuite.Applier.GatewayClass = gatewayClassName - newSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, - newSuite.Client, newSuite.TimeoutConfig, newSuite.GatewayClassName) - - return newSuite } diff --git a/test/e2e/merge-gateways/merge_gateways_test.go b/test/e2e/merge-gateways/merge_gateways_test.go new file mode 100644 index 00000000000..bd9ea2ea49e --- /dev/null +++ b/test/e2e/merge-gateways/merge_gateways_test.go @@ -0,0 +1,60 @@ +// 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 e2e + +import ( + "flag" + "testing" + + "github.com/stretchr/testify/require" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/config" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + "sigs.k8s.io/gateway-api/conformance/utils/flags" + "sigs.k8s.io/gateway-api/conformance/utils/suite" + + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" + "github.com/envoyproxy/gateway/test/e2e" + "github.com/envoyproxy/gateway/test/e2e/tests" +) + +func TestMergeGateways(t *testing.T) { + flag.Parse() + + cfg, err := config.GetConfig() + require.NoError(t, err) + + c, err := client.New(cfg, client.Options{}) + require.NoError(t, err) + require.NoError(t, gwapiv1a2.AddToScheme(c.Scheme())) + require.NoError(t, gwapiv1.AddToScheme(c.Scheme())) + require.NoError(t, egv1a1.AddToScheme(c.Scheme())) + + if flags.RunTest != nil && *flags.RunTest != "" { + t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", + *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) + } else { + t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", + *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) + } + + cSuite := suite.New(suite.Options{ + Client: c, + GatewayClassName: *flags.GatewayClassName, + Debug: *flags.ShowDebug, + CleanupBaseResources: *flags.CleanupBaseResources, + FS: &e2e.Manifests, + RunTest: *flags.RunTest, + }) + + cSuite.Setup(t) + t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) + cSuite.Run(t, tests.MergeGatewaysTests) +} diff --git a/test/e2e/tests/eg_upgrade.go b/test/e2e/tests/eg_upgrade.go index ffa61d1139e..f14ecb66899 100644 --- a/test/e2e/tests/eg_upgrade.go +++ b/test/e2e/tests/eg_upgrade.go @@ -24,6 +24,10 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/suite" ) +func init() { + UpgradeTests = append(UpgradeTests, EGUpgradeTest) +} + var EGUpgradeTest = suite.ConformanceTest{ ShortName: "EGUpgrade", Description: "Upgrading from the last eg version should not lead to failures", diff --git a/test/e2e/upgrade/eg_upgrade_test.go b/test/e2e/upgrade/eg_upgrade_test.go index 431ecf01960..a1be622cb0f 100644 --- a/test/e2e/upgrade/eg_upgrade_test.go +++ b/test/e2e/upgrade/eg_upgrade_test.go @@ -10,14 +10,11 @@ package upgrade import ( "flag" - "testing" "github.com/stretchr/testify/require" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" - gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" @@ -30,6 +27,7 @@ import ( func TestEGUpgrade(t *testing.T) { flag.Parse() + cfg, err := config.GetConfig() require.NoError(t, err) @@ -57,6 +55,6 @@ func TestEGUpgrade(t *testing.T) { }) cSuite.Setup(t) - t.Logf("Upgrade: Running tests") - cSuite.Run(t, []suite.ConformanceTest{tests.EnvoyShutdownTest, tests.EGUpgradeTest}) + t.Logf("Running %d Upgrade tests", len(tests.UpgradeTests)) + cSuite.Run(t, tests.UpgradeTests) } diff --git a/tools/make/kube.mk b/tools/make/kube.mk index a862d9db20a..419d60f8d1f 100644 --- a/tools/make/kube.mk +++ b/tools/make/kube.mk @@ -122,17 +122,21 @@ run-e2e: install-e2e-telemetry kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available kubectl apply -f test/config/gatewayclass.yaml ifeq ($(E2E_RUN_TEST),) - go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false + go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) + go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) else ifeq ($(E2E_RUN_EG_UPGRADE_TESTS),false) go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ --run-test $(E2E_RUN_TEST) + go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ + --run-test $(E2E_RUN_TEST) else go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ --run-test $(E2E_RUN_TEST) endif endif + .PHONY: install-e2e-telemetry install-e2e-telemetry: prepare-helm-repo install-fluent-bit install-loki install-tempo install-otel-collector install-prometheus @$(LOG_TARGET) From 8a86e002bf33d06162bae6c08437c98ac8e589af Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Fri, 15 Mar 2024 08:46:39 +0800 Subject: [PATCH 08/16] fix resources cleanup Signed-off-by: shawnh2 --- tools/make/kube.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/make/kube.mk b/tools/make/kube.mk index 419d60f8d1f..34f4e9648b8 100644 --- a/tools/make/kube.mk +++ b/tools/make/kube.mk @@ -122,12 +122,12 @@ run-e2e: install-e2e-telemetry kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available kubectl apply -f test/config/gatewayclass.yaml ifeq ($(E2E_RUN_TEST),) - go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) - go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) + go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false + go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=false go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) else ifeq ($(E2E_RUN_EG_UPGRADE_TESTS),false) - go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ + go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false \ --run-test $(E2E_RUN_TEST) go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ --run-test $(E2E_RUN_TEST) From a4fc3f150d8b8fe40a6a8525a8913496de6067ef Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Wed, 20 Mar 2024 13:31:44 +0800 Subject: [PATCH 09/16] passing necessary args for suite instead of calling Setup Signed-off-by: shawnh2 --- test/e2e/merge-gateways/merge_gateways_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/e2e/merge-gateways/merge_gateways_test.go b/test/e2e/merge-gateways/merge_gateways_test.go index bd9ea2ea49e..be793750765 100644 --- a/test/e2e/merge-gateways/merge_gateways_test.go +++ b/test/e2e/merge-gateways/merge_gateways_test.go @@ -18,6 +18,7 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -47,14 +48,18 @@ func TestMergeGateways(t *testing.T) { cSuite := suite.New(suite.Options{ Client: c, - GatewayClassName: *flags.GatewayClassName, Debug: *flags.ShowDebug, CleanupBaseResources: *flags.CleanupBaseResources, - FS: &e2e.Manifests, RunTest: *flags.RunTest, }) - cSuite.Setup(t) + // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, + // since this test suite reuse the base resources of previous test suite. + cSuite.Applier.FS = e2e.Manifests + cSuite.Applier.GatewayClass = *flags.GatewayClassName + cSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, + cSuite.Client, cSuite.TimeoutConfig, cSuite.GatewayClassName) + t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) cSuite.Run(t, tests.MergeGatewaysTests) } From c3df6a1907b70ee53e90bc6c70405200568a567e Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Wed, 20 Mar 2024 13:59:21 +0800 Subject: [PATCH 10/16] fix gateway class name arg Signed-off-by: shawnh2 --- test/e2e/merge-gateways/merge_gateways_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/merge-gateways/merge_gateways_test.go b/test/e2e/merge-gateways/merge_gateways_test.go index be793750765..a67da075f67 100644 --- a/test/e2e/merge-gateways/merge_gateways_test.go +++ b/test/e2e/merge-gateways/merge_gateways_test.go @@ -48,6 +48,7 @@ func TestMergeGateways(t *testing.T) { cSuite := suite.New(suite.Options{ Client: c, + GatewayClassName: *flags.GatewayClassName, Debug: *flags.ShowDebug, CleanupBaseResources: *flags.CleanupBaseResources, RunTest: *flags.RunTest, From 6a32018782b307436f1f24fd2551fc327b84f8af Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Sun, 14 Apr 2024 21:48:30 +0800 Subject: [PATCH 11/16] address comments Signed-off-by: shawnh2 --- tools/make/kube.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/make/kube.mk b/tools/make/kube.mk index c6eccb64887..efa10754f94 100644 --- a/tools/make/kube.mk +++ b/tools/make/kube.mk @@ -126,13 +126,13 @@ run-e2e: install-e2e-telemetry kubectl apply -f test/config/gatewayclass.yaml ifeq ($(E2E_RUN_TEST),) go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false - go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=false - go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) + go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false + go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) else ifeq ($(E2E_RUN_EG_UPGRADE_TESTS),false) - go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false \ + go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false \ --run-test $(E2E_RUN_TEST) - go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ + go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ --run-test $(E2E_RUN_TEST) else go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ From eb7629ac6cb56c0439969282871c9445043d6111 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Mon, 15 Apr 2024 13:34:46 +0800 Subject: [PATCH 12/16] sort imports for envoy_shutdown and setup suite for merge-gateways Signed-off-by: shawnh2 --- .../merge_gateways_test.go | 12 +++--------- test/e2e/tests/envoy_shutdown.go | 11 ++++------- 2 files changed, 7 insertions(+), 16 deletions(-) rename test/e2e/{merge-gateways => merge_gateways}/merge_gateways_test.go (79%) diff --git a/test/e2e/merge-gateways/merge_gateways_test.go b/test/e2e/merge_gateways/merge_gateways_test.go similarity index 79% rename from test/e2e/merge-gateways/merge_gateways_test.go rename to test/e2e/merge_gateways/merge_gateways_test.go index a67da075f67..d70fc56247b 100644 --- a/test/e2e/merge-gateways/merge_gateways_test.go +++ b/test/e2e/merge_gateways/merge_gateways_test.go @@ -6,7 +6,7 @@ //go:build e2e // +build e2e -package e2e +package merge_gateways import ( "flag" @@ -18,7 +18,6 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" - "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -51,16 +50,11 @@ func TestMergeGateways(t *testing.T) { GatewayClassName: *flags.GatewayClassName, Debug: *flags.ShowDebug, CleanupBaseResources: *flags.CleanupBaseResources, + FS: &e2e.Manifests, RunTest: *flags.RunTest, }) - // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, - // since this test suite reuse the base resources of previous test suite. - cSuite.Applier.FS = e2e.Manifests - cSuite.Applier.GatewayClass = *flags.GatewayClassName - cSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, - cSuite.Client, cSuite.TimeoutConfig, cSuite.GatewayClassName) - + cSuite.Setup(t) t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) cSuite.Run(t, tests.MergeGatewaysTests) } diff --git a/test/e2e/tests/envoy_shutdown.go b/test/e2e/tests/envoy_shutdown.go index 6e870a265e6..4cb1e68ac7b 100644 --- a/test/e2e/tests/envoy_shutdown.go +++ b/test/e2e/tests/envoy_shutdown.go @@ -16,25 +16,22 @@ import ( "testing" "time" - "github.com/envoyproxy/gateway/api/v1alpha1" - "fortio.org/fortio/periodic" - - "github.com/envoyproxy/gateway/internal/gatewayapi" - "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/proxy" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/gateway-api/conformance/utils/config" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + + "github.com/envoyproxy/gateway/api/v1alpha1" + "github.com/envoyproxy/gateway/internal/gatewayapi" + "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/proxy" ) func init() { From a4517cc41e28edb62f3e2fb91f0225a6c758d47f Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Mon, 15 Apr 2024 14:06:57 +0800 Subject: [PATCH 13/16] fix lint Signed-off-by: shawnh2 --- test/e2e/merge_gateways/merge_gateways_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/merge_gateways/merge_gateways_test.go b/test/e2e/merge_gateways/merge_gateways_test.go index d70fc56247b..3b3404dfd27 100644 --- a/test/e2e/merge_gateways/merge_gateways_test.go +++ b/test/e2e/merge_gateways/merge_gateways_test.go @@ -6,7 +6,7 @@ //go:build e2e // +build e2e -package merge_gateways +package mergegateways import ( "flag" From 29e77caac28ca6bb212e7fbb131cd557d6f4da75 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Mon, 15 Apr 2024 14:17:48 +0800 Subject: [PATCH 14/16] fix gen-check Signed-off-by: shawnh2 --- site/content/en/latest/api/extension_types.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index 8d64f7d9b42..d8b5d11689b 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -59,12 +59,12 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | + | `backendRefs` | _[BackendRef](#backendref) array_ | true | BackendRefs references a Kubernetes object that represents the gRPC service to which
the access logs will be sent. Currently only Service is supported. | | `logName` | _string_ | false | LogName defines the friendly name of the access log to be returned in
StreamAccessLogsMessage.Identifier. This allows the access log server
to differentiate between different access logs coming from the same Envoy. | | `type` | _[ALSEnvoyProxyAccessLogType](#alsenvoyproxyaccesslogtype)_ | true | Type defines the type of accesslog. Supported types are "HTTP" and "TCP". | | `http` | _[ALSEnvoyProxyHTTPAccessLogConfig](#alsenvoyproxyhttpaccesslogconfig)_ | false | HTTP defines additional configuration specific to HTTP access logs. | - #### ALSEnvoyProxyAccessLogType _Underlying type:_ _string_ @@ -87,11 +87,11 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | + | `requestHeaders` | _string array_ | false | RequestHeaders defines request headers to include in log entries sent to the access log service. | | `responseHeaders` | _string array_ | false | ResponseHeaders defines response headers to include in log entries sent to the access log service. | | `responseTrailers` | _string array_ | false | ResponseTrailers defines response trailers to include in log entries sent to the access log service. | - #### ActiveHealthCheck From e97db3dd33646203423908e255eee5a94cf6e6ef Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Mon, 15 Apr 2024 15:29:05 +0800 Subject: [PATCH 15/16] change kube.mk merge gateways path Signed-off-by: shawnh2 --- site/content/en/latest/api/extension_types.md | 9 +++++++-- tools/make/kube.mk | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index e45d3ca0a9e..7c9b355fefb 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -64,12 +64,12 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | - | `backendRefs` | _[BackendRef](#backendref) array_ | true | BackendRefs references a Kubernetes object that represents the gRPC service to which
the access logs will be sent. Currently only Service is supported. | | `logName` | _string_ | false | LogName defines the friendly name of the access log to be returned in
StreamAccessLogsMessage.Identifier. This allows the access log server
to differentiate between different access logs coming from the same Envoy. | | `type` | _[ALSEnvoyProxyAccessLogType](#alsenvoyproxyaccesslogtype)_ | true | Type defines the type of accesslog. Supported types are "HTTP" and "TCP". | | `http` | _[ALSEnvoyProxyHTTPAccessLogConfig](#alsenvoyproxyhttpaccesslogconfig)_ | false | HTTP defines additional configuration specific to HTTP access logs. | + #### ALSEnvoyProxyAccessLogType _Underlying type:_ _string_ @@ -79,6 +79,10 @@ _Underlying type:_ _string_ _Appears in:_ - [ALSEnvoyProxyAccessLog](#alsenvoyproxyaccesslog) +| Value | Description | +| ----- | ----------- | +| `HTTP` | ALSEnvoyProxyAccessLogTypeHTTP defines the HTTP access log type and will populate StreamAccessLogsMessage.http_logs.
| +| `TCP` | ALSEnvoyProxyAccessLogTypeTCP defines the TCP access log type and will populate StreamAccessLogsMessage.tcp_logs.
| #### ALSEnvoyProxyHTTPAccessLogConfig @@ -92,11 +96,11 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | - | `requestHeaders` | _string array_ | false | RequestHeaders defines request headers to include in log entries sent to the access log service. | | `responseHeaders` | _string array_ | false | ResponseHeaders defines response headers to include in log entries sent to the access log service. | | `responseTrailers` | _string array_ | false | ResponseTrailers defines response trailers to include in log entries sent to the access log service. | + #### ActiveHealthCheck @@ -2194,6 +2198,7 @@ _Appears in:_ | Value | Description | | ----- | ----------- | +| `ALS` | ProxyAccessLogSinkTypeALS defines the gRPC Access Log Service (ALS) sink.
The service must implement the Envoy gRPC Access Log Service streaming API:
https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/accesslog/v3/als.proto
| | `File` | ProxyAccessLogSinkTypeFile defines the file accesslog sink.
| | `OpenTelemetry` | ProxyAccessLogSinkTypeOpenTelemetry defines the OpenTelemetry accesslog sink.
When the provider is Kubernetes, EnvoyGateway always sends `k8s.namespace.name`
and `k8s.pod.name` as additional attributes.
| diff --git a/tools/make/kube.mk b/tools/make/kube.mk index efa10754f94..8d8c96a76d2 100644 --- a/tools/make/kube.mk +++ b/tools/make/kube.mk @@ -126,11 +126,11 @@ run-e2e: install-e2e-telemetry kubectl apply -f test/config/gatewayclass.yaml ifeq ($(E2E_RUN_TEST),) go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=false - go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false + go test -v -tags e2e ./test/e2e/merge_gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false go test -v -tags e2e ./test/e2e/upgrade --gateway-class=upgrade --debug=true --cleanup-base-resources=$(E2E_CLEANUP) else ifeq ($(E2E_RUN_EG_UPGRADE_TESTS),false) - go test -v -tags e2e ./test/e2e/merge-gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false \ + go test -v -tags e2e ./test/e2e/merge_gateways --gateway-class=merge-gateways --debug=true --cleanup-base-resources=false \ --run-test $(E2E_RUN_TEST) go test -v -tags e2e ./test/e2e --gateway-class=envoy-gateway --debug=true --cleanup-base-resources=$(E2E_CLEANUP) \ --run-test $(E2E_RUN_TEST) From 2c65b0bbec932a9ec8d1c9865ad83352e2cfa1aa Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Sun, 21 Apr 2024 13:44:11 +0800 Subject: [PATCH 16/16] only setting up necessary arguments for merged gateway e2e test to be able to run Signed-off-by: shawnh2 --- test/e2e/merge_gateways/merge_gateways_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/e2e/merge_gateways/merge_gateways_test.go b/test/e2e/merge_gateways/merge_gateways_test.go index 3b3404dfd27..30e82aa6cdd 100644 --- a/test/e2e/merge_gateways/merge_gateways_test.go +++ b/test/e2e/merge_gateways/merge_gateways_test.go @@ -18,6 +18,7 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/flags" + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -50,11 +51,16 @@ func TestMergeGateways(t *testing.T) { GatewayClassName: *flags.GatewayClassName, Debug: *flags.ShowDebug, CleanupBaseResources: *flags.CleanupBaseResources, - FS: &e2e.Manifests, RunTest: *flags.RunTest, }) - cSuite.Setup(t) + // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, + // since this test suite reuse the base resources of previous test suite. + cSuite.Applier.FS = e2e.Manifests + cSuite.Applier.GatewayClass = *flags.GatewayClassName + cSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, + cSuite.Client, cSuite.TimeoutConfig, cSuite.GatewayClassName) + t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) cSuite.Run(t, tests.MergeGatewaysTests) }