diff --git a/changelog/v1.18.0-beta1/e2e-tests-cleanup.yaml b/changelog/v1.18.0-beta1/e2e-tests-cleanup.yaml new file mode 100644 index 000000000000..50503732c179 --- /dev/null +++ b/changelog/v1.18.0-beta1/e2e-tests-cleanup.yaml @@ -0,0 +1,8 @@ +changelog: + - type: NON_USER_FACING + issueLink: https://github.com/solo-io/gloo/issues/9353 + resolvesIssue: false + description: >- + Make Kubernetes E2E tests easily importable and runnable from enterprise suites + + skipCI-docs-build:true diff --git a/changelog/v1.18.0-beta1/stateful_session_docs.yaml b/changelog/v1.18.0-beta1/stateful_session_docs.yaml new file mode 100644 index 000000000000..8777a304fab2 --- /dev/null +++ b/changelog/v1.18.0-beta1/stateful_session_docs.yaml @@ -0,0 +1,6 @@ +changelog: + - type: NON_USER_FACING + issueLink: https://github.com/solo-io/gloo/issues/9104 + resolvesIssue: false + description: >- + Update "session affinity" Documentation to cover new stateful session filter diff --git a/docs/content/installation/advanced_configuration/session_affinity.md b/docs/content/installation/advanced_configuration/session_affinity.md index f12b8ac25ac7..8cf09f6f9370 100644 --- a/docs/content/installation/advanced_configuration/session_affinity.md +++ b/docs/content/installation/advanced_configuration/session_affinity.md @@ -7,7 +7,6 @@ description: Configure Gloo Edge session affinity (sticky sessions) For certain applications deployed across multiple replicas, it may be desirable to route all traffic from a single client session to the same instance of the application. This can help reduce latency through better use of caches. This load balancer behavior is referred to as Session Affinity or Sticky Sessions. Gloo Edge exposes Envoy's full session affinity capabilities, as described below. --- - ## Configuration overview There are two steps to configuring session affinity: @@ -341,3 +340,114 @@ Return to the app in your browser and refresh the page a few times. You should s ``` Now that you have configured cookie-based sticky sessions, web requests from your browser will be served by the same instance of the counter app (unless you delete the cookie). + + +## Stateful Session Filter (Enterprise Only) + +Envoy provides another method of implementing sticky sessions using the [Stateful Session](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/stateful_session_filter) filter, which implements "strong" stickiness. + +This example uses the session affinity app resources that are created in the [Apply the DaemonSet](#apply-the-daemonset) section. No additional modifications to the upstream or virtual service are required. + +### Requirements + +- A Kubernetes cluster with at least two nodes with Gloo Edge Enterprise installed. +- Permission to deploy a DaemonSet and edit Gloo Edge resources. + +### Cookie-based stateful session filter + +When enabling the cookie-based stateful session filter, a hash of the upstream that serves the request is stored in a `statefulsessioncookie` cookie. In subsequent requests, the same upstream resource is used to fulfill the request. + +1. [Apply the session affinity DaemonSet](#apply-the-daemonset). + +2. Edit the gateway proxy. + ```sh + kubectl edit gateways.gateway.solo.io -n gloo-system gateway-proxy + ``` + +3. Add the following configuration to the `spec` section of your gateway to enable the cookie-based stateful session filter. + {{< highlight yaml "hl_lines=4-11" >}} + spec: + bindAddress: '::' + bindPort: 8080 + httpGateway: + options: + statefulSession: + cookieBased: + cookie: + name: statefulsessioncookie + path: /route1 + ttl: 60s + proxyNames: + - gateway-proxy + ssl: false + useProxyProto: false + {{< /highlight >}} + +4. Get the URL of the gateway proxy. + ```sh + glooctl proxy url + ``` + +5. Open a web browser and navigate to the `/route1` path. For example, if your gateway proxy is `http://34.111.222.111:80`, type `http://34.111.222.111:80/route1` in to your web browser. +6. Refresh the page a couple of times. Verify that you see an increasing count as the requests are now all directed to the same upstream. + + Example output: + ``` + 5,6,7,8,... + ``` + +### Header-based stateful session filter + +When enabling the header-based stateful session filter for a route, a `statefulsessionheader` header is returned with the hash of the upstream that served the request. You must use this header in subsequent requests to enable session stickiness. + +1. [Apply the session affinity DaemonSet](#apply-the-daemonset). + +2. Edit the gateway proxy. + ```sh + kubectl edit gateways.gateway.solo.io -n gloo-system gateway-proxy + ``` + +3. Add the following configuration to the `spec` section of your gateway to enable the header-based stateful session filter. + {{< highlight yaml "hl_lines=4-8" >}} + spec: + bindAddress: '::' + bindPort: 8080 + httpGateway: + options: + statefulSession: + headerBased: + headerName: statefulsessionheader + proxyNames: + - gateway-proxy + ssl: false + useProxyProto: false + {{< /highlight >}} + +4. Get the URL of the gateway proxy. + ```sh + glooctl proxy url + ``` + +5. Send a request to the `/route1` path. Requests to the `/route1` path return a `statefulsessionheader` header that you can send in subsequent requests to enable the session stickiness. Because headers are not automatically applied by the browser, it is easier to test this behavior by using a curl request. + ```sh + curl -v $(glooctl proxy url)/route1 + ``` + + Example output: + ``` + < HTTP/1.1 200 OK + < date: Tue, 11 Jun 2024 15:11:23 GMT + < content-length: 1 + < content-type: text/plain; charset=utf-8 + < x-envoy-upstream-service-time: 10 + < statefulsessionheader: MTAuMjQ0LjAuNDU6ODA4MA== + < server: envoy + < + * Connection #0 to host 127.0.0.1 left intact + 3% + ``` + +6. Send another request to the `/route1` path and include the `statefulsessionheader` that was returned in the previous step. Verify that you see an increased count in your response as the requests are now all directed to the same upstream. + ```sh + curl -v -H "statefulsessionheader: MTAuMjQ0LjAuNDU6ODA4MA==" $(glooctl proxy url)/route1 + ``` diff --git a/test/kubernetes/e2e/README.md b/test/kubernetes/e2e/README.md index acf286f2e457..20e856f068cc 100644 --- a/test/kubernetes/e2e/README.md +++ b/test/kubernetes/e2e/README.md @@ -18,11 +18,21 @@ We define all tests in the [features](./features) package. This is done for a va 1. We group the tests by feature, so it's easy to identify which behaviors we assert for a given feature. 2. We can invoke that same test against different `TestInstallation`s. This means we can test a feature against a variety of installation values, or even against OSS and Enterprise installations. +## Test Suites +A Test Suite is a subset of the Feature concept. A single Feature has at minimum one Test Suite, and can have many. Each Test Suite within the feature must have a function which satisfies the signature `NewSuiteFunc` found in [suite.go](./suite.go). + +These test suites are registered by a name and this func in [Tests](#tests) to be run against various `TestInstallation`s. + ## Tests This package holds the entry point for each of our `TestInstallation`. See [Load balancing tests](./load_balancing_tests.md) for more information about how these tests are run in CI. +Each `*_test.go` file contains a specific test installation and exists within the `tests_test` package. In order for tests to be imported and run from other repos, each `*_test.go` file has a corresponding `*_test.go` file which exists in the `tests` package. This is done because `_test` packages cannot be imported. + +In order to add a feature suite to be run in a given test installation, it must be added to the exported function in the corresponding `*_tests.go` file. +e.g. In order to add a feature suite to be run with the test installation defined in `istio_test.go`, we have to register it by adding it to `IstioTests()` in `istio_tests.go` following the existing paradigm. + ## Environment Variables Some tests may require environment variables to be set. Some required env vars are: @@ -50,4 +60,4 @@ Below are a set of known areas of improvement. The goal is to provide a starting - **Improved install action(s)**: We rely on the [SoloTestHelper](/test/kube2e/helper/install.go) currently, and it would be nice if we relied directly on Helm or Glooctl. - **Cluster provisioning**: We rely on the [setup-kind](/ci/kind/setup-kind.sh) script to provision a cluster. We should make this more flexible by providing a configurable, declarative way to do this. - **Istio action**: We need a way to perform Istio actions against a cluster. -- **Argo action**: We need an easy utility to perform ArgoCD commands against a cluster. \ No newline at end of file +- **Argo action**: We need an easy utility to perform ArgoCD commands against a cluster. diff --git a/test/kubernetes/e2e/features/deployer/istio_integration_deployer_suite.go b/test/kubernetes/e2e/features/deployer/istio_integration_deployer_suite.go index ca2be33c97ac..dcbf8760b6f6 100644 --- a/test/kubernetes/e2e/features/deployer/istio_integration_deployer_suite.go +++ b/test/kubernetes/e2e/features/deployer/istio_integration_deployer_suite.go @@ -13,6 +13,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/e2e" ) +var _ e2e.NewSuiteFunc = NewIstioIntegrationTestingSuite + // istioIntegrationDeployerSuite is the entire Suite of tests for the "deployer" feature that relies on an Istio installation // The "deployer" code can be found here: /projects/gateway2/deployer type istioIntegrationDeployerSuite struct { diff --git a/test/kubernetes/e2e/features/deployer/suite.go b/test/kubernetes/e2e/features/deployer/suite.go index d351fbe8dc80..a087e8a404c7 100644 --- a/test/kubernetes/e2e/features/deployer/suite.go +++ b/test/kubernetes/e2e/features/deployer/suite.go @@ -21,6 +21,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/testutils/runtime" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "deployer" feature // The "deployer" code can be found here: /projects/gateway2/deployer type testingSuite struct { diff --git a/test/kubernetes/e2e/features/example/suite.go b/test/kubernetes/e2e/features/example/suite.go index 4da810b2d2e2..b69787805e62 100644 --- a/test/kubernetes/e2e/features/example/suite.go +++ b/test/kubernetes/e2e/features/example/suite.go @@ -9,6 +9,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/e2e" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "example" feature // Typically, we would include a link to the feature code here type testingSuite struct { diff --git a/test/kubernetes/e2e/features/glooctl/check_suite.go b/test/kubernetes/e2e/features/glooctl/check_suite.go index 607901282ce0..ada55dc36732 100644 --- a/test/kubernetes/e2e/features/glooctl/check_suite.go +++ b/test/kubernetes/e2e/features/glooctl/check_suite.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/suite" ) +var _ e2e.NewSuiteFunc = NewCheckSuite + // checkSuite contains the set of tests to validate the behavior of `glooctl check` // These tests attempt to mirror: https://github.com/solo-io/gloo/blob/v1.16.x/test/kube2e/glooctl/check_test.go type checkSuite struct { diff --git a/test/kubernetes/e2e/features/glooctl/debug_suite.go b/test/kubernetes/e2e/features/glooctl/debug_suite.go index 887d9f7ce955..e37aa3144bbf 100644 --- a/test/kubernetes/e2e/features/glooctl/debug_suite.go +++ b/test/kubernetes/e2e/features/glooctl/debug_suite.go @@ -9,6 +9,8 @@ import ( "github.com/stretchr/testify/suite" ) +var _ e2e.NewSuiteFunc = NewDebugSuite + // debugSuite contains the set of tests to validate the behavior of `glooctl debug` // These tests attempt to mirror: https://github.com/solo-io/gloo/blob/v1.16.x/test/kube2e/glooctl/debug_test.go type debugSuite struct { diff --git a/test/kubernetes/e2e/features/glooctl/get_proxy_suite.go b/test/kubernetes/e2e/features/glooctl/get_proxy_suite.go index c96b4e949175..39e2cfdd4175 100644 --- a/test/kubernetes/e2e/features/glooctl/get_proxy_suite.go +++ b/test/kubernetes/e2e/features/glooctl/get_proxy_suite.go @@ -19,6 +19,8 @@ import ( "github.com/stretchr/testify/suite" ) +var _ e2e.NewSuiteFunc = NewGetProxySuite + var ( yamlSeparator = regexp.MustCompile("\n---\n") ) diff --git a/test/kubernetes/e2e/features/glooctl/istio_inject_suite.go b/test/kubernetes/e2e/features/glooctl/istio_inject_suite.go index d34c8c4e6a31..f3f1baea9cc1 100644 --- a/test/kubernetes/e2e/features/glooctl/istio_inject_suite.go +++ b/test/kubernetes/e2e/features/glooctl/istio_inject_suite.go @@ -13,6 +13,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewIstioInjectTestingSuite + // istioInjectTestingSuite is the entire Suite of tests for the "glooctl istio inject" integration cases // NOTE: This suite is not intended to be run as a standalone test suite. It applies the "glooctl istio inject" command // to an existing installation of Gloo Gateway and verifies that the necessary resources are created, but does not clean diff --git a/test/kubernetes/e2e/features/glooctl/istio_uninject_suite.go b/test/kubernetes/e2e/features/glooctl/istio_uninject_suite.go index 50e394c3b625..9e7421231b97 100644 --- a/test/kubernetes/e2e/features/glooctl/istio_uninject_suite.go +++ b/test/kubernetes/e2e/features/glooctl/istio_uninject_suite.go @@ -13,6 +13,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewIstioUninjectTestingSuite + // istioUninjectTestingSuite is the entire Suite of tests for the "glooctl istio uninject" integration cases // NOTE: This suite is not intended to be run as a standalone test suite. It applies the "glooctl unistio inject" command // to an existing installation of Gloo Gateway where the istio-proxy and sds containers have already been injected diff --git a/test/kubernetes/e2e/features/headless_svc/gloo_gateway_suite.go b/test/kubernetes/e2e/features/headless_svc/gloo_gateway_suite.go index e712aea39594..3b6ca78c0c35 100644 --- a/test/kubernetes/e2e/features/headless_svc/gloo_gateway_suite.go +++ b/test/kubernetes/e2e/features/headless_svc/gloo_gateway_suite.go @@ -13,6 +13,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewEdgeGatewayHeadlessSvcSuite + type edgeGatewaySuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/headless_svc/k8s_gw_suite.go b/test/kubernetes/e2e/features/headless_svc/k8s_gw_suite.go index 13e6fbc3957d..749ae3ec5891 100644 --- a/test/kubernetes/e2e/features/headless_svc/k8s_gw_suite.go +++ b/test/kubernetes/e2e/features/headless_svc/k8s_gw_suite.go @@ -13,6 +13,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/testutils/resources" ) +var _ e2e.NewSuiteFunc = NewK8sGatewayHeadlessSvcSuite + type k8sGatewaySuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/http_listener_options/http_lis_opt_suite.go b/test/kubernetes/e2e/features/http_listener_options/http_lis_opt_suite.go index 7650cb2db8b6..e0f5177ae90b 100644 --- a/test/kubernetes/e2e/features/http_listener_options/http_lis_opt_suite.go +++ b/test/kubernetes/e2e/features/http_listener_options/http_lis_opt_suite.go @@ -15,6 +15,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "HttpListenerOptions" feature type testingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/istio/gloo_gateway_auto_mtls_suite.go b/test/kubernetes/e2e/features/istio/gloo_gateway_auto_mtls_suite.go index 218cda8d9101..90225d77622b 100644 --- a/test/kubernetes/e2e/features/istio/gloo_gateway_auto_mtls_suite.go +++ b/test/kubernetes/e2e/features/istio/gloo_gateway_auto_mtls_suite.go @@ -16,6 +16,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewGlooIstioAutoMtlsSuite + // glooIstioAutoMtlsTestingSuite is the entire Suite of tests for the "Istio" integration cases where auto mTLS is enabled type glooIstioAutoMtlsTestingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/istio/gloo_gateway_no_auto_mtls_suite.go b/test/kubernetes/e2e/features/istio/gloo_gateway_no_auto_mtls_suite.go index 17750aa590cd..34a054483213 100644 --- a/test/kubernetes/e2e/features/istio/gloo_gateway_no_auto_mtls_suite.go +++ b/test/kubernetes/e2e/features/istio/gloo_gateway_no_auto_mtls_suite.go @@ -16,6 +16,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewGlooTestingSuite + // glooIstioTestingSuite is the entire Suite of tests for the "Istio" integration cases where auto mtls is disabled // and Upstreams do not have sslConfig values set type glooIstioTestingSuite struct { diff --git a/test/kubernetes/e2e/features/istio/k8s_gateway_auto_mtls_suite.go b/test/kubernetes/e2e/features/istio/k8s_gateway_auto_mtls_suite.go index 489685cdcf43..659e73bb9017 100644 --- a/test/kubernetes/e2e/features/istio/k8s_gateway_auto_mtls_suite.go +++ b/test/kubernetes/e2e/features/istio/k8s_gateway_auto_mtls_suite.go @@ -12,6 +12,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/e2e" ) +var _ e2e.NewSuiteFunc = NewIstioAutoMtlsSuite + // istioMtlsTestingSuite is the entire Suite of tests for the "Istio" integration cases where auto mTLS is enabled type istioAutoMtlsTestingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/istio/k8s_gateway_no_auto_mtls_suite.go b/test/kubernetes/e2e/features/istio/k8s_gateway_no_auto_mtls_suite.go index 0ec8dcb5fa29..0c175a7a4f9a 100644 --- a/test/kubernetes/e2e/features/istio/k8s_gateway_no_auto_mtls_suite.go +++ b/test/kubernetes/e2e/features/istio/k8s_gateway_no_auto_mtls_suite.go @@ -11,6 +11,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // istioTestingSuite is the entire Suite of tests for the "Istio" integration cases where auto mtls is disabled // and Upstreams do not have sslConfig values set type istioTestingSuite struct { diff --git a/test/kubernetes/e2e/features/listener_options/lis_opt_suite.go b/test/kubernetes/e2e/features/listener_options/lis_opt_suite.go index 2bf6b30acbaa..fbf43b57d1e2 100644 --- a/test/kubernetes/e2e/features/listener_options/lis_opt_suite.go +++ b/test/kubernetes/e2e/features/listener_options/lis_opt_suite.go @@ -15,6 +15,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "ListenerOptions" feature type testingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/port_routing/suite.go b/test/kubernetes/e2e/features/port_routing/suite.go index 5d6825526dfb..8b914714a158 100644 --- a/test/kubernetes/e2e/features/port_routing/suite.go +++ b/test/kubernetes/e2e/features/port_routing/suite.go @@ -11,6 +11,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // portRoutingTestingSuite is the entire Suite of tests for the "PortRouting" cases type portRoutingTestingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/route_delegation/suite.go b/test/kubernetes/e2e/features/route_delegation/suite.go index ee30fdaf24aa..31f3a0a8c6c3 100644 --- a/test/kubernetes/e2e/features/route_delegation/suite.go +++ b/test/kubernetes/e2e/features/route_delegation/suite.go @@ -19,6 +19,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + type tsuite struct { suite.Suite @@ -33,7 +35,7 @@ type tsuite struct { manifestObjects map[string][]client.Object } -func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) *tsuite { +func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite { return &tsuite{ ctx: ctx, ti: testInst, diff --git a/test/kubernetes/e2e/features/route_options/suite.go b/test/kubernetes/e2e/features/route_options/suite.go index fa2267e88232..1502d0ebde13 100644 --- a/test/kubernetes/e2e/features/route_options/suite.go +++ b/test/kubernetes/e2e/features/route_options/suite.go @@ -21,6 +21,8 @@ import ( testdefaults "github.com/solo-io/gloo/test/kubernetes/e2e/defaults" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "Route Options" feature type testingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/upstreams/suite.go b/test/kubernetes/e2e/features/upstreams/suite.go index 81eec31f80bc..e3d8e21589aa 100644 --- a/test/kubernetes/e2e/features/upstreams/suite.go +++ b/test/kubernetes/e2e/features/upstreams/suite.go @@ -14,6 +14,8 @@ import ( "github.com/solo-io/gloo/test/kubernetes/e2e" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "Upstream" feature type testingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go b/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go index 3494a7498a51..c9c6d3b97a64 100644 --- a/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go +++ b/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go @@ -22,6 +22,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var _ e2e.NewSuiteFunc = NewTestingSuite + // testingSuite is the entire Suite of tests for the "VirtualHostOptions" feature type testingSuite struct { suite.Suite diff --git a/test/kubernetes/e2e/suite.go b/test/kubernetes/e2e/suite.go new file mode 100644 index 000000000000..16434026bc0c --- /dev/null +++ b/test/kubernetes/e2e/suite.go @@ -0,0 +1,87 @@ +package e2e + +import ( + "context" + "testing" + + "github.com/stretchr/testify/suite" +) + +type ( + NewSuiteFunc func(ctx context.Context, testInstallation *TestInstallation) suite.TestingSuite + + namedSuite struct { + name string + newSuite NewSuiteFunc + } + + orderedSuites struct { + suites []namedSuite + } + + suites struct { + suites map[string]NewSuiteFunc + } + + // A SuiteRunner is an interface that allows E2E tests to simply Register tests in one location and execute them + // with Run. + SuiteRunner interface { + Run(ctx context.Context, t *testing.T, testInstallation *TestInstallation) + Register(name string, newSuite NewSuiteFunc) + } +) + +var ( + _ SuiteRunner = new(orderedSuites) + _ SuiteRunner = new(suites) +) + +// NewSuiteRunner returns an implementation of TestRunner that will execute tests as specified +// in the ordered parameter. +// +// NOTE: it should be strongly preferred to use unordered tests. Only pass true to this function +// if there is a clear need for the tests to be ordered, and specify in a comment near the call +// to NewSuiteRunner why the tests need to be ordered. +func NewSuiteRunner(ordered bool) SuiteRunner { + if ordered { + return new(orderedSuites) + } + + return new(suites) +} + +func (o orderedSuites) Run(ctx context.Context, t *testing.T, testInstallation *TestInstallation) { + for _, namedTest := range o.suites { + t.Run(namedTest.name, func(t *testing.T) { + suite.Run(t, namedTest.newSuite(ctx, testInstallation)) + }) + } +} + +func (o *orderedSuites) Register(name string, newSuite NewSuiteFunc) { + if o.suites == nil { + o.suites = make([]namedSuite, 0) + } + o.suites = append(o.suites, namedSuite{ + name: name, + newSuite: newSuite, + }) + +} + +func (u suites) Run(ctx context.Context, t *testing.T, testInstallation *TestInstallation) { + // TODO(jbohanon) does some randomness need to be injected here to ensure they aren't run in the same order every time? + // from https://goplay.tools/snippet/A-qqQCWkFaZ it looks like maps are not stable, but tend toward stability. + for testName, newSuite := range u.suites { + t.Run(testName, func(t *testing.T) { + suite.Run(t, newSuite(ctx, testInstallation)) + }) + } +} + +func (u *suites) Register(name string, newSuite NewSuiteFunc) { + if u.suites == nil { + u.suites = make(map[string]NewSuiteFunc) + } + u.suites[name] = newSuite +} diff --git a/test/kubernetes/e2e/tests/automtls_istio_edge_api_test.go b/test/kubernetes/e2e/tests/automtls_istio_edge_api_test.go index 88471c412413..057979f7b909 100644 --- a/test/kubernetes/e2e/tests/automtls_istio_edge_api_test.go +++ b/test/kubernetes/e2e/tests/automtls_istio_edge_api_test.go @@ -7,13 +7,11 @@ import ( "time" "github.com/solo-io/gloo/test/kube2e/helper" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" "github.com/solo-io/gloo/test/kubernetes/e2e" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" ) @@ -67,11 +65,5 @@ func TestAutomtlsIstioEdgeApisGateway(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewEdgeGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) - - t.Run("IstioIntegration", func(t *testing.T) { - suite.Run(t, istio.NewGlooIstioAutoMtlsSuite(ctx, testInstallation)) - }) + AutomtlsIstioEdgeApiSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/automtls_istio_edge_api_tests.go b/test/kubernetes/e2e/tests/automtls_istio_edge_api_tests.go new file mode 100644 index 000000000000..c0951003fa50 --- /dev/null +++ b/test/kubernetes/e2e/tests/automtls_istio_edge_api_tests.go @@ -0,0 +1,16 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" +) + +func AutomtlsIstioEdgeApiSuiteRunner() e2e.SuiteRunner { + automtlsIstioEdgeApiSuiteRunner := e2e.NewSuiteRunner(false) + + automtlsIstioEdgeApiSuiteRunner.Register("HeadlessSvc", headless_svc.NewEdgeGatewayHeadlessSvcSuite) + automtlsIstioEdgeApiSuiteRunner.Register("IstioIntegrationAutoMtls", istio.NewGlooIstioAutoMtlsSuite) + + return automtlsIstioEdgeApiSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/automtls_istio_test.go b/test/kubernetes/e2e/tests/automtls_istio_test.go index 0f4916c901e9..fd9f5862b9d2 100644 --- a/test/kubernetes/e2e/tests/automtls_istio_test.go +++ b/test/kubernetes/e2e/tests/automtls_istio_test.go @@ -9,12 +9,9 @@ import ( "github.com/solo-io/gloo/test/kube2e/helper" "github.com/solo-io/gloo/test/kubernetes/e2e" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" ) // TestK8sGatewayIstioAutoMtls is the function which executes a series of tests against a given installation @@ -70,15 +67,5 @@ func TestK8sGatewayIstioAutoMtls(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 10*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("PortRouting", func(t *testing.T) { - suite.Run(t, port_routing.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewK8sGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) - - t.Run("IstioIntegrationAutoMtls", func(t *testing.T) { - suite.Run(t, istio.NewIstioAutoMtlsSuite(ctx, testInstallation)) - }) + AutomtlsIstioSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/automtls_istio_tests.go b/test/kubernetes/e2e/tests/automtls_istio_tests.go new file mode 100644 index 000000000000..450c7500a36f --- /dev/null +++ b/test/kubernetes/e2e/tests/automtls_istio_tests.go @@ -0,0 +1,18 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" +) + +func AutomtlsIstioSuiteRunner() e2e.SuiteRunner { + automtlsIstioSuiteRunner := e2e.NewSuiteRunner(false) + + automtlsIstioSuiteRunner.Register("PortRouting", port_routing.NewTestingSuite) + automtlsIstioSuiteRunner.Register("HeadlessSvc", headless_svc.NewK8sGatewayHeadlessSvcSuite) + automtlsIstioSuiteRunner.Register("IstioIntegrationAutoMtls", istio.NewIstioAutoMtlsSuite) + + return automtlsIstioSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/edge_gw_test.go b/test/kubernetes/e2e/tests/edge_gw_test.go index 912b8642ac32..b713d61284e4 100644 --- a/test/kubernetes/e2e/tests/edge_gw_test.go +++ b/test/kubernetes/e2e/tests/edge_gw_test.go @@ -8,10 +8,9 @@ import ( "github.com/solo-io/gloo/test/kube2e/helper" "github.com/solo-io/gloo/test/kubernetes/e2e" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" ) // TestGlooGatewayEdgeGateway is the function which executes a series of tests against a given installation where @@ -45,7 +44,5 @@ func TestGlooGatewayEdgeGateway(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewEdgeGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) + EdgeGwSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/edge_gw_tests.go b/test/kubernetes/e2e/tests/edge_gw_tests.go new file mode 100644 index 000000000000..0fe5328311ea --- /dev/null +++ b/test/kubernetes/e2e/tests/edge_gw_tests.go @@ -0,0 +1,14 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" +) + +func EdgeGwSuiteRunner() e2e.SuiteRunner { + edgeGwSuiteRunner := e2e.NewSuiteRunner(false) + + edgeGwSuiteRunner.Register("HeadlessSvc", headless_svc.NewEdgeGatewayHeadlessSvcSuite) + + return edgeGwSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/glooctl_istio_inject_test.go b/test/kubernetes/e2e/tests/glooctl_istio_inject_test.go index 7ace0f384172..724a877e1458 100644 --- a/test/kubernetes/e2e/tests/glooctl_istio_inject_test.go +++ b/test/kubernetes/e2e/tests/glooctl_istio_inject_test.go @@ -7,12 +7,10 @@ import ( "time" "github.com/solo-io/gloo/test/kube2e/helper" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/glooctl" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" "github.com/solo-io/gloo/test/kubernetes/e2e" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" ) @@ -66,16 +64,5 @@ func TestGlooctlIstioInjectEdgeApiGateway(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - // NOTE: Order of tests is important here because the tests are dependent on each other (e.g. the inject test must run before the istio test) - t.Run("GlooctlIstioInject", func(t *testing.T) { - suite.Run(t, glooctl.NewIstioInjectTestingSuite(ctx, testInstallation)) - }) - - t.Run("IstioIntegration", func(t *testing.T) { - suite.Run(t, istio.NewGlooTestingSuite(ctx, testInstallation)) - }) - - t.Run("GlooctlIstioUninject", func(t *testing.T) { - suite.Run(t, glooctl.NewIstioUninjectTestingSuite(ctx, testInstallation)) - }) + GlooctlIstioInjectSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/glooctl_istio_inject_tests.go b/test/kubernetes/e2e/tests/glooctl_istio_inject_tests.go new file mode 100644 index 000000000000..f1f5bfdd27bc --- /dev/null +++ b/test/kubernetes/e2e/tests/glooctl_istio_inject_tests.go @@ -0,0 +1,17 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/glooctl" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" +) + +func GlooctlIstioInjectSuiteRunner() e2e.SuiteRunner { + // NOTE: Order of tests is important here because the tests are dependent on each other (e.g. the inject test must run before the istio test) + glooctlIstioInjectSuiteRunner := e2e.NewSuiteRunner(true) + + glooctlIstioInjectSuiteRunner.Register("GlooctlIstioInject", glooctl.NewIstioInjectTestingSuite) + glooctlIstioInjectSuiteRunner.Register("IstioIntegration", istio.NewGlooTestingSuite) + glooctlIstioInjectSuiteRunner.Register("GlooctlIstioUninject", glooctl.NewIstioUninjectTestingSuite) + return glooctlIstioInjectSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/istio_edge_api_test.go b/test/kubernetes/e2e/tests/istio_edge_api_test.go index 4e06196ae7ba..9cab29e889ae 100644 --- a/test/kubernetes/e2e/tests/istio_edge_api_test.go +++ b/test/kubernetes/e2e/tests/istio_edge_api_test.go @@ -8,14 +8,11 @@ import ( "time" "github.com/solo-io/gloo/test/kube2e/helper" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" - - "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" - "github.com/solo-io/gloo/test/kubernetes/e2e" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" + + "github.com/solo-io/skv2/codegen/util" ) // TestIstioEdgeApiGateway is the function which executes a series of tests against a given installation where @@ -72,11 +69,5 @@ func TestIstioEdgeApiGateway(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewEdgeGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) - - t.Run("IstioIntegration", func(t *testing.T) { - suite.Run(t, istio.NewGlooTestingSuite(ctx, testInstallation)) - }) + IstioEdgeApiSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/istio_edge_api_tests.go b/test/kubernetes/e2e/tests/istio_edge_api_tests.go new file mode 100644 index 000000000000..f72e6574b59d --- /dev/null +++ b/test/kubernetes/e2e/tests/istio_edge_api_tests.go @@ -0,0 +1,16 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" +) + +func IstioEdgeApiSuiteRunner() e2e.SuiteRunner { + istioEdgeApiSuiteRunner := e2e.NewSuiteRunner(false) + + istioEdgeApiSuiteRunner.Register("HeadlessSvc", headless_svc.NewEdgeGatewayHeadlessSvcSuite) + istioEdgeApiSuiteRunner.Register("IstioIntegration", istio.NewGlooTestingSuite) + + return istioEdgeApiSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/istio_test.go b/test/kubernetes/e2e/tests/istio_test.go index 849ae18941a4..4bc587ad2f97 100644 --- a/test/kubernetes/e2e/tests/istio_test.go +++ b/test/kubernetes/e2e/tests/istio_test.go @@ -8,13 +8,9 @@ import ( "github.com/solo-io/gloo/test/kube2e/helper" "github.com/solo-io/gloo/test/kubernetes/e2e" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/deployer" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" ) // TestK8sGatewayIstio is the function which executes a series of tests against a given installation @@ -67,19 +63,5 @@ func TestK8sGatewayIstio(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 10*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("PortRouting", func(t *testing.T) { - suite.Run(t, port_routing.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewK8sGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) - - t.Run("IstioIntegration", func(t *testing.T) { - suite.Run(t, istio.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("IstioGatewayParameters", func(t *testing.T) { - suite.Run(t, deployer.NewIstioIntegrationTestingSuite(ctx, testInstallation)) - }) + IstioSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/istio_tests.go b/test/kubernetes/e2e/tests/istio_tests.go new file mode 100644 index 000000000000..2502e1840e8f --- /dev/null +++ b/test/kubernetes/e2e/tests/istio_tests.go @@ -0,0 +1,20 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/deployer" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/istio" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" +) + +func IstioSuiteRunner() e2e.SuiteRunner { + istioSuiteRunner := e2e.NewSuiteRunner(false) + + istioSuiteRunner.Register("PortRouting", port_routing.NewTestingSuite) + istioSuiteRunner.Register("HeadlessSvc", headless_svc.NewK8sGatewayHeadlessSvcSuite) + istioSuiteRunner.Register("IstioIntegration", istio.NewTestingSuite) + istioSuiteRunner.Register("IstioGatewayParameters", deployer.NewIstioIntegrationTestingSuite) + + return istioSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go b/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go index 731e972321d1..2810145b1c01 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go @@ -7,14 +7,10 @@ import ( "time" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" "github.com/solo-io/gloo/test/kube2e/helper" "github.com/solo-io/gloo/test/kubernetes/e2e" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/listener_options" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_options" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/virtualhost_options" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" ) @@ -49,20 +45,5 @@ func TestK8sGatewayNoValidation(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("ListenerOptions", func(t *testing.T) { - suite.Run(t, listener_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("RouteOptions", func(t *testing.T) { - suite.Run(t, route_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("VirtualHostOptions", func(t *testing.T) { - suite.Run(t, virtualhost_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("PortRouting", func(t *testing.T) { - suite.Run(t, port_routing.NewTestingSuite(ctx, testInstallation)) - - }) + KubeGatewayNoValidationSuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/k8s_gw_no_validation_tests.go b/test/kubernetes/e2e/tests/k8s_gw_no_validation_tests.go new file mode 100644 index 000000000000..74090f6c1624 --- /dev/null +++ b/test/kubernetes/e2e/tests/k8s_gw_no_validation_tests.go @@ -0,0 +1,20 @@ +package tests + +import ( + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/listener_options" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_options" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/virtualhost_options" +) + +func KubeGatewayNoValidationSuiteRunner() e2e.SuiteRunner { + kubeGatewayNoValidationSuiteRunner := e2e.NewSuiteRunner(false) + + kubeGatewayNoValidationSuiteRunner.Register("ListenerOptions", listener_options.NewTestingSuite) + kubeGatewayNoValidationSuiteRunner.Register("RouteOptions", route_options.NewTestingSuite) + kubeGatewayNoValidationSuiteRunner.Register("VirtualHostOptions", virtualhost_options.NewTestingSuite) + kubeGatewayNoValidationSuiteRunner.Register("PortRouting", port_routing.NewTestingSuite) + + return kubeGatewayNoValidationSuiteRunner +} diff --git a/test/kubernetes/e2e/tests/k8s_gw_test.go b/test/kubernetes/e2e/tests/k8s_gw_test.go index 41a2dd3e919d..c2771c273140 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_test.go @@ -9,21 +9,10 @@ import ( "github.com/solo-io/gloo/pkg/utils/env" "github.com/solo-io/gloo/test/kube2e/helper" "github.com/solo-io/gloo/test/kubernetes/e2e" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/deployer" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/glooctl" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/http_listener_options" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/listener_options" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_delegation" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_options" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/services" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/upstreams" - "github.com/solo-io/gloo/test/kubernetes/e2e/features/virtualhost_options" + . "github.com/solo-io/gloo/test/kubernetes/e2e/tests" "github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" "github.com/solo-io/gloo/test/testutils" "github.com/solo-io/skv2/codegen/util" - "github.com/stretchr/testify/suite" ) // TestK8sGateway is the function which executes a series of tests against a given installation @@ -57,57 +46,5 @@ func TestK8sGateway(t *testing.T) { return testHelper.InstallGloo(ctx, helper.GATEWAY, 5*time.Minute, helper.ExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) }) - t.Run("Deployer", func(t *testing.T) { - suite.Run(t, deployer.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("HttpListenerOptions", func(t *testing.T) { - suite.Run(t, http_listener_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("ListenerOptions", func(t *testing.T) { - suite.Run(t, listener_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("RouteOptions", func(t *testing.T) { - suite.Run(t, route_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("VirtualHostOptions", func(t *testing.T) { - suite.Run(t, virtualhost_options.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("Upstreams", func(t *testing.T) { - suite.Run(t, upstreams.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("Services", func(t *testing.T) { - suite.Run(t, services.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("HeadlessSvc", func(t *testing.T) { - suite.Run(t, headless_svc.NewK8sGatewayHeadlessSvcSuite(ctx, testInstallation)) - }) - - t.Run("PortRouting", func(t *testing.T) { - suite.Run(t, port_routing.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("RouteDelegation", func(t *testing.T) { - suite.Run(t, route_delegation.NewTestingSuite(ctx, testInstallation)) - }) - - t.Run("Glooctl", func(t *testing.T) { - t.Run("Check", func(t *testing.T) { - suite.Run(t, glooctl.NewCheckSuite(ctx, testInstallation)) - }) - - t.Run("Debug", func(t *testing.T) { - suite.Run(t, glooctl.NewDebugSuite(ctx, testInstallation)) - }) - - t.Run("GetProxy", func(t *testing.T) { - suite.Run(t, glooctl.NewGetProxySuite(ctx, testInstallation)) - }) - }) + KubeGatewaySuiteRunner().Run(ctx, t, testInstallation) } diff --git a/test/kubernetes/e2e/tests/k8s_gw_tests.go b/test/kubernetes/e2e/tests/k8s_gw_tests.go new file mode 100644 index 000000000000..0f88fcf7bea5 --- /dev/null +++ b/test/kubernetes/e2e/tests/k8s_gw_tests.go @@ -0,0 +1,63 @@ +package tests + +import ( + "context" + + "github.com/solo-io/gloo/test/kubernetes/e2e" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/deployer" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/glooctl" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/http_listener_options" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/listener_options" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_delegation" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/route_options" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/services" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/upstreams" + "github.com/solo-io/gloo/test/kubernetes/e2e/features/virtualhost_options" + "github.com/stretchr/testify/suite" +) + +func KubeGatewaySuiteRunner() e2e.SuiteRunner { + kubeGatewaySuiteRunner := e2e.NewSuiteRunner(false) + + kubeGatewaySuiteRunner.Register("Deployer", deployer.NewTestingSuite) + kubeGatewaySuiteRunner.Register("HttpListenerOptions", http_listener_options.NewTestingSuite) + kubeGatewaySuiteRunner.Register("ListenerOptions", listener_options.NewTestingSuite) + kubeGatewaySuiteRunner.Register("RouteOptions", route_options.NewTestingSuite) + kubeGatewaySuiteRunner.Register("VirtualHostOptions", virtualhost_options.NewTestingSuite) + kubeGatewaySuiteRunner.Register("Upstreams", upstreams.NewTestingSuite) + kubeGatewaySuiteRunner.Register("Services", services.NewTestingSuite) + kubeGatewaySuiteRunner.Register("HeadlessSvc", headless_svc.NewK8sGatewayHeadlessSvcSuite) + kubeGatewaySuiteRunner.Register("PortRouting", port_routing.NewTestingSuite) + kubeGatewaySuiteRunner.Register("RouteDelegation", route_delegation.NewTestingSuite) + kubeGatewaySuiteRunner.Register("Glooctl", newGlooctlTestingSuite) + + return kubeGatewaySuiteRunner +} + +// We need to define tests requiring nesting as their own suites in order to support the injection paradigm +type glooctlSuite struct { + suite.Suite + ctx context.Context + testInstallation *e2e.TestInstallation +} + +func newGlooctlTestingSuite(ctx context.Context, testInstallation *e2e.TestInstallation) suite.TestingSuite { + return &glooctlSuite{ + ctx: ctx, + testInstallation: testInstallation, + } +} + +func (s *glooctlSuite) TestCheck() { + suite.Run(s.T(), glooctl.NewCheckSuite(s.ctx, s.testInstallation)) +} + +func (s *glooctlSuite) TestDebug() { + suite.Run(s.T(), glooctl.NewDebugSuite(s.ctx, s.testInstallation)) +} + +func (s *glooctlSuite) TestGetProxy() { + suite.Run(s.T(), glooctl.NewGetProxySuite(s.ctx, s.testInstallation)) +}