Skip to content

Commit

Permalink
Merge branch 'backend_tls' of https://github.com/alexwo/gateway
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Volchok <alex.volchok@sap.com>
  • Loading branch information
alexwo committed Apr 24, 2024
2 parents 6d98016 + 27a770f commit c17d15b
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 14 deletions.
20 changes: 20 additions & 0 deletions test/config/gatewayclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,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 mergegateways

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:
- 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)
}

var EGUpgradeTest = suite.ConformanceTest{
ShortName: "EGUpgrade",
Description: "Upgrading from the last eg version should not lead to failures",
Expand Down
11 changes: 4 additions & 7 deletions test/e2e/tests/envoy_shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading

0 comments on commit c17d15b

Please sign in to comment.