Skip to content
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: add e2e test for MergeGateways feature #2665

Merged
merged 33 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1f1dedf
add e2e test for merge gateways feature
shawnh2 Feb 21, 2024
f7161d9
address comments
shawnh2 Feb 21, 2024
ae3a2d0
Merge branch 'main' of github.com:envoyproxy/gateway into merge-gatew…
shawnh2 Feb 24, 2024
5ea21e5
add e2e test for conflicted merge gateways case
shawnh2 Feb 24, 2024
4ef1232
add supportedKinds for listener status
shawnh2 Feb 24, 2024
893f5ee
resolve conflicts
shawnh2 Feb 28, 2024
f5cfbb0
Merge branch 'main' of github.com:envoyproxy/gateway into merge-gatew…
shawnh2 Feb 28, 2024
8df3a0d
abstract new e2e test for gateway class as a function
shawnh2 Feb 28, 2024
ef9baee
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Mar 8, 2024
8647f62
update code
shawnh2 Mar 8, 2024
17c1d61
resolve conflicts
shawnh2 Mar 12, 2024
7c93dda
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Mar 13, 2024
e604db2
resolve conflicts
shawnh2 Mar 14, 2024
16bd4dd
add a test-suite for merge-gateways
shawnh2 Mar 14, 2024
61b138e
Merge branch 'merge-gateways-e2e-test' of https://github.com/shawnh2/…
shawnh2 Mar 14, 2024
ca592b5
Merge branch 'main' of github.com:envoyproxy/gateway into merge-gatew…
shawnh2 Mar 15, 2024
8a86e00
fix resources cleanup
shawnh2 Mar 15, 2024
a55ed51
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Mar 20, 2024
a4fc3f1
passing necessary args for suite instead of calling Setup
shawnh2 Mar 20, 2024
c3df6a1
fix gateway class name arg
shawnh2 Mar 20, 2024
9117cd6
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Apr 10, 2024
e822a61
resolve conflicts
shawnh2 Apr 14, 2024
6a32018
address comments
shawnh2 Apr 14, 2024
eb7629a
sort imports for envoy_shutdown and setup suite for merge-gateways
shawnh2 Apr 15, 2024
a4517cc
fix lint
shawnh2 Apr 15, 2024
50512dc
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Apr 15, 2024
29e77ca
fix gen-check
shawnh2 Apr 15, 2024
0402ca5
Merge branch 'main' of github.com:envoyproxy/gateway into merge-gatew…
shawnh2 Apr 15, 2024
e97db3d
change kube.mk merge gateways path
shawnh2 Apr 15, 2024
3131079
Merge branch 'main' of github.com:envoyproxy/gateway into merge-gatew…
shawnh2 Apr 21, 2024
2c65b0b
only setting up necessary arguments for merged gateway e2e test to be…
shawnh2 Apr 21, 2024
85fadad
Merge branch 'main' into merge-gateways-e2e-test
zirain Apr 23, 2024
0b4509a
Merge branch 'main' into merge-gateways-e2e-test
shawnh2 Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion test/config/gatewayclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,23 @@ spec:
kubernetes:
envoyDeployment:
replicas: 2

---
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
66 changes: 66 additions & 0 deletions test/e2e/merge-gateways/merge_gateways_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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/kubernetes"
"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,
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)

t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests))
cSuite.Run(t, tests.MergeGatewaysTests)
}
147 changes: 147 additions & 0 deletions test/e2e/testdata/basic-merge-gateways.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
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: Gateway
metadata:
name: merged-gateway-4
namespace: gateway-conformance-infra
spec:
gatewayClassName: merge-gateways
listeners:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the instability because you are using the same listener name and port b/w merged-gateway-4 & merged-gateway-3
cc @cnvergence

Copy link
Contributor Author

@shawnh2 shawnh2 Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the merged-gateway-4 is deliberately collide with merged-gateway-3. the test case for merged-gateway-4 is to make sure the right status will be surfaced if the merge gateway is conflict with another.

- 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
---
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
4 changes: 4 additions & 0 deletions test/e2e/tests/eg_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

func init() {
UpgradeTests = append(UpgradeTests, EGUpgradeTest)
shawnh2 marked this conversation as resolved.
Show resolved Hide resolved
}

var EGUpgradeTest = suite.ConformanceTest{
ShortName: "EGUpgrade",
Description: "Upgrading from the last eg version should not lead to failures",
Expand Down
Loading
Loading