From 11987ca7fd66378e10267a09d4e2b545f7535b09 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Mon, 27 Jan 2025 16:24:50 -0500 Subject: [PATCH 01/14] add back workflow --- .github/workflows/pr-kubernetes-tests.yaml | 139 ++++++++++++++++++ .../workflows/pr-kubernetes-tests.yaml_noop | 134 ----------------- 2 files changed, 139 insertions(+), 134 deletions(-) create mode 100644 .github/workflows/pr-kubernetes-tests.yaml delete mode 100644 .github/workflows/pr-kubernetes-tests.yaml_noop diff --git a/.github/workflows/pr-kubernetes-tests.yaml b/.github/workflows/pr-kubernetes-tests.yaml new file mode 100644 index 00000000000..757957547a8 --- /dev/null +++ b/.github/workflows/pr-kubernetes-tests.yaml @@ -0,0 +1,139 @@ +name: Kubernetes Tests +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +env: + VERSION: '1.0.0-ci1' + GITHUB_TOKEN: ${{ github.token }} + +jobs: + # TODO consider adding back later if we want to handle skip directives. + # currently we don't have changelogs to add the skip directives to + # prepare_env: + # name: Prepare Environment + # runs-on: ubuntu-22.04 + # timeout-minutes: 5 + # outputs: + # should-auto-succeed-kube-tests: ${{ steps.run-strategy.outputs.auto_succeed }} + # steps: + # - name: Cancel Previous Actions + # uses: styfle/cancel-workflow-action@0.12.1 + # with: + # access_token: ${{ github.token }} + # - id: checkout-code + # uses: actions/checkout@v4 + # with: + # # We require gathering the branch and tag history since we rely on a `git diff` + # # which compares the state of two branches + # fetch-depth: 0 + # - id: process-skip-directives + # uses: ./.github/actions/process-skip-directives + # with: + # base-ref: ${{ github.base_ref }} + # - id: run-strategy + # name: Determine Test Run Strategy + # run: | + # skip_kube_tests=${{ steps.process-skip-directives.outputs.skip-kube-tests }} + # if [[ ! -z $skip_kube_tests && $skip_kube_tests = true ]] ; then + # echo "auto_succeed=true" >> $GITHUB_OUTPUT + # fi + + end_to_end_tests: + name: End-to-End (${{ matrix.test.cluster-name }}) + # needs: prepare_env + runs-on: ubuntu-22.04 + timeout-minutes: 60 + if: ${{ !github.event.pull_request.draft }} + strategy: + fail-fast: false + matrix: + # We intentionally set an upper threshold of 30 minutes for our End-to-End tests + # Our goal is to load balance tests in a way that allows quick iteration on PRs + # If tests are exceeding the 30-minute limit, please see: + # /test/kubernetes/e2e/load_balancing_tests.md + # + # Above each test below, we document the latest date/time for the GitHub action step to run + # NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture + + test: + - cluster-name: 'cluster-one' + go-test-args: '-v -timeout=25m' + go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$' + # Dec 4, 2024: 22 minutes + # - cluster-name: 'cluster-one' + # go-test-args: '-v -timeout=25m' + # go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$' + + # # Dec 4, 2024: 23 minutes + # - cluster-name: 'cluster-two' + # go-test-args: '-v -timeout=25m' + # go-test-run-regex: '^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$' + + # # Dec 4, 2024: 24 minutes + # - cluster-name: 'cluster-three' + # go-test-args: '-v -timeout=30m' + # go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)' + + # # Dec 4, 2024: 21 minutes + # - cluster-name: 'cluster-four' + # go-test-args: '-v -timeout=30m' + # go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)' + + # # Dec 4, 2024: 24 minutes + # - cluster-name: 'cluster-five' + # go-test-args: '-v -timeout=30m' + # go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$' + + # # Dec 4, 2024: 26 minutes + # - cluster-name: 'cluster-six' + # go-test-args: '-v -timeout=30m' + # go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$|^TestZeroDowntimeRollout$$' + + # # Dec 4, 2024: 13 minutes + # - cluster-name: 'cluster-seven' + # go-test-args: '-v -timeout=25m' + # go-test-run-regex: '^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^Metrics$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$' + + # In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support + # The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/ + version-files: + - file: './.github/workflows/.env/pr-tests/versions.env' + steps: + # - id: auto-succeed-tests + # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests == 'true' + # run: | + # echo "Regression tests auto-succeeded" + - uses: actions/checkout@v4 + - name: Prep Go Runner + uses: ./.github/actions/prep-go-runner + # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' + # The dotenv action is used to load key-value pairs from files. + # In this case, the file is specified in the matrix and will contain the versions of the tools to use + - name: Dotenv Action + uses: falti/dotenv-action@v1.1.4 + # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' + id: dotenv + with: + path: ${{ matrix.version-files.file }} + log-variables: true + - id: setup-kind-cluster + name: Setup KinD Cluster + # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' + uses: ./.github/actions/setup-kind-cluster + with: + cluster-name: ${{ matrix.test.cluster-name }} + kind-node-version: ${{ steps.dotenv.outputs.node_version }} + kind-version: ${{ steps.dotenv.outputs.kind_version }} + kubectl-version: ${{ steps.dotenv.outputs.kubectl_version }} + helm-version: ${{ steps.dotenv.outputs.helm_version }} + istio-version: ${{ steps.dotenv.outputs.istio_version }} + - id: run-tests + # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' + uses: ./.github/actions/kubernetes-e2e-tests + with: + cluster-name: ${{ matrix.test.cluster-name }} + test-args: ${{ matrix.test.go-test-args }} + run-regex: ${{ matrix.test.go-test-run-regex }} + istio-version: ${{ steps.dotenv.outputs.istio_version }} + matrix-label: "pr" diff --git a/.github/workflows/pr-kubernetes-tests.yaml_noop b/.github/workflows/pr-kubernetes-tests.yaml_noop deleted file mode 100644 index d78c691f937..00000000000 --- a/.github/workflows/pr-kubernetes-tests.yaml_noop +++ /dev/null @@ -1,134 +0,0 @@ -# name: Kubernetes Tests -# on: -# pull_request: -# types: [opened, synchronize, reopened, ready_for_review] - -# env: -# VERSION: '1.0.0-ci1' -# GITHUB_TOKEN: ${{ github.token }} - -# jobs: -# prepare_env: -# name: Prepare Environment -# runs-on: ubuntu-22.04 -# timeout-minutes: 5 -# outputs: -# should-auto-succeed-kube-tests: ${{ steps.run-strategy.outputs.auto_succeed }} -# steps: -# - name: Cancel Previous Actions -# uses: styfle/cancel-workflow-action@0.12.1 -# with: -# access_token: ${{ github.token }} -# - id: checkout-code -# uses: actions/checkout@v4 -# with: -# # We require gathering the branch and tag history since we rely on a `git diff` -# # which compares the state of two branches -# fetch-depth: 0 -# - id: process-skip-directives -# uses: ./.github/actions/process-skip-directives -# with: -# base-ref: ${{ github.base_ref }} -# - id: run-strategy -# name: Determine Test Run Strategy -# run: | -# skip_kube_tests=${{ steps.process-skip-directives.outputs.skip-kube-tests }} -# if [[ ! -z $skip_kube_tests && $skip_kube_tests = true ]] ; then -# echo "auto_succeed=true" >> $GITHUB_OUTPUT -# fi - -# end_to_end_tests: -# name: End-to-End (${{ matrix.test.cluster-name }}) -# needs: prepare_env -# runs-on: ubuntu-22.04 -# timeout-minutes: 60 -# if: ${{ !github.event.pull_request.draft }} -# strategy: -# fail-fast: false -# matrix: -# # We intentionally set an upper threshold of 30 minutes for our End-to-End tests -# # Our goal is to load balance tests in a way that allows quick iteration on PRs -# # If tests are exceeding the 30-minute limit, please see: -# # /test/kubernetes/e2e/load_balancing_tests.md -# # -# # Above each test below, we document the latest date/time for the GitHub action step to run -# # NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture - -# test: -# # Dec 4, 2024: 22 minutes -# - cluster-name: 'cluster-one' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$' - -# # Dec 4, 2024: 23 minutes -# - cluster-name: 'cluster-two' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$' - -# # Dec 4, 2024: 24 minutes -# - cluster-name: 'cluster-three' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)' - -# # Dec 4, 2024: 21 minutes -# - cluster-name: 'cluster-four' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)' - -# # Dec 4, 2024: 24 minutes -# - cluster-name: 'cluster-five' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$' - -# # Dec 4, 2024: 26 minutes -# - cluster-name: 'cluster-six' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$|^TestZeroDowntimeRollout$$' - -# # Dec 4, 2024: 13 minutes -# - cluster-name: 'cluster-seven' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^Metrics$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$' - -# # In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support -# # The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/ -# version-files: -# - file: './.github/workflows/.env/pr-tests/versions.env' -# steps: -# - id: auto-succeed-tests -# if: needs.prepare_env.outputs.should-auto-succeed-kube-tests == 'true' -# run: | -# echo "Regression tests auto-succeeded" -# - uses: actions/checkout@v4 -# - name: Prep Go Runner -# uses: ./.github/actions/prep-go-runner -# if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' -# # The dotenv action is used to load key-value pairs from files. -# # In this case, the file is specified in the matrix and will contain the versions of the tools to use -# - name: Dotenv Action -# uses: falti/dotenv-action@v1.1.4 -# if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' -# id: dotenv -# with: -# path: ${{ matrix.version-files.file }} -# log-variables: true -# - id: setup-kind-cluster -# name: Setup KinD Cluster -# if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' -# uses: ./.github/actions/setup-kind-cluster -# with: -# cluster-name: ${{ matrix.test.cluster-name }} -# kind-node-version: ${{ steps.dotenv.outputs.node_version }} -# kind-version: ${{ steps.dotenv.outputs.kind_version }} -# kubectl-version: ${{ steps.dotenv.outputs.kubectl_version }} -# helm-version: ${{ steps.dotenv.outputs.helm_version }} -# istio-version: ${{ steps.dotenv.outputs.istio_version }} -# - id: run-tests -# if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' -# uses: ./.github/actions/kubernetes-e2e-tests -# with: -# cluster-name: ${{ matrix.test.cluster-name }} -# test-args: ${{ matrix.test.go-test-args }} -# run-regex: ${{ matrix.test.go-test-run-regex }} -# istio-version: ${{ steps.dotenv.outputs.istio_version }} -# matrix-label: "pr" From caa9c0c92891d94d28600d98510727cc9b807477 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Thu, 30 Jan 2025 13:34:23 -0500 Subject: [PATCH 02/14] cleanup --- .../e2e/features/admin_server/suite.go | 4 - .../virtualhost_options/vhost_opt_suite.go | 20 +-- test/kubernetes/e2e/suite.go | 2 - test/kubernetes/e2e/test.go | 2 - test/kubernetes/e2e/tests/k8s_gw_aws_test.go | 1 - .../kubernetes/e2e/tests/k8s_gw_istio_test.go | 1 - ..._minimal_default_gatewayparameters_test.go | 2 - .../e2e/tests/k8s_gw_no_validation_test.go | 2 - test/kubernetes/e2e/tests/k8s_gw_test.go | 4 - test/kubernetes/e2e/tests/k8s_gw_tests.go | 64 ++++---- test/kubernetes/e2e/tests/upgrade_test.go | 2 - .../testutils/assertions/objects.go | 32 +--- .../testutils/gloogateway/clients.go | 148 ------------------ .../testutils/gloogateway/context.go | 10 -- 14 files changed, 44 insertions(+), 250 deletions(-) delete mode 100644 test/kubernetes/testutils/gloogateway/clients.go diff --git a/test/kubernetes/e2e/features/admin_server/suite.go b/test/kubernetes/e2e/features/admin_server/suite.go index e344e029cc1..5e80a9cd081 100644 --- a/test/kubernetes/e2e/features/admin_server/suite.go +++ b/test/kubernetes/e2e/features/admin_server/suite.go @@ -77,10 +77,6 @@ func (s *testingSuite) TestGetInputSnapshotIncludesEdgeApiResources() { // TestGetInputSnapshotIncludesK8sGatewayApiResources verifies that we can query the /snapshots/input API and have it return K8s Gateway API // resources without an error func (s *testingSuite) TestGetInputSnapshotIncludesK8sGatewayApiResources() { - if !s.testInstallation.Metadata.K8sGatewayEnabled { - s.T().Skip("Installation of Gloo Gateway does not have K8s Gateway enabled, skipping test as there is nothing to test") - } - s.T().Cleanup(func() { err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, gatewayParametersManifest) s.NoError(err, "can delete manifest") 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 49c7d2a9ca0..9eae55ae0eb 100644 --- a/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go +++ b/test/kubernetes/e2e/features/virtualhost_options/vhost_opt_suite.go @@ -157,20 +157,12 @@ func (s *testingSuite) TestConfigureInvalidVirtualHostOptions() { s.testInstallation.Assertions.ExpectObjectAdmitted(manifestVhoWebhookReject, err, output, "Validating *v1.VirtualHostOption failed") - if !s.testInstallation.Metadata.ValidationAlwaysAccept { - s.testInstallation.Assertions.ExpectGlooObjectNotExist( - s.ctx, - s.getterForMeta(&vhoWebhookReject), - &vhoWebhookReject, - ) - } else { - // Check status is rejected on bad VirtualHostOption - s.testInstallation.Assertions.EventuallyResourceStatusMatchesState( - s.getterForMeta(&vhoWebhookReject), - core.Status_Rejected, - defaults.KubeGatewayReporter, - ) - } + // Check status is rejected on bad VirtualHostOption + s.testInstallation.Assertions.EventuallyResourceStatusMatchesState( + s.getterForMeta(&vhoWebhookReject), + core.Status_Rejected, + defaults.KubeGatewayReporter, + ) // Check healthy response with no x-bar header s.testInstallation.Assertions.AssertEventualCurlResponse( diff --git a/test/kubernetes/e2e/suite.go b/test/kubernetes/e2e/suite.go index 100d3db7c74..cfa24ba6972 100644 --- a/test/kubernetes/e2e/suite.go +++ b/test/kubernetes/e2e/suite.go @@ -1,5 +1,3 @@ -//go:build ignore - package e2e import ( diff --git a/test/kubernetes/e2e/test.go b/test/kubernetes/e2e/test.go index b632396b773..376764cd09b 100644 --- a/test/kubernetes/e2e/test.go +++ b/test/kubernetes/e2e/test.go @@ -1,5 +1,3 @@ -//go:build ignore - package e2e import ( diff --git a/test/kubernetes/e2e/tests/k8s_gw_aws_test.go b/test/kubernetes/e2e/tests/k8s_gw_aws_test.go index b111b175561..b2101bafd34 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_aws_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_aws_test.go @@ -26,7 +26,6 @@ func TestK8sGatewayAws(t *testing.T) { InstallNamespace: installNs, ProfileValuesManifestFile: e2e.KubernetesGatewayProfilePath, ValuesManifestFile: e2e.ManifestPath("aws-lambda-helm.yaml"), - K8sGatewayEnabled: true, // these should correspond to the `settings.aws.*` values in the aws-lambda-helm.yaml manifest AwsOptions: &gloogateway.AwsOptions{ EnableServiceAccountCredentials: true, diff --git a/test/kubernetes/e2e/tests/k8s_gw_istio_test.go b/test/kubernetes/e2e/tests/k8s_gw_istio_test.go index c459b611068..961f07441f0 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_istio_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_istio_test.go @@ -25,7 +25,6 @@ func TestK8sGatewayIstio(t *testing.T) { InstallNamespace: installNs, ProfileValuesManifestFile: e2e.KubernetesGatewayProfilePath, ValuesManifestFile: e2e.ManifestPath("istio-automtls-disabled-helm.yaml"), - K8sGatewayEnabled: true, }, ) diff --git a/test/kubernetes/e2e/tests/k8s_gw_minimal_default_gatewayparameters_test.go b/test/kubernetes/e2e/tests/k8s_gw_minimal_default_gatewayparameters_test.go index 865a091200b..0704e6b4c8a 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_minimal_default_gatewayparameters_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_minimal_default_gatewayparameters_test.go @@ -26,8 +26,6 @@ func TestK8sGatewayMinimalDefaultGatewayParameters(t *testing.T) { InstallNamespace: installNs, ProfileValuesManifestFile: e2e.KubernetesGatewayProfilePath, ValuesManifestFile: e2e.ManifestPath("k8s-gateway-minimal-default-gatewayparameters-test-helm.yaml"), - ValidationAlwaysAccept: false, - K8sGatewayEnabled: true, }, ) 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 c0546361ce1..de4f07462fa 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_no_validation_test.go @@ -25,8 +25,6 @@ func TestK8sGatewayNoValidation(t *testing.T) { InstallNamespace: installNs, ProfileValuesManifestFile: e2e.KubernetesGatewayProfilePath, ValuesManifestFile: e2e.ManifestPath("k8s-gateway-no-webhook-validation-test-helm.yaml"), - ValidationAlwaysAccept: true, - K8sGatewayEnabled: true, }, ) diff --git a/test/kubernetes/e2e/tests/k8s_gw_test.go b/test/kubernetes/e2e/tests/k8s_gw_test.go index 24860a580f8..a09ab549616 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_test.go +++ b/test/kubernetes/e2e/tests/k8s_gw_test.go @@ -1,5 +1,3 @@ -//go:build ignore - package tests_test import ( @@ -25,8 +23,6 @@ func TestK8sGateway(t *testing.T) { InstallNamespace: installNs, ProfileValuesManifestFile: e2e.KubernetesGatewayProfilePath, ValuesManifestFile: e2e.EmptyValuesManifestPath, - ValidationAlwaysAccept: false, - K8sGatewayEnabled: true, }, ) diff --git a/test/kubernetes/e2e/tests/k8s_gw_tests.go b/test/kubernetes/e2e/tests/k8s_gw_tests.go index 1afd51c451a..f351fe78204 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_tests.go +++ b/test/kubernetes/e2e/tests/k8s_gw_tests.go @@ -1,44 +1,44 @@ -//go:build ignore - package tests import ( "github.com/kgateway-dev/kgateway/test/kubernetes/e2e" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/admin_server" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/crd_categories" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/deployer" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/directresponse" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/headless_svc" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/http_listener_options" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/listener_options" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/metrics" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/port_routing" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/route_delegation" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/route_options" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/services/httproute" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/services/tcproute" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/upstreams" - "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/virtualhost_options" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/admin_server" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/crd_categories" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/deployer" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/directresponse" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/headless_svc" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/http_listener_options" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/listener_options" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/metrics" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/port_routing" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/route_delegation" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/route_options" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/services/httproute" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/services/tcproute" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/upstreams" + // "github.com/kgateway-dev/kgateway/test/kubernetes/e2e/features/virtualhost_options" ) 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("HTTPRouteServices", httproute.NewTestingSuite) - kubeGatewaySuiteRunner.Register("TCPRouteServices", tcproute.NewTestingSuite) - kubeGatewaySuiteRunner.Register("HeadlessSvc", headless_svc.NewK8sGatewayHeadlessSvcSuite) - kubeGatewaySuiteRunner.Register("PortRouting", port_routing.NewK8sGatewayTestingSuite) - kubeGatewaySuiteRunner.Register("RouteDelegation", route_delegation.NewTestingSuite) - kubeGatewaySuiteRunner.Register("GlooAdminServer", admin_server.NewTestingSuite) - kubeGatewaySuiteRunner.Register("DirectResponse", directresponse.NewTestingSuite) - kubeGatewaySuiteRunner.Register("CRDCategories", crd_categories.NewTestingSuite) - kubeGatewaySuiteRunner.Register("Metrics", metrics.NewTestingSuite) + /* + 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("HTTPRouteServices", httproute.NewTestingSuite) + kubeGatewaySuiteRunner.Register("TCPRouteServices", tcproute.NewTestingSuite) + kubeGatewaySuiteRunner.Register("HeadlessSvc", headless_svc.NewK8sGatewayHeadlessSvcSuite) + kubeGatewaySuiteRunner.Register("PortRouting", port_routing.NewK8sGatewayTestingSuite) + kubeGatewaySuiteRunner.Register("RouteDelegation", route_delegation.NewTestingSuite) + kubeGatewaySuiteRunner.Register("GlooAdminServer", admin_server.NewTestingSuite) + kubeGatewaySuiteRunner.Register("DirectResponse", directresponse.NewTestingSuite) + kubeGatewaySuiteRunner.Register("CRDCategories", crd_categories.NewTestingSuite) + kubeGatewaySuiteRunner.Register("Metrics", metrics.NewTestingSuite) + */ return kubeGatewaySuiteRunner } diff --git a/test/kubernetes/e2e/tests/upgrade_test.go b/test/kubernetes/e2e/tests/upgrade_test.go index 814656e665b..6c1b9268ea0 100644 --- a/test/kubernetes/e2e/tests/upgrade_test.go +++ b/test/kubernetes/e2e/tests/upgrade_test.go @@ -30,7 +30,6 @@ func TestUpgradeFromLastPatchPreviousMinor(t *testing.T) { InstallNamespace: "upgrade-from-last-patch-previous-minor", ProfileValuesManifestFile: e2e.FullGatewayProfilePath, ValuesManifestFile: e2e.EmptyValuesManifestPath, - ValidationAlwaysAccept: false, ReleasedVersion: lastPatchPreviousMinorVersion.String(), }, ) @@ -57,7 +56,6 @@ func TestUpgradeFromCurrentPatchLatestMinor(t *testing.T) { InstallNamespace: "upgrade-from-current-patch-latest-minor", ProfileValuesManifestFile: e2e.FullGatewayProfilePath, ValuesManifestFile: e2e.EmptyValuesManifestPath, - ValidationAlwaysAccept: false, ReleasedVersion: currentPatchMostRecentMinorVersion.String(), }, ) diff --git a/test/kubernetes/testutils/assertions/objects.go b/test/kubernetes/testutils/assertions/objects.go index 92ad0f6a705..f1f2987ca2e 100644 --- a/test/kubernetes/testutils/assertions/objects.go +++ b/test/kubernetes/testutils/assertions/objects.go @@ -5,7 +5,6 @@ package assertions import ( "context" "fmt" - "strings" "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -82,36 +81,17 @@ func (p *Provider) ExpectGlooObjectNotExist(ctx context.Context, getter helpers. p.Gomega.Expect(errors.IsNotExist(err)).To(BeTrue(), fmt.Sprintf("obj %s.%s should not be found in cluster", meta.GetName(), meta.GetNamespace())) } +// TODO clean up these functions, as the validation webhook has been removed // ExpectObjectAdmitted should be used when applying Policy objects that are subject to the Gloo Gateway Validation Webhook // If the testInstallation has validation enabled and the manifest contains a known substring (e.g. `webhook-reject`) // we expect the application to fail, with an expected error substring supplied as `expectedOutput` func (p *Provider) ExpectObjectAdmitted(manifest string, err error, actualOutput, expectedOutput string) { - if p.glooGatewayContext.ValidationAlwaysAccept { - p.Assert.NoError(err, "can apply "+manifest) - return - } - - if strings.Contains(manifest, WebhookReject) { - // when validation is enforced (i.e. does NOT always accept), an apply should result in an error - // and the output from the command should contain a validation failure message - p.Assert.Error(err, "got error when applying "+manifest) - p.Assert.Contains(actualOutput, expectedOutput, "apply failed with expected message for "+manifest) - } else { - p.Assert.NoError(err, "can apply "+manifest) - } + p.Assert.NoError(err, "can apply "+manifest) + return } +// TODO clean this up as the validation webhook has been removed func (p *Provider) ExpectObjectDeleted(manifest string, err error, actualOutput string) { - if p.glooGatewayContext.ValidationAlwaysAccept { - p.Assert.NoError(err, "can delete "+manifest) - return - } - - if strings.Contains(manifest, WebhookReject) { - // when validation is enforced (i.e. does NOT always accept), a delete should result in an error and "not found" in the output - p.Assert.Error(err, "delete failed for "+manifest) - p.Assert.Contains(actualOutput, "NotFound") - } else { - p.Assert.NoError(err, "can delete "+manifest) - } + p.Assert.NoError(err, "can delete "+manifest) + return } diff --git a/test/kubernetes/testutils/gloogateway/clients.go b/test/kubernetes/testutils/gloogateway/clients.go deleted file mode 100644 index 0cff2b94fae..00000000000 --- a/test/kubernetes/testutils/gloogateway/clients.go +++ /dev/null @@ -1,148 +0,0 @@ -//go:build ignore - -package gloogateway - -import ( - "context" - - v1alpha1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/external/solo/ratelimit" - v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1" - - gatewayv1 "github.com/kgateway-dev/kgateway/projects/gateway/pkg/api/v1" - "github.com/kgateway-dev/kgateway/test/kubernetes/testutils/cluster" - - "github.com/solo-io/solo-kit/pkg/api/external/kubernetes/service" - "github.com/solo-io/solo-kit/pkg/api/v1/clients/factory" - "github.com/solo-io/solo-kit/pkg/api/v1/clients/kube" - "github.com/solo-io/solo-kit/pkg/api/v1/clients/kube/cache" - skkube "github.com/solo-io/solo-kit/pkg/api/v1/resources/common/kubernetes" -) - -// ResourceClients is a set of clients for interacting with the Edge resources -type ResourceClients interface { - RouteOptionClient() gatewayv1.RouteOptionClient - VirtualHostOptionClient() gatewayv1.VirtualHostOptionClient - ServiceClient() skkube.ServiceClient - UpstreamClient() v1.UpstreamClient - VirtualServiceClient() gatewayv1.VirtualServiceClient - RateLimitConfigClient() v1alpha1.RateLimitConfigClient - GatewayClient() gatewayv1.GatewayClient -} - -type Clients struct { - routeOptionClient gatewayv1.RouteOptionClient - serviceClient skkube.ServiceClient - upstreamClient v1.UpstreamClient - virtualHostOptionClient gatewayv1.VirtualHostOptionClient - virtualServiceClient gatewayv1.VirtualServiceClient - rateLimitConfigClient v1alpha1.RateLimitConfigClient - gatewayClient gatewayv1.GatewayClient -} - -func NewResourceClients(ctx context.Context, clusterCtx *cluster.Context) (ResourceClients, error) { - sharedClientCache := kube.NewKubeCache(ctx) - - routeOptionClientFactory := &factory.KubeResourceClientFactory{ - Crd: gatewayv1.RouteOptionCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - routeOptionClient, err := gatewayv1.NewRouteOptionClient(ctx, routeOptionClientFactory) - if err != nil { - return nil, err - } - - upstreamClientFactory := &factory.KubeResourceClientFactory{ - Crd: v1.UpstreamCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - upstreamClient, err := v1.NewUpstreamClient(ctx, upstreamClientFactory) - if err != nil { - return nil, err - } - - virtualServiceClientFactory := &factory.KubeResourceClientFactory{ - Crd: gatewayv1.VirtualServiceCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - virtualServiceClient, err := gatewayv1.NewVirtualServiceClient(ctx, virtualServiceClientFactory) - if err != nil { - return nil, err - } - - kubeCoreCache, err := cache.NewKubeCoreCache(ctx, clusterCtx.Clientset) - if err != nil { - return nil, err - } - serviceClient := service.NewServiceClient(clusterCtx.Clientset, kubeCoreCache) - - virtualHostOptionClientFactory := &factory.KubeResourceClientFactory{ - Crd: gatewayv1.VirtualHostOptionCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - virtualHostOptionClient, err := gatewayv1.NewVirtualHostOptionClient(ctx, virtualHostOptionClientFactory) - if err != nil { - return nil, err - } - - rlcClientFactory := &factory.KubeResourceClientFactory{ - Crd: v1alpha1.RateLimitConfigCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - rlcClient, err := v1alpha1.NewRateLimitConfigClient(ctx, rlcClientFactory) - if err != nil { - return nil, err - } - - gwClientFactory := &factory.KubeResourceClientFactory{ - Crd: gatewayv1.GatewayCrd, - Cfg: clusterCtx.RestConfig, - SharedCache: sharedClientCache, - } - gwClient, err := gatewayv1.NewGatewayClient(ctx, gwClientFactory) - if err != nil { - return nil, err - } - - return &Clients{ - routeOptionClient: routeOptionClient, - serviceClient: serviceClient, - upstreamClient: upstreamClient, - virtualHostOptionClient: virtualHostOptionClient, - virtualServiceClient: virtualServiceClient, - rateLimitConfigClient: rlcClient, - gatewayClient: gwClient, - }, nil -} - -func (c *Clients) RouteOptionClient() gatewayv1.RouteOptionClient { - return c.routeOptionClient -} - -func (c *Clients) VirtualHostOptionClient() gatewayv1.VirtualHostOptionClient { - return c.virtualHostOptionClient -} - -func (c *Clients) ServiceClient() skkube.ServiceClient { - return c.serviceClient -} - -func (c *Clients) UpstreamClient() v1.UpstreamClient { - return c.upstreamClient -} - -func (c *Clients) VirtualServiceClient() gatewayv1.VirtualServiceClient { - return c.virtualServiceClient -} - -func (c *Clients) RateLimitConfigClient() v1alpha1.RateLimitConfigClient { - return c.rateLimitConfigClient -} - -func (c *Clients) GatewayClient() gatewayv1.GatewayClient { - return c.gatewayClient -} diff --git a/test/kubernetes/testutils/gloogateway/context.go b/test/kubernetes/testutils/gloogateway/context.go index 251c8139f87..6f77433eaf6 100644 --- a/test/kubernetes/testutils/gloogateway/context.go +++ b/test/kubernetes/testutils/gloogateway/context.go @@ -20,16 +20,6 @@ type Context struct { // ValuesManifestFile points to the file that contains the set of Helm values that are unique to this test ValuesManifestFile string - // whether or not the K8s Gateway controller is enabled - K8sGatewayEnabled bool - - // whether or not the installation is an enterprise installation - IsEnterprise bool - - // whether or not the validation webhook is configured to always accept resources, - // i.e. if this is set to true, the webhook will accept regardless of errors found during validation - ValidationAlwaysAccept bool - // is populated if the installation has any AWS options configured (via `settings.aws.*` Helm values) AwsOptions *AwsOptions From 13c25c5dc72290435e00abe33384059a0bd6dc6f Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Fri, 31 Jan 2025 10:45:20 -0500 Subject: [PATCH 03/14] add back readme section --- test/kubernetes/e2e/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/kubernetes/e2e/README.md b/test/kubernetes/e2e/README.md index c29a0adc90a..a7d6e59002f 100644 --- a/test/kubernetes/e2e/README.md +++ b/test/kubernetes/e2e/README.md @@ -53,6 +53,16 @@ Some tests may require environment variables to be set. Some required env vars a - Istio features: Require `ISTIO_VERSION` to be set. The tests running in CI use `ISTIO_VERSION="${ISTIO_VERSION:-1.19.9}"` to default to a specific version of Istio. +## Resource example generation tool + +This tool generates the input resources defined in code as an output yaml file. You can find an example under `test/kubernetes/e2e/features/headless_svc/generate/generate_examples.go`. + +These examples are run as part of the codegen, but can also be manually run using the following command: + +```bash +go generate +``` + ## Debugging Refer to the [Debugging guide](./debugging.md) for more information on how to debug tests. From 9183133b54ff2ebc5bc2047af6c00f4efdd67d98 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Fri, 31 Jan 2025 10:45:30 -0500 Subject: [PATCH 04/14] delete unused file --- test/testutils/services.go | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 test/testutils/services.go diff --git a/test/testutils/services.go b/test/testutils/services.go deleted file mode 100644 index e5256773330..00000000000 --- a/test/testutils/services.go +++ /dev/null @@ -1,23 +0,0 @@ -//go:build ignore - -package testutils - -import ( - "fmt" -) - -const ( - // ConsulBinaryVersion defines the version of the Consul binary - ConsulBinaryVersion = "1.13.3" - // ConsulBinaryName defines the name of the Consul binary - ConsulBinaryName = "consul" - // VaultBinaryVersion defines the version of the Vault binary - VaultBinaryVersion = "1.13.3" - // VaultBinaryName defines the name of the Vault binary - VaultBinaryName = "vault" -) - -var ( - ConsulDockerImage = fmt.Sprintf("hashicorp/%s:%s", ConsulBinaryName, ConsulBinaryVersion) - VaultDockerImage = fmt.Sprintf("hashicorp/%s:%s", VaultBinaryName, VaultBinaryVersion) -) From 0cc3db25b61f4a866229ef34d45b17596ec80565 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 14:00:31 -0500 Subject: [PATCH 05/14] gha Signed-off-by: Jenny Shu --- .github/workflows/pr-kubernetes-tests.yaml | 97 +++++---------- .../workflows/pr-kubernetes-tests.yaml_noop | 113 ------------------ 2 files changed, 27 insertions(+), 183 deletions(-) delete mode 100644 .github/workflows/pr-kubernetes-tests.yaml_noop diff --git a/.github/workflows/pr-kubernetes-tests.yaml b/.github/workflows/pr-kubernetes-tests.yaml index 757957547a8..402fdc82d4a 100644 --- a/.github/workflows/pr-kubernetes-tests.yaml +++ b/.github/workflows/pr-kubernetes-tests.yaml @@ -8,40 +8,8 @@ env: GITHUB_TOKEN: ${{ github.token }} jobs: - # TODO consider adding back later if we want to handle skip directives. - # currently we don't have changelogs to add the skip directives to - # prepare_env: - # name: Prepare Environment - # runs-on: ubuntu-22.04 - # timeout-minutes: 5 - # outputs: - # should-auto-succeed-kube-tests: ${{ steps.run-strategy.outputs.auto_succeed }} - # steps: - # - name: Cancel Previous Actions - # uses: styfle/cancel-workflow-action@0.12.1 - # with: - # access_token: ${{ github.token }} - # - id: checkout-code - # uses: actions/checkout@v4 - # with: - # # We require gathering the branch and tag history since we rely on a `git diff` - # # which compares the state of two branches - # fetch-depth: 0 - # - id: process-skip-directives - # uses: ./.github/actions/process-skip-directives - # with: - # base-ref: ${{ github.base_ref }} - # - id: run-strategy - # name: Determine Test Run Strategy - # run: | - # skip_kube_tests=${{ steps.process-skip-directives.outputs.skip-kube-tests }} - # if [[ ! -z $skip_kube_tests && $skip_kube_tests = true ]] ; then - # echo "auto_succeed=true" >> $GITHUB_OUTPUT - # fi - end_to_end_tests: name: End-to-End (${{ matrix.test.cluster-name }}) - # needs: prepare_env runs-on: ubuntu-22.04 timeout-minutes: 60 if: ${{ !github.event.pull_request.draft }} @@ -57,69 +25,59 @@ jobs: # NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture test: + # Feb 17, 2025: ? minutes - cluster-name: 'cluster-one' go-test-args: '-v -timeout=25m' - go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$' - # Dec 4, 2024: 22 minutes - # - cluster-name: 'cluster-one' - # go-test-args: '-v -timeout=25m' - # go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$' + go-test-run-regex: '^TestK8sGateway$$/^BasicRouting$$' - # # Dec 4, 2024: 23 minutes - # - cluster-name: 'cluster-two' - # go-test-args: '-v -timeout=25m' - # go-test-run-regex: '^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$' +# # Dec 4, 2024: 23 minutes +# - cluster-name: 'cluster-two' +# go-test-args: '-v -timeout=25m' +# go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$' - # # Dec 4, 2024: 24 minutes - # - cluster-name: 'cluster-three' - # go-test-args: '-v -timeout=30m' - # go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)' +# # Dec 4, 2024: 24 minutes +# - cluster-name: 'cluster-three' +# go-test-args: '-v -timeout=30m' +# go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)' - # # Dec 4, 2024: 21 minutes - # - cluster-name: 'cluster-four' - # go-test-args: '-v -timeout=30m' - # go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)' +# # Dec 4, 2024: 21 minutes +# - cluster-name: 'cluster-four' +# go-test-args: '-v -timeout=30m' +# go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)' - # # Dec 4, 2024: 24 minutes - # - cluster-name: 'cluster-five' - # go-test-args: '-v -timeout=30m' - # go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$' +# # Dec 4, 2024: 24 minutes +# - cluster-name: 'cluster-five' +# go-test-args: '-v -timeout=30m' +# go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$' - # # Dec 4, 2024: 26 minutes - # - cluster-name: 'cluster-six' - # go-test-args: '-v -timeout=30m' - # go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$|^TestZeroDowntimeRollout$$' +# # Dec 4, 2024: 26 minutes +# - cluster-name: 'cluster-six' +# go-test-args: '-v -timeout=30m' +# go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$|^TestZeroDowntimeRollout$$' - # # Dec 4, 2024: 13 minutes - # - cluster-name: 'cluster-seven' - # go-test-args: '-v -timeout=25m' - # go-test-run-regex: '^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^Metrics$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$' +# # Dec 4, 2024: 13 minutes +# - cluster-name: 'cluster-seven' +# go-test-args: '-v -timeout=25m' +# go-test-run-regex: '^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^Metrics$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$' # In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support - # The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/ + # The versions should mirror: https://kgateway.dev/docs/reference/versions/ version-files: - file: './.github/workflows/.env/pr-tests/versions.env' steps: - # - id: auto-succeed-tests - # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests == 'true' - # run: | - # echo "Regression tests auto-succeeded" - uses: actions/checkout@v4 - name: Prep Go Runner uses: ./.github/actions/prep-go-runner - # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' # The dotenv action is used to load key-value pairs from files. # In this case, the file is specified in the matrix and will contain the versions of the tools to use - name: Dotenv Action uses: falti/dotenv-action@v1.1.4 - # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' id: dotenv with: path: ${{ matrix.version-files.file }} log-variables: true - id: setup-kind-cluster name: Setup KinD Cluster - # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' uses: ./.github/actions/setup-kind-cluster with: cluster-name: ${{ matrix.test.cluster-name }} @@ -129,7 +87,6 @@ jobs: helm-version: ${{ steps.dotenv.outputs.helm_version }} istio-version: ${{ steps.dotenv.outputs.istio_version }} - id: run-tests - # if: needs.prepare_env.outputs.should-auto-succeed-kube-tests != 'true' uses: ./.github/actions/kubernetes-e2e-tests with: cluster-name: ${{ matrix.test.cluster-name }} diff --git a/.github/workflows/pr-kubernetes-tests.yaml_noop b/.github/workflows/pr-kubernetes-tests.yaml_noop deleted file mode 100644 index a7fa005f0ad..00000000000 --- a/.github/workflows/pr-kubernetes-tests.yaml_noop +++ /dev/null @@ -1,113 +0,0 @@ -# name: Kubernetes Tests -# on: -# pull_request: -# types: [opened, synchronize, reopened, ready_for_review] - -# env: -# VERSION: '1.0.0-ci1' -# GITHUB_TOKEN: ${{ github.token }} - -# jobs: -# prepare_env: -# name: Prepare Environment -# runs-on: ubuntu-22.04 -# timeout-minutes: 5 -# steps: -# - name: Cancel Previous Actions -# uses: styfle/cancel-workflow-action@0.12.1 -# with: -# access_token: ${{ github.token }} -# - id: checkout-code -# uses: actions/checkout@v4 -# with: -# # We require gathering the branch and tag history since we rely on a `git diff` -# # which compares the state of two branches -# fetch-depth: 0 - -# end_to_end_tests: -# name: End-to-End (${{ matrix.test.cluster-name }}) -# needs: prepare_env -# runs-on: ubuntu-22.04 -# timeout-minutes: 60 -# if: ${{ !github.event.pull_request.draft }} -# strategy: -# fail-fast: false -# matrix: -# # We intentionally set an upper threshold of 30 minutes for our End-to-End tests -# # Our goal is to load balance tests in a way that allows quick iteration on PRs -# # If tests are exceeding the 30-minute limit, please see: -# # /test/kubernetes/e2e/load_balancing_tests.md -# # -# # Above each test below, we document the latest date/time for the GitHub action step to run -# # NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture - -# test: -# # Dec 4, 2024: 22 minutes -# - cluster-name: 'cluster-one' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$' - -# # Dec 4, 2024: 23 minutes -# - cluster-name: 'cluster-two' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$' - -# # Dec 4, 2024: 24 minutes -# - cluster-name: 'cluster-three' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)' - -# # Dec 4, 2024: 21 minutes -# - cluster-name: 'cluster-four' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)' - -# # Dec 4, 2024: 24 minutes -# - cluster-name: 'cluster-five' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$' - -# # Dec 4, 2024: 26 minutes -# - cluster-name: 'cluster-six' -# go-test-args: '-v -timeout=30m' -# go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$|^TestZeroDowntimeRollout$$' - -# # Dec 4, 2024: 13 minutes -# - cluster-name: 'cluster-seven' -# go-test-args: '-v -timeout=25m' -# go-test-run-regex: '^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^Metrics$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$' - -# # In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support -# # The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/ -# version-files: -# - file: './.github/workflows/.env/pr-tests/versions.env' -# steps: -# - uses: actions/checkout@v4 -# - name: Prep Go Runner -# uses: ./.github/actions/prep-go-runner -# # The dotenv action is used to load key-value pairs from files. -# # In this case, the file is specified in the matrix and will contain the versions of the tools to use -# - name: Dotenv Action -# uses: falti/dotenv-action@v1.1.4 -# id: dotenv -# with: -# path: ${{ matrix.version-files.file }} -# log-variables: true -# - id: setup-kind-cluster -# name: Setup KinD Cluster -# uses: ./.github/actions/setup-kind-cluster -# with: -# cluster-name: ${{ matrix.test.cluster-name }} -# kind-node-version: ${{ steps.dotenv.outputs.node_version }} -# kind-version: ${{ steps.dotenv.outputs.kind_version }} -# kubectl-version: ${{ steps.dotenv.outputs.kubectl_version }} -# helm-version: ${{ steps.dotenv.outputs.helm_version }} -# istio-version: ${{ steps.dotenv.outputs.istio_version }} -# - id: run-tests -# uses: ./.github/actions/kubernetes-e2e-tests -# with: -# cluster-name: ${{ matrix.test.cluster-name }} -# test-args: ${{ matrix.test.go-test-args }} -# run-regex: ${{ matrix.test.go-test-run-regex }} -# istio-version: ${{ steps.dotenv.outputs.istio_version }} -# matrix-label: "pr" From b49010f1e5045a90c3ef70c84d123f2cdb04ed73 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 14:01:53 -0500 Subject: [PATCH 06/14] enable build test helpers Signed-off-by: Jenny Shu --- test/gomega/gomega.go | 2 - test/gomega/matchers/contain_map_elements.go | 2 - .../matchers/contain_map_elements_test.go | 2 - test/gomega/matchers/have_http_response.go | 3 - .../matchers/have_kubegateway_status.go | 2 - test/gomega/matchers/have_status.go | 290 ------------------ test/gomega/matchers/json_contains.go | 2 - test/gomega/matchers/json_contains_test.go | 2 - test/gomega/matchers/matchers_suite_test.go | 2 - test/gomega/transforms/curl.go | 2 - test/gomega/transforms/curl_test.go | 12 +- test/helpers/timeouts.go | 2 - test/kubernetes/e2e/defaults/defaults.go | 2 - test/kubernetes/testutils/assertions/curl.go | 2 - .../testutils/assertions/deployments.go | 31 -- test/kubernetes/testutils/assertions/pods.go | 2 - 16 files changed, 4 insertions(+), 356 deletions(-) delete mode 100644 test/gomega/matchers/have_status.go diff --git a/test/gomega/gomega.go b/test/gomega/gomega.go index 8a3e6ff9839..d4cd78df544 100644 --- a/test/gomega/gomega.go +++ b/test/gomega/gomega.go @@ -1,5 +1,3 @@ -//go:build ignore - package gomega import ( diff --git a/test/gomega/matchers/contain_map_elements.go b/test/gomega/matchers/contain_map_elements.go index 5b951356e62..772457d952e 100644 --- a/test/gomega/matchers/contain_map_elements.go +++ b/test/gomega/matchers/contain_map_elements.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers import ( diff --git a/test/gomega/matchers/contain_map_elements_test.go b/test/gomega/matchers/contain_map_elements_test.go index d1662817c6e..9b9d1b09917 100644 --- a/test/gomega/matchers/contain_map_elements_test.go +++ b/test/gomega/matchers/contain_map_elements_test.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers_test import ( diff --git a/test/gomega/matchers/have_http_response.go b/test/gomega/matchers/have_http_response.go index 19ee5eb3aea..d218635cc3d 100644 --- a/test/gomega/matchers/have_http_response.go +++ b/test/gomega/matchers/have_http_response.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers import ( @@ -10,7 +8,6 @@ import ( "github.com/onsi/gomega" "github.com/onsi/gomega/gstruct" - "github.com/onsi/gomega/matchers" "github.com/onsi/gomega/types" ) diff --git a/test/gomega/matchers/have_kubegateway_status.go b/test/gomega/matchers/have_kubegateway_status.go index c7b6d1f90a7..70a3345da9a 100644 --- a/test/gomega/matchers/have_kubegateway_status.go +++ b/test/gomega/matchers/have_kubegateway_status.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers import ( diff --git a/test/gomega/matchers/have_status.go b/test/gomega/matchers/have_status.go deleted file mode 100644 index 80a1ba2b611..00000000000 --- a/test/gomega/matchers/have_status.go +++ /dev/null @@ -1,290 +0,0 @@ -//go:build ignore - -package matchers - -import ( - "fmt" - - "github.com/onsi/gomega" - "github.com/onsi/gomega/gstruct" - "github.com/onsi/gomega/types" - "github.com/rotisserie/eris" - "github.com/solo-io/solo-kit/pkg/api/v1/resources/core" -) - -// SoloKitStatus defines the set of properties that we can validate from a core.Status -type SoloKitStatus struct { - State *core.Status_State - Reason string - ReportedBy string - SubresourceStatuses map[string]SoloKitSubresourceStatus - // TODO: implement as needed - // Details *structpb.Struct - // Messages []string - // Custom is a generic matcher that can be applied to validate any other properties of a core.Status - // Optional: If not provided, does not perform additional validation - Custom types.GomegaMatcher -} - -// SoloKitSubresourceStatus is a struct for subresource status fields -type SoloKitSubresourceStatus struct { - Reason string - ReportedBy string - State string -} - -// SoloKitNamespacedStatuses defines the set of properties that we can validate from a core.NamespacedStatuses -type SoloKitNamespacedStatuses struct { - Statuses map[string]*SoloKitStatus -} - -func HaveState(state core.Status_State) types.GomegaMatcher { - return HaveStatus(&SoloKitStatus{ - State: &state, - }) -} - -func HaveReportedBy(reporter string) types.GomegaMatcher { - return HaveStatus(&SoloKitStatus{ - ReportedBy: reporter, - }) -} - -func HaveSubResourceStatusState(subResourceName string, subResourceStatus SoloKitSubresourceStatus) types.GomegaMatcher { - return HaveStatus(&SoloKitStatus{ - SubresourceStatuses: map[string]SoloKitSubresourceStatus{ - subResourceName: subResourceStatus, - }, - }) -} - -func HaveAcceptedState() types.GomegaMatcher { - st := core.Status_Accepted - return HaveStatus(&SoloKitStatus{ - State: &st, - }) -} - -func HaveWarningStateWithReasonSubstrings(reasons ...string) types.GomegaMatcher { - m := HaveReasonSubstrings(reasons...) - st := core.Status_Warning - m.(*HaveStatusMatcher).Expected.State = &st - return m -} - -func HaveRejectedStateWithReasonSubstrings(reasons ...string) types.GomegaMatcher { - m := HaveReasonSubstrings(reasons...) - st := core.Status_Rejected - m.(*HaveStatusMatcher).Expected.State = &st - return m -} - -func HaveReasonSubstrings(reasons ...string) types.GomegaMatcher { - return HaveStatus(&SoloKitStatus{ - Custom: gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "Reason": ContainSubstrings(reasons), - }), - }) -} - -// MatchStatusInNamespace will create a matcher that allows a *HaveStatusMatcher generated from this -// package to be matched against the provided namespace in a HaveNamespacedStatusesMatcher -func MatchStatusInNamespace(ns string, matcher types.GomegaMatcher) types.GomegaMatcher { - // TODO the dev ux of this isn't great since we will not have data for matchers of different types, - // though we should expect not to receive such matchers. - expected := &SoloKitStatus{} - m, ok := matcher.(*HaveStatusMatcher) - if ok { - expected = m.Expected - } - - return &HaveNamespacedStatusesMatcher{ - Expected: &SoloKitNamespacedStatuses{ - Statuses: map[string]*SoloKitStatus{ - ns: expected, - }, - }, - namespacedStatusesMatchers: map[string]types.GomegaMatcher{ - ns: matcher, - }, - evaluated: false, - } -} - -func HaveStatusInNamespace(ns string, status *core.Status) types.GomegaMatcher { - st := status.GetState() - return HaveNamespacedStatuses(&SoloKitNamespacedStatuses{ - Statuses: map[string]*SoloKitStatus{ - ns: { - State: &st, - Reason: status.GetReason(), - ReportedBy: status.GetReportedBy(), - }, - }, - }) -} - -func HaveNamespacedStatuses(expected *SoloKitNamespacedStatuses) types.GomegaMatcher { - if expected == nil { - // If no status is defined, we create a matcher that always succeeds - return gstruct.Ignore() - } - namespacedStatusMatchers := map[string]types.GomegaMatcher{} - for ns, expectedStatus := range expected.Statuses { - namespacedStatusMatchers[ns] = HaveStatus(expectedStatus) - } - return &HaveNamespacedStatusesMatcher{ - Expected: expected, - namespacedStatusesMatchers: namespacedStatusMatchers, - evaluated: false, - } -} - -// HaveStatus produces a matcher that will match if the provided status matches the -// actual status -func HaveStatus(expected *SoloKitStatus) types.GomegaMatcher { - if expected == nil { - // If no status is defined, we create a matcher that always succeeds - return gstruct.Ignore() - } - expectedCustomMatcher := expected.Custom - if expectedCustomMatcher == nil { - // Default to an always accept matcher - expectedCustomMatcher = gstruct.Ignore() - } - partialStatusMatchers := []types.GomegaMatcher{expectedCustomMatcher} - - expectedStateMatcher := gstruct.Ignore() - if expected.State != nil { - expectedStateMatcher = gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "State": gomega.Equal(*expected.State), - }) - } - partialStatusMatchers = append(partialStatusMatchers, expectedStateMatcher) - - expectedReasonMatcher := gstruct.Ignore() - if expected.Reason != "" { - expectedReasonMatcher = gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "Reason": gomega.Equal(expected.Reason), - }) - } - partialStatusMatchers = append(partialStatusMatchers, expectedReasonMatcher) - - expectedReportedByMatcher := gstruct.Ignore() - if expected.ReportedBy != "" { - expectedReportedByMatcher = gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "ReportedBy": gomega.Equal(expected.ReportedBy), - }) - } - partialStatusMatchers = append(partialStatusMatchers, expectedReportedByMatcher) - - // Matcher for subresource statuses - expectedSubresourceStatusesMatcher := gstruct.Ignore() - if expected.SubresourceStatuses != nil { - subresourceMatchers := make(map[string]types.GomegaMatcher) - for subresourceKey, subresourceStatus := range expected.SubresourceStatuses { - subresourceMatchers[subresourceKey] = gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "Reason": gomega.ContainSubstring(subresourceStatus.Reason), - "ReportedBy": gomega.Equal(subresourceStatus.ReportedBy), - "State": gomega.Equal(subresourceStatus.State), - }) - } - expectedSubresourceStatusesMatcher = gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ - "SubresourceStatuses": gstruct.MatchFields(gstruct.IgnoreExtras, subresourceMatchers), - }) - } - partialStatusMatchers = append(partialStatusMatchers, expectedSubresourceStatusesMatcher) - - return &HaveStatusMatcher{ - Expected: expected, - statusMatcher: gomega.And(partialStatusMatchers...), - } -} - -type HaveStatusMatcher struct { - Expected *SoloKitStatus - statusMatcher types.GomegaMatcher - // An internal utility for tracking whether we have evaluated this matcher - // There is a comment within the Match method, outlining why we introduced this - evaluated bool -} - -func (m *HaveStatusMatcher) Match(actual interface{}) (success bool, err error) { - if m.evaluated { - // Matchers are intended to be short-lived, and we have seen inconsistent behaviors - // when evaluating the same matcher multiple times. - // For example, the underlying http body matcher caches the response body, so if you are wrapping this - // matcher in an Eventually, you need to create a new matcher each iteration. - // This error is intended to help prevent developers hitting this edge case - return false, eris.New("using the same matcher twice can lead to inconsistent behaviors") - } - m.evaluated = true - - if ok, err := m.statusMatcher.Match(actual); !ok { - return false, err - } - - return true, nil -} - -func (m *HaveStatusMatcher) FailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("%s \n%s", - m.statusMatcher.FailureMessage(actual), - informativeComparison(m.Expected, actual)) -} - -func (m *HaveStatusMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("%s \n%s", - m.statusMatcher.NegatedFailureMessage(actual), - informativeComparison(m.Expected, actual)) -} - -type HaveNamespacedStatusesMatcher struct { - Expected *SoloKitNamespacedStatuses - namespacedStatusesMatchers map[string]types.GomegaMatcher - // An internal utility for tracking whether we have evaluated this matcher - // There is a comment within the Match method, outlining why we introduced this - evaluated bool -} - -func (m *HaveNamespacedStatusesMatcher) Match(actual interface{}) (success bool, err error) { - if m.evaluated { - // Matchers are intended to be short-lived, and we have seen inconsistent behaviors - // when evaluating the same matcher multiple times. - // For example, the underlying http body matcher caches the response body, so if you are wrapping this - // matcher in an Eventually, you need to create a new matcher each iteration. - // This error is intended to help prevent developers hitting this edge case - return false, eris.New("using the same matcher twice can lead to inconsistent behaviors") - } - m.evaluated = true - - val, ok := actual.(core.NamespacedStatuses) - if !ok { - return false, eris.Errorf("matcher expected core.NamespacedStatuses, got %T", actual) - } - - for ns, matcher := range m.namespacedStatusesMatchers { - actualStatus, ok := val.GetStatuses()[ns] - if !ok { - return false, eris.Errorf("have matcher for namespace %s which is not found", ns) - } - if actualStatus == nil { - return false, eris.New("got nil status") - } - if ok, err := matcher.Match(*actualStatus); !ok { - return false, err - } - } - - return true, nil -} - -func (m *HaveNamespacedStatusesMatcher) FailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("%s", - informativeComparison(m.Expected, actual)) -} - -func (m *HaveNamespacedStatusesMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("%s", - informativeComparison(m.Expected, actual)) -} diff --git a/test/gomega/matchers/json_contains.go b/test/gomega/matchers/json_contains.go index 1fbc0980fe5..2ce6f3c7bbf 100644 --- a/test/gomega/matchers/json_contains.go +++ b/test/gomega/matchers/json_contains.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers import ( diff --git a/test/gomega/matchers/json_contains_test.go b/test/gomega/matchers/json_contains_test.go index 3ca7b95a311..4d22147ab14 100644 --- a/test/gomega/matchers/json_contains_test.go +++ b/test/gomega/matchers/json_contains_test.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers_test import ( diff --git a/test/gomega/matchers/matchers_suite_test.go b/test/gomega/matchers/matchers_suite_test.go index d4a6f95b547..f9bb193b521 100644 --- a/test/gomega/matchers/matchers_suite_test.go +++ b/test/gomega/matchers/matchers_suite_test.go @@ -1,5 +1,3 @@ -//go:build ignore - package matchers_test import ( diff --git a/test/gomega/transforms/curl.go b/test/gomega/transforms/curl.go index 6e3b21abf17..52818737b07 100644 --- a/test/gomega/transforms/curl.go +++ b/test/gomega/transforms/curl.go @@ -1,5 +1,3 @@ -//go:build ignore - package transforms import ( diff --git a/test/gomega/transforms/curl_test.go b/test/gomega/transforms/curl_test.go index 765b0209e74..fe9af464cd9 100644 --- a/test/gomega/transforms/curl_test.go +++ b/test/gomega/transforms/curl_test.go @@ -1,20 +1,16 @@ -//go:build ignore - package transforms_test import ( "fmt" "net/http" - "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils/kubectl" - "github.com/kgateway-dev/kgateway/v2/test/gomega/transforms" - + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/onsi/gomega/gstruct" + "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils/kubectl" "github.com/kgateway-dev/kgateway/v2/test/gomega/matchers" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "github.com/kgateway-dev/kgateway/v2/test/gomega/transforms" ) var _ = Describe("Curl", func() { diff --git a/test/helpers/timeouts.go b/test/helpers/timeouts.go index 2ade5f2e66e..046e7ebc77b 100644 --- a/test/helpers/timeouts.go +++ b/test/helpers/timeouts.go @@ -1,5 +1,3 @@ -//go:build ignore - package helpers import ( diff --git a/test/kubernetes/e2e/defaults/defaults.go b/test/kubernetes/e2e/defaults/defaults.go index 86aa752d2e9..8eb31494ff1 100644 --- a/test/kubernetes/e2e/defaults/defaults.go +++ b/test/kubernetes/e2e/defaults/defaults.go @@ -1,5 +1,3 @@ -//go:build ignore - package defaults import ( diff --git a/test/kubernetes/testutils/assertions/curl.go b/test/kubernetes/testutils/assertions/curl.go index 9d0313cc8de..dd2adb8f1be 100644 --- a/test/kubernetes/testutils/assertions/curl.go +++ b/test/kubernetes/testutils/assertions/curl.go @@ -1,5 +1,3 @@ -//go:build ignore - package assertions import ( diff --git a/test/kubernetes/testutils/assertions/deployments.go b/test/kubernetes/testutils/assertions/deployments.go index 762ed4f00f2..48c850b8917 100644 --- a/test/kubernetes/testutils/assertions/deployments.go +++ b/test/kubernetes/testutils/assertions/deployments.go @@ -1,5 +1,3 @@ -//go:build ignore - package assertions import ( @@ -8,12 +6,9 @@ import ( . "github.com/onsi/gomega" "github.com/onsi/gomega/types" - "github.com/solo-io/go-utils/stats" - "go.uber.org/zap/zapcore" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils" - "github.com/kgateway-dev/kgateway/v2/test/gomega/assertions" ) func (p *Provider) EventuallyRunningReplicas(ctx context.Context, deploymentMeta metav1.ObjectMeta, replicaMatcher types.GomegaMatcher) { @@ -30,29 +25,3 @@ func (p *Provider) EventuallyRunningReplicas(ctx context.Context, deploymentMeta WithPolling(time.Millisecond * 200). Should(Succeed()) } - -func (p *Provider) EventuallyGlooReachesConsistentState(installNamespace string) { - // We port-forward the Gloo deployment stats port to inspect the metrics and log settings - // TODO(jbohanon) clean this up with newer style portforwarder - glooStatsForwardConfig := assertions.StatsPortFwd{ - ResourceName: "deployment/gloo", - ResourceNamespace: installNamespace, - LocalPort: stats.DefaultPort, - TargetPort: stats.DefaultPort, - } - - // Gloo components are configured to log to the Info level by default but for these e2e tests we explicitly enable debug logging - // This is done so we can triage failures after the fact and matches the process users will take to troubleshoot - logLevelAssertion := assertions.LogLevelAssertion(zapcore.DebugLevel) - - // The emitter at some point should stabilize and not continue to increase the number of snapshots produced - // We choose 4 here as a bit of a magic number, but we feel comfortable that if 4 consecutive polls of the metrics - // endpoint returns that same value, then we have stabilized - identicalResultInARow := 4 - emitterMetricAssertion, _ := assertions.IntStatisticReachesConsistentValueAssertion("api_gloosnapshot_gloo_solo_io_emitter_snap_out", identicalResultInARow) - - assertions.EventuallyStatisticsMatchAssertions(glooStatsForwardConfig, - logLevelAssertion, - emitterMetricAssertion, - ) -} diff --git a/test/kubernetes/testutils/assertions/pods.go b/test/kubernetes/testutils/assertions/pods.go index cf8c88fefec..55a517d2684 100644 --- a/test/kubernetes/testutils/assertions/pods.go +++ b/test/kubernetes/testutils/assertions/pods.go @@ -1,5 +1,3 @@ -//go:build ignore - package assertions import ( From c6efeea0f0bd83702bbd579bf0e8bea6feb220cd Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 14:09:24 -0500 Subject: [PATCH 07/14] add basicrouting Signed-off-by: Jenny Shu --- .../e2e/features/basicrouting/suite.go | 102 ++++++++++++++++++ .../testdata/gateway-with-route.yaml | 27 +++++ .../basicrouting/testdata/service.yaml | 25 +++++ .../e2e/features/basicrouting/types.go | 41 +++++++ test/kubernetes/e2e/tests/k8s_gw_tests.go | 3 + 5 files changed, 198 insertions(+) create mode 100644 test/kubernetes/e2e/features/basicrouting/suite.go create mode 100644 test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml create mode 100644 test/kubernetes/e2e/features/basicrouting/testdata/service.yaml create mode 100644 test/kubernetes/e2e/features/basicrouting/types.go diff --git a/test/kubernetes/e2e/features/basicrouting/suite.go b/test/kubernetes/e2e/features/basicrouting/suite.go new file mode 100644 index 00000000000..1bb29a724d4 --- /dev/null +++ b/test/kubernetes/e2e/features/basicrouting/suite.go @@ -0,0 +1,102 @@ +package basicrouting + +import ( + "context" + "net/http" + + "github.com/onsi/gomega" + "github.com/stretchr/testify/suite" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils" + "github.com/kgateway-dev/kgateway/v2/pkg/utils/requestutils/curl" + testmatchers "github.com/kgateway-dev/kgateway/v2/test/gomega/matchers" + "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e" + testdefaults "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/defaults" +) + +var _ e2e.NewSuiteFunc = NewTestingSuite + +// testingSuite is a suite of basic routing / "happy path" tests +type testingSuite struct { + suite.Suite + + ctx context.Context + + // testInstallation contains all the metadata/utilities necessary to execute a series of tests + // against an installation of kgateway + testInstallation *e2e.TestInstallation + + // manifests maps test name to a list of manifests to apply before the test + manifests map[string][]string + + // manifestObjects maps a manifest file to a list of objects that are contained in that file + manifestObjects map[string][]client.Object +} + +func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite { + return &testingSuite{ + ctx: ctx, + testInstallation: testInst, + } +} + +func (s *testingSuite) SetupSuite() { + s.manifests = map[string][]string{ + "TestGatewayWithRoute": { + testdefaults.CurlPodManifest, + exampleServiceManifest, + gatewayWithRouteManifest, + }, + } + + s.manifestObjects = map[string][]client.Object{ + testdefaults.CurlPodManifest: {testdefaults.CurlPod}, + exampleServiceManifest: {nginxPod, exampleSvc}, + gatewayWithRouteManifest: {proxyService, proxyServiceAccount, proxyDeployment}, + } +} + +func (s *testingSuite) TearDownSuite() { + // nothing at the moment +} + +func (s *testingSuite) BeforeTest(suiteName, testName string) { + manifests := s.manifests[testName] + for _, manifest := range manifests { + err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, manifest) + s.Require().NoError(err) + s.testInstallation.Assertions.EventuallyObjectsExist(s.ctx, s.manifestObjects[manifest]...) + } +} + +func (s *testingSuite) AfterTest(suiteName, testName string) { + manifests := s.manifests[testName] + for _, manifest := range manifests { + err := s.testInstallation.Actions.Kubectl().DeleteFileSafe(s.ctx, manifest) + s.Require().NoError(err) + s.testInstallation.Assertions.EventuallyObjectsNotExist(s.ctx, s.manifestObjects[manifest]...) + } +} + +func (s *testingSuite) TestGatewayWithRoute() { + s.testInstallation.Assertions.EventuallyRunningReplicas(s.ctx, proxyDeployment.ObjectMeta, gomega.Equal(1)) + + // Should have a successful response + s.testInstallation.Assertions.AssertEventualCurlResponse( + s.ctx, + testdefaults.CurlPodExecOpt, + []curl.Option{ + curl.WithHost(kubeutils.ServiceFQDN(metav1.ObjectMeta{ + Name: glooProxyObjectMeta.Name, + Namespace: glooProxyObjectMeta.Namespace, + })), + curl.WithHostHeader("example.com"), + curl.WithPort(80), + }, + &testmatchers.HttpResponse{ + StatusCode: http.StatusOK, + Body: gomega.ContainSubstring(testdefaults.NginxResponse), + }) +} diff --git a/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml new file mode 100644 index 00000000000..50e64d2d105 --- /dev/null +++ b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml @@ -0,0 +1,27 @@ +kind: Gateway +apiVersion: gateway.networking.k8s.io/v1 +metadata: + name: gw +spec: + gatewayClassName: gloo-gateway + listeners: + - protocol: HTTP + port: 8080 + name: http + allowedRoutes: + namespaces: + from: Same +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: example-route +spec: + parentRefs: + - name: gw + hostnames: + - "example.com" + rules: + - backendRefs: + - name: nginx + port: 8080 \ No newline at end of file diff --git a/test/kubernetes/e2e/features/basicrouting/testdata/service.yaml b/test/kubernetes/e2e/features/basicrouting/testdata/service.yaml new file mode 100644 index 00000000000..52d9b217730 --- /dev/null +++ b/test/kubernetes/e2e/features/basicrouting/testdata/service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + name: example-svc +spec: + selector: + app.kubernetes.io/name: nginx + ports: + - protocol: TCP + port: 8080 + targetPort: http-web-svc +--- +apiVersion: v1 +kind: Pod +metadata: + name: nginx + labels: + app.kubernetes.io/name: nginx +spec: + containers: + - name: nginx + image: nginx:stable + ports: + - containerPort: 80 + name: http-web-svc diff --git a/test/kubernetes/e2e/features/basicrouting/types.go b/test/kubernetes/e2e/features/basicrouting/types.go new file mode 100644 index 00000000000..8ca454cfe0e --- /dev/null +++ b/test/kubernetes/e2e/features/basicrouting/types.go @@ -0,0 +1,41 @@ +package basicrouting + +import ( + "path/filepath" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + + "github.com/kgateway-dev/kgateway/v2/pkg/utils/fsutils" +) + +var ( + // manifests + exampleServiceManifest = filepath.Join(fsutils.MustGetThisDir(), "testdata", "service.yaml") + gatewayWithRouteManifest = filepath.Join(fsutils.MustGetThisDir(), "testdata", "gateway-with-route.yaml") + + // objects + glooProxyObjectMeta = metav1.ObjectMeta{ + Name: "gw", + Namespace: "default", + } + proxyDeployment = &appsv1.Deployment{ObjectMeta: glooProxyObjectMeta} + proxyService = &corev1.Service{ObjectMeta: glooProxyObjectMeta} + proxyServiceAccount = &corev1.ServiceAccount{ObjectMeta: glooProxyObjectMeta} + gw = &gwapiv1.Gateway{ObjectMeta: glooProxyObjectMeta} + + exampleSvc = &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: "example-svc", + Namespace: "default", + }, + } + nginxPod = &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "nginx", + Namespace: "default", + }, + } +) diff --git a/test/kubernetes/e2e/tests/k8s_gw_tests.go b/test/kubernetes/e2e/tests/k8s_gw_tests.go index def01cc16e9..111b88a7633 100644 --- a/test/kubernetes/e2e/tests/k8s_gw_tests.go +++ b/test/kubernetes/e2e/tests/k8s_gw_tests.go @@ -2,6 +2,7 @@ package tests import ( "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e" + "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/features/basicrouting" // "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/features/admin_server" // "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/features/crd_categories" // "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/features/deployer" @@ -22,6 +23,8 @@ import ( func KubeGatewaySuiteRunner() e2e.SuiteRunner { kubeGatewaySuiteRunner := e2e.NewSuiteRunner(false) + kubeGatewaySuiteRunner.Register("BasicRouting", basicrouting.NewTestingSuite) + // kubeGatewaySuiteRunner.Register("Deployer", deployer.NewTestingSuite) // kubeGatewaySuiteRunner.Register("HttpListenerOptions", http_listener_options.NewTestingSuite) // kubeGatewaySuiteRunner.Register("ListenerOptions", listener_options.NewTestingSuite) From 3472e295637efb0adc7ddc6527884a5ddf423b71 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 14:44:31 -0500 Subject: [PATCH 08/14] fix gatewayclassname Signed-off-by: Jenny Shu --- .../e2e/features/basicrouting/testdata/gateway-with-route.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml index 50e64d2d105..616f8861527 100644 --- a/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml +++ b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml @@ -3,7 +3,7 @@ apiVersion: gateway.networking.k8s.io/v1 metadata: name: gw spec: - gatewayClassName: gloo-gateway + gatewayClassName: kgateway listeners: - protocol: HTTP port: 8080 From 91167fd2ad75ddffaadac1c831d73a20092f5a1b Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 14:45:26 -0500 Subject: [PATCH 09/14] remove gloo refs Signed-off-by: Jenny Shu --- test/kubernetes/e2e/features/basicrouting/suite.go | 4 ++-- test/kubernetes/e2e/features/basicrouting/types.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/kubernetes/e2e/features/basicrouting/suite.go b/test/kubernetes/e2e/features/basicrouting/suite.go index 1bb29a724d4..163df4464b6 100644 --- a/test/kubernetes/e2e/features/basicrouting/suite.go +++ b/test/kubernetes/e2e/features/basicrouting/suite.go @@ -89,8 +89,8 @@ func (s *testingSuite) TestGatewayWithRoute() { testdefaults.CurlPodExecOpt, []curl.Option{ curl.WithHost(kubeutils.ServiceFQDN(metav1.ObjectMeta{ - Name: glooProxyObjectMeta.Name, - Namespace: glooProxyObjectMeta.Namespace, + Name: proxyObjectMeta.Name, + Namespace: proxyObjectMeta.Namespace, })), curl.WithHostHeader("example.com"), curl.WithPort(80), diff --git a/test/kubernetes/e2e/features/basicrouting/types.go b/test/kubernetes/e2e/features/basicrouting/types.go index 8ca454cfe0e..33dd6fc7c47 100644 --- a/test/kubernetes/e2e/features/basicrouting/types.go +++ b/test/kubernetes/e2e/features/basicrouting/types.go @@ -17,14 +17,14 @@ var ( gatewayWithRouteManifest = filepath.Join(fsutils.MustGetThisDir(), "testdata", "gateway-with-route.yaml") // objects - glooProxyObjectMeta = metav1.ObjectMeta{ + proxyObjectMeta = metav1.ObjectMeta{ Name: "gw", Namespace: "default", } - proxyDeployment = &appsv1.Deployment{ObjectMeta: glooProxyObjectMeta} - proxyService = &corev1.Service{ObjectMeta: glooProxyObjectMeta} - proxyServiceAccount = &corev1.ServiceAccount{ObjectMeta: glooProxyObjectMeta} - gw = &gwapiv1.Gateway{ObjectMeta: glooProxyObjectMeta} + proxyDeployment = &appsv1.Deployment{ObjectMeta: proxyObjectMeta} + proxyService = &corev1.Service{ObjectMeta: proxyObjectMeta} + proxyServiceAccount = &corev1.ServiceAccount{ObjectMeta: proxyObjectMeta} + gw = &gwapiv1.Gateway{ObjectMeta: proxyObjectMeta} exampleSvc = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ From da32183fb3b082f9a6bf796019f63dd1118e2ee9 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 15:14:42 -0500 Subject: [PATCH 10/14] fix helm ns Signed-off-by: Jenny Shu --- install/helm/kgateway/templates/gatewayclass.yaml | 2 +- install/helm/kgateway/values.yaml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/install/helm/kgateway/templates/gatewayclass.yaml b/install/helm/kgateway/templates/gatewayclass.yaml index 4e3a8ba2fb1..a329edc125b 100644 --- a/install/helm/kgateway/templates/gatewayclass.yaml +++ b/install/helm/kgateway/templates/gatewayclass.yaml @@ -13,8 +13,8 @@ spec: group: {{ .group }} kind: {{ .kind }} name: {{ .name }} - namespace: {{ .namespace }} {{- end }} + namespace: {{ .Release.Namespace }} {{- end }} description: {{ .Values.gatewayClass.description | quote }} {{- end }} diff --git a/install/helm/kgateway/values.yaml b/install/helm/kgateway/values.yaml index 34a39b3d344..e3d29e45d93 100644 --- a/install/helm/kgateway/values.yaml +++ b/install/helm/kgateway/values.yaml @@ -78,7 +78,6 @@ gatewayClass: kind: "GatewayParameters" # The name of the GatewayParameters which is attached by parametersRef to the GatewayClass name: "kgateway" - namespace: "kgateway-system" # Gateway proxy configuration gateway: From 93988d1d8808981160e2a23fe0be6e141385e1ec Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 15:25:31 -0500 Subject: [PATCH 11/14] fix refs Signed-off-by: Jenny Shu --- test/kubernetes/e2e/features/basicrouting/suite.go | 8 ++------ .../basicrouting/testdata/gateway-with-route.yaml | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/test/kubernetes/e2e/features/basicrouting/suite.go b/test/kubernetes/e2e/features/basicrouting/suite.go index 163df4464b6..a5de5ae6a29 100644 --- a/test/kubernetes/e2e/features/basicrouting/suite.go +++ b/test/kubernetes/e2e/features/basicrouting/suite.go @@ -6,7 +6,6 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/suite" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils" @@ -88,12 +87,9 @@ func (s *testingSuite) TestGatewayWithRoute() { s.ctx, testdefaults.CurlPodExecOpt, []curl.Option{ - curl.WithHost(kubeutils.ServiceFQDN(metav1.ObjectMeta{ - Name: proxyObjectMeta.Name, - Namespace: proxyObjectMeta.Namespace, - })), + curl.WithHost(kubeutils.ServiceFQDN(proxyObjectMeta)), curl.WithHostHeader("example.com"), - curl.WithPort(80), + curl.WithPort(8080), }, &testmatchers.HttpResponse{ StatusCode: http.StatusOK, diff --git a/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml index 616f8861527..e801b2dde8b 100644 --- a/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml +++ b/test/kubernetes/e2e/features/basicrouting/testdata/gateway-with-route.yaml @@ -23,5 +23,5 @@ spec: - "example.com" rules: - backendRefs: - - name: nginx + - name: example-svc port: 8080 \ No newline at end of file From 3655bc78794047262426a72a10788b86ed939033 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 15:28:41 -0500 Subject: [PATCH 12/14] remove install-test-tools Signed-off-by: Jenny Shu --- .github/actions/kubernetes-e2e-tests/action.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/actions/kubernetes-e2e-tests/action.yaml b/.github/actions/kubernetes-e2e-tests/action.yaml index d7a529df3f1..e866ffdd852 100644 --- a/.github/actions/kubernetes-e2e-tests/action.yaml +++ b/.github/actions/kubernetes-e2e-tests/action.yaml @@ -25,9 +25,6 @@ inputs: runs: using: "composite" steps: - - name: Install test tools - shell: bash - run: make install-test-tools - name: Execute tests env: GO_TEST_USER_ARGS: ${{ inputs.test-args }} -run "${{ inputs.run-regex }}" From 6771cc56bfc5ec6d6e3f38d31a3db177f94f84fe Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 16:02:12 -0500 Subject: [PATCH 13/14] install uninstall checks Signed-off-by: Jenny Shu --- test/kubernetes/e2e/test.go | 4 +- .../testutils/assertions/install.go | 23 ------------ .../testutils/assertions/kgateway.go | 37 +++++++++++++++++++ test/kubernetes/testutils/assertions/pods.go | 20 ++++++++++ 4 files changed, 59 insertions(+), 25 deletions(-) delete mode 100644 test/kubernetes/testutils/assertions/install.go create mode 100644 test/kubernetes/testutils/assertions/kgateway.go diff --git a/test/kubernetes/e2e/test.go b/test/kubernetes/e2e/test.go index 33924bbffac..331e4faabd4 100644 --- a/test/kubernetes/e2e/test.go +++ b/test/kubernetes/e2e/test.go @@ -161,7 +161,7 @@ func (i *TestInstallation) InstallKgatewayFromLocalChart(ctx context.Context) { ChartUri: chartUri, }) i.Assertions.Require.NoError(err) - i.Assertions.EventuallyInstallationSucceeded(ctx) + i.Assertions.EventuallyKgatewayInstallSucceeded(ctx, i.Metadata.InstallNamespace) } // TODO implement this when we add upgrade tests @@ -183,7 +183,7 @@ func (i *TestInstallation) UninstallKgateway(ctx context.Context) { }, ) i.Assertions.Require.NoError(err) - i.Assertions.EventuallyUninstallationSucceeded(ctx) + i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx, i.Metadata.InstallNamespace) } // PreFailHandler is the function that is invoked if a test in the given TestInstallation fails diff --git a/test/kubernetes/testutils/assertions/install.go b/test/kubernetes/testutils/assertions/install.go deleted file mode 100644 index b0fbbda856e..00000000000 --- a/test/kubernetes/testutils/assertions/install.go +++ /dev/null @@ -1,23 +0,0 @@ -package assertions - -import ( - "context" -) - -func (p *Provider) EventuallyInstallationSucceeded(ctx context.Context) { - p.expectInstallContextDefined() - - // TODO check other things here, e.g. expected pods are up -} - -func (p *Provider) EventuallyUninstallationSucceeded(ctx context.Context) { - p.expectInstallContextDefined() - - p.ExpectNamespaceNotExist(ctx, p.installContext.InstallNamespace) -} - -func (p *Provider) EventuallyUpgradeSucceeded(ctx context.Context, version string) { - p.expectInstallContextDefined() - - // TODO check other things here, e.g. expected pods are up -} diff --git a/test/kubernetes/testutils/assertions/kgateway.go b/test/kubernetes/testutils/assertions/kgateway.go new file mode 100644 index 00000000000..a920ba7a8c3 --- /dev/null +++ b/test/kubernetes/testutils/assertions/kgateway.go @@ -0,0 +1,37 @@ +package assertions + +import ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func (p *Provider) EventuallyKgatewayInstallSucceeded( + ctx context.Context, + installNamespace string, +) { + p.expectInstallContextDefined() + + p.EventuallyPodsRunning(ctx, installNamespace, + metav1.ListOptions{ + LabelSelector: "app.kubernetes.io/name=kgateway", + }) +} + +func (p *Provider) EventuallyKgatewayUninstallSucceeded( + ctx context.Context, + installNamespace string, +) { + p.expectInstallContextDefined() + + p.EventuallyPodsNotExist(ctx, installNamespace, + metav1.ListOptions{ + LabelSelector: "app.kubernetes.io/name=kgateway", + }) +} + +func (p *Provider) EventuallyKgatewayUpgradeSucceeded(ctx context.Context, version string) { + p.expectInstallContextDefined() + + // TODO check other things here, e.g. expected pods are up +} diff --git a/test/kubernetes/testutils/assertions/pods.go b/test/kubernetes/testutils/assertions/pods.go index 55a517d2684..0cb27dd4d5e 100644 --- a/test/kubernetes/testutils/assertions/pods.go +++ b/test/kubernetes/testutils/assertions/pods.go @@ -46,3 +46,23 @@ func (p *Provider) EventuallyPodsMatches( WithPolling(pollingInterval). Should(gomega.Succeed(), fmt.Sprintf("Failed to match pod in namespace %s", podNamespace)) } + +// EventuallyPodsNotExist asserts that eventually no pods matching the given selector exist on the cluster. +func (p *Provider) EventuallyPodsNotExist( + ctx context.Context, + podNamespace string, + listOpt metav1.ListOptions, + timeout ...time.Duration, +) { + currentTimeout, pollingInterval := helpers.GetTimeouts(timeout...) + + p.Gomega.Eventually(func(g gomega.Gomega) { + pods, err := p.clusterContext.Clientset.CoreV1().Pods(podNamespace).List(ctx, listOpt) + g.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to list pods") + g.Expect(pods.Items).To(gomega.BeEmpty(), "No pods should be found") + }). + WithTimeout(currentTimeout). + WithPolling(pollingInterval). + Should(gomega.Succeed(), fmt.Sprintf("pods matching %v in namespace %s should not be found in cluster", + listOpt, podNamespace)) +} From de2d737bf0b2eef972f644925da973075c2ef4c5 Mon Sep 17 00:00:00 2001 From: Jenny Shu Date: Tue, 18 Feb 2025 16:11:44 -0500 Subject: [PATCH 14/14] don't need ns Signed-off-by: Jenny Shu --- test/kubernetes/e2e/test.go | 4 ++-- test/kubernetes/testutils/assertions/kgateway.go | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/test/kubernetes/e2e/test.go b/test/kubernetes/e2e/test.go index 331e4faabd4..548ada7bad7 100644 --- a/test/kubernetes/e2e/test.go +++ b/test/kubernetes/e2e/test.go @@ -161,7 +161,7 @@ func (i *TestInstallation) InstallKgatewayFromLocalChart(ctx context.Context) { ChartUri: chartUri, }) i.Assertions.Require.NoError(err) - i.Assertions.EventuallyKgatewayInstallSucceeded(ctx, i.Metadata.InstallNamespace) + i.Assertions.EventuallyKgatewayInstallSucceeded(ctx) } // TODO implement this when we add upgrade tests @@ -183,7 +183,7 @@ func (i *TestInstallation) UninstallKgateway(ctx context.Context) { }, ) i.Assertions.Require.NoError(err) - i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx, i.Metadata.InstallNamespace) + i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx) } // PreFailHandler is the function that is invoked if a test in the given TestInstallation fails diff --git a/test/kubernetes/testutils/assertions/kgateway.go b/test/kubernetes/testutils/assertions/kgateway.go index a920ba7a8c3..3f10d0dcbab 100644 --- a/test/kubernetes/testutils/assertions/kgateway.go +++ b/test/kubernetes/testutils/assertions/kgateway.go @@ -6,25 +6,19 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (p *Provider) EventuallyKgatewayInstallSucceeded( - ctx context.Context, - installNamespace string, -) { +func (p *Provider) EventuallyKgatewayInstallSucceeded(ctx context.Context) { p.expectInstallContextDefined() - p.EventuallyPodsRunning(ctx, installNamespace, + p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace, metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=kgateway", }) } -func (p *Provider) EventuallyKgatewayUninstallSucceeded( - ctx context.Context, - installNamespace string, -) { +func (p *Provider) EventuallyKgatewayUninstallSucceeded(ctx context.Context) { p.expectInstallContextDefined() - p.EventuallyPodsNotExist(ctx, installNamespace, + p.EventuallyPodsNotExist(ctx, p.installContext.InstallNamespace, metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=kgateway", })