-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* e2e: multiple gc test Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * update multiple gc tests Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
- Loading branch information
1 parent
7fdc738
commit 845a5ec
Showing
7 changed files
with
364 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,110 @@ | ||
// 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 multiplegc | ||
|
||
import ( | ||
"flag" | ||
"io/fs" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
"sigs.k8s.io/gateway-api/conformance/utils/flags" | ||
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes" | ||
"sigs.k8s.io/gateway-api/conformance/utils/suite" | ||
"sigs.k8s.io/gateway-api/pkg/features" | ||
|
||
"github.com/envoyproxy/gateway/test/e2e" | ||
"github.com/envoyproxy/gateway/test/e2e/tests" | ||
) | ||
|
||
func TestMultipleGC(t *testing.T) { | ||
flag.Parse() | ||
|
||
cfg, err := config.GetConfig() | ||
require.NoError(t, err) | ||
|
||
c, err := client.New(cfg, client.Options{}) | ||
require.NoError(t, err) | ||
|
||
// Install all the scheme to kubernetes client. | ||
e2e.CheckInstallScheme(t, c) | ||
|
||
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) | ||
} | ||
t.Run("Internet GC Test", func(t *testing.T) { | ||
t.Parallel() | ||
internetGatewaySuiteGatewayClassName := "internet" | ||
internetGatewaySuite, err := suite.NewConformanceTestSuite(suite.ConformanceOptions{ | ||
Client: c, | ||
GatewayClassName: internetGatewaySuiteGatewayClassName, | ||
Debug: *flags.ShowDebug, | ||
CleanupBaseResources: *flags.CleanupBaseResources, | ||
RunTest: *flags.RunTest, | ||
// SupportedFeatures cannot be empty, so we set it to SupportGateway | ||
// All e2e tests should leave Features empty. | ||
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway), | ||
SkipTests: []string{}, | ||
}) | ||
if err != nil { | ||
t.Fatalf("Failed to create ConformanceTestSuite: %v", err) | ||
} | ||
|
||
// 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. | ||
internetGatewaySuite.Applier.ManifestFS = []fs.FS{e2e.Manifests} | ||
internetGatewaySuite.Applier.GatewayClass = internetGatewaySuiteGatewayClassName | ||
internetGatewaySuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, internetGatewaySuite.Client, internetGatewaySuite.TimeoutConfig, internetGatewaySuite.GatewayClassName) | ||
|
||
t.Logf("Running %d MultipleGC tests", len(tests.MultipleGCTests[internetGatewaySuiteGatewayClassName])) | ||
|
||
err = internetGatewaySuite.Run(t, tests.MultipleGCTests[internetGatewaySuiteGatewayClassName]) | ||
if err != nil { | ||
t.Fatalf("Failed to run InternetGC tests: %v", err) | ||
} | ||
}) | ||
|
||
t.Run("Private GC Test", func(t *testing.T) { | ||
t.Parallel() | ||
privateGatewaySuiteGatewayClassName := "private" | ||
privateGatewaySuite, err := suite.NewConformanceTestSuite(suite.ConformanceOptions{ | ||
Client: c, | ||
GatewayClassName: privateGatewaySuiteGatewayClassName, | ||
Debug: *flags.ShowDebug, | ||
CleanupBaseResources: *flags.CleanupBaseResources, | ||
RunTest: *flags.RunTest, | ||
// SupportedFeatures cannot be empty, so we set it to SupportGateway | ||
// All e2e tests should leave Features empty. | ||
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway), | ||
SkipTests: []string{}, | ||
}) | ||
if err != nil { | ||
t.Fatalf("Failed to create ConformanceTestSuite: %v", err) | ||
} | ||
|
||
// 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. | ||
privateGatewaySuite.Applier.ManifestFS = []fs.FS{e2e.Manifests} | ||
privateGatewaySuite.Applier.GatewayClass = privateGatewaySuiteGatewayClassName | ||
privateGatewaySuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, privateGatewaySuite.Client, privateGatewaySuite.TimeoutConfig, privateGatewaySuite.GatewayClassName) | ||
|
||
t.Logf("Running %d MultipleGC tests", len(tests.MultipleGCTests[privateGatewaySuiteGatewayClassName])) | ||
err = privateGatewaySuite.Run(t, tests.MultipleGCTests[privateGatewaySuiteGatewayClassName]) | ||
if err != nil { | ||
t.Fatalf("Failed to run PrivateGC tests: %v", err) | ||
} | ||
}) | ||
} |
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,74 @@ | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: internet-gateway | ||
namespace: gateway-conformance-infra | ||
spec: | ||
gatewayClassName: internet | ||
listeners: | ||
- name: http | ||
port: 80 | ||
protocol: HTTP | ||
allowedRoutes: | ||
namespaces: | ||
from: Same | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: internet-backend | ||
namespace: gateway-conformance-infra | ||
spec: | ||
selector: | ||
app: internet-backend | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 3000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: internet-backend | ||
namespace: gateway-conformance-infra | ||
labels: | ||
app: internet-backend | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: internet-backend | ||
template: | ||
metadata: | ||
labels: | ||
app: internet-backend | ||
spec: | ||
containers: | ||
- name: internet-backend | ||
image: gcr.io/k8s-staging-ingressconformance/echoserver:v20221109-7ee2f3e | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
resources: | ||
requests: | ||
cpu: 10m | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: internet-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: internet-gateway | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: internet-backend | ||
port: 8080 |
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,74 @@ | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: private-gateway | ||
namespace: gateway-conformance-infra | ||
spec: | ||
gatewayClassName: private | ||
listeners: | ||
- name: http | ||
port: 80 | ||
protocol: HTTP | ||
allowedRoutes: | ||
namespaces: | ||
from: Same | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: private-backend | ||
namespace: gateway-conformance-infra | ||
spec: | ||
selector: | ||
app: private-backend | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 3000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: private-backend | ||
namespace: gateway-conformance-infra | ||
labels: | ||
app: private-backend | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: private-backend | ||
template: | ||
metadata: | ||
labels: | ||
app: private-backend | ||
spec: | ||
containers: | ||
- name: private-backend | ||
image: gcr.io/k8s-staging-ingressconformance/echoserver:v20221109-7ee2f3e | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
resources: | ||
requests: | ||
cpu: 10m | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: private-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: private-gateway | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: private-backend | ||
port: 8080 |
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,85 @@ | ||
// 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. | ||
|
||
// This file contains code derived from upstream gateway-api, it will be moved to upstream. | ||
|
||
//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" | ||
) | ||
|
||
var ( | ||
InternetGCTests []suite.ConformanceTest | ||
PrivateGCTests []suite.ConformanceTest | ||
) | ||
|
||
func init() { | ||
MultipleGCTests = make(map[string][]suite.ConformanceTest) | ||
InternetGCTests = append(InternetGCTests, InternetGCTest) | ||
PrivateGCTests = append(PrivateGCTests, PrivateGCTest) | ||
MultipleGCTests["internet"] = InternetGCTests | ||
MultipleGCTests["private"] = PrivateGCTests | ||
} | ||
|
||
var InternetGCTest = suite.ConformanceTest{ | ||
ShortName: "InternetGC", | ||
Description: "Testing multiple GatewayClass with the same controller", | ||
Manifests: []string{"testdata/internet-gc.yaml"}, | ||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { | ||
t.Run("internet gc", func(t *testing.T) { | ||
ns := "gateway-conformance-infra" | ||
routeNN := types.NamespacedName{Name: "internet-route", Namespace: ns} | ||
gwNN := types.NamespacedName{Name: "internet-gateway", Namespace: ns} | ||
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) | ||
OkResp := http.ExpectedResponse{ | ||
Request: http.Request{ | ||
Path: "/", | ||
}, | ||
Response: http.Response{ | ||
StatusCode: 200, | ||
}, | ||
Namespace: ns, | ||
} | ||
|
||
// Send a request to an valid path and expect a successful response | ||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp) | ||
}) | ||
}, | ||
} | ||
|
||
var PrivateGCTest = suite.ConformanceTest{ | ||
ShortName: "PrivateGC", | ||
Description: "Testing multiple GatewayClass with the same controller", | ||
Manifests: []string{"testdata/private-gc.yaml"}, | ||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { | ||
t.Run("private gc", func(t *testing.T) { | ||
ns := "gateway-conformance-infra" | ||
routeNN := types.NamespacedName{Name: "private-route", Namespace: ns} | ||
gwNN := types.NamespacedName{Name: "private-gateway", Namespace: ns} | ||
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) | ||
OkResp := http.ExpectedResponse{ | ||
Request: http.Request{ | ||
Path: "/", | ||
}, | ||
Response: http.Response{ | ||
StatusCode: 200, | ||
}, | ||
Namespace: ns, | ||
} | ||
|
||
// Send a request to an valid path and expect a successful response | ||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp) | ||
}) | ||
}, | ||
} |
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
Oops, something went wrong.