Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor E2E suite to make it more generic #637

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/e2e-long.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
test_name: Import via GitOps
run_azure_janitor: false
artifact_name: artifacts_import_gitops
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
e2e_import_gitops_v3:
uses: ./.github/workflows/run-e2e-suite.yaml
Expand All @@ -24,7 +24,7 @@ jobs:
test_name: Import via GitOps [v3]
run_azure_janitor: false
artifact_name: artifacts_import_gitops_v3
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
e2e_v2prov:
uses: ./.github/workflows/run-e2e-suite.yaml
Expand All @@ -33,7 +33,7 @@ jobs:
test_name: v2 provisioning
run_azure_janitor: true
artifact_name: artifacts_v2prov
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
e2e_update_labels:
uses: ./.github/workflows/run-e2e-suite.yaml
Expand All @@ -42,7 +42,7 @@ jobs:
test_name: Update labels
run_azure_janitor: true
artifact_name: artifacts_update_labels
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
e2e_embedded_capi_disabled:
uses: ./.github/workflows/run-e2e-suite.yaml
Expand All @@ -51,7 +51,7 @@ jobs:
test_name: Embedded CAPI disabled
run_azure_janitor: false
artifact_name: artifacts_embedded_capi
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
e2e_embedded_capi_disabled_v3:
uses: ./.github/workflows/run-e2e-suite.yaml
Expand All @@ -60,5 +60,5 @@ jobs:
test_name: Embedded CAPI disabled [v3]
run_azure_janitor: false
artifact_name: artifacts_embedded_capi_v3
use_eks: true
management_cluster_infrastructure: eks
secrets: inherit
6 changes: 5 additions & 1 deletion .github/workflows/e2e-short-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Run short e2e tests (with runner)
on:
workflow_dispatch:

env:
MANAGEMENT_CLUSTER_INFRASTRUCTURE: "isolated-kind"
alexander-demicev marked this conversation as resolved.
Show resolved Hide resolved
GINKGO_LABEL_FILTER: "short"

jobs:
e2e:
runs-on: org--rancher--amd64-containers
Expand All @@ -17,7 +21,7 @@ jobs:
with:
go-version: "=1.22.0"
- name: Run e2e tests
run: ISOLATED_MODE=true USE_EKS=false GINKGO_LABEL_FILTER=short make test-e2e
run: make test-e2e
- name: Collect run artifacts
if: always()
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/e2e-short.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
types: [opened, edited, synchronize, reopened, labeled, unlabeled]

env:
MANAGEMENT_CLUSTER_INFRASTRUCTURE: "isolated-kind"
GINKGO_LABEL_FILTER: "short"

jobs:
e2e:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -34,7 +38,7 @@ jobs:
with:
go-version: "=1.22.0"
- name: Run e2e tests
run: ISOLATED_MODE=true USE_EKS=false GINKGO_LABEL_FILTER=short make test-e2e
run: make test-e2e
- name: Collect run artifacts
if: always()
uses: actions/upload-artifact@v4
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/run-e2e-suite.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
on:
workflow_call:
inputs:
management_cluster_infrastructure:
description: "The infrastructure to use for the management cluster: eks, kind or isolated-kind"
type: string
required: true
default: "eks"
test_suite:
description: "The test suite to run (i.e. path to it)"
required: true
Expand All @@ -18,10 +23,6 @@ on:
required: false
default: false
type: boolean
use_eks:
description: "Use EKS for the management cluster"
required: true
type: boolean

permissions:
contents: read
Expand All @@ -42,6 +43,9 @@ env:
AWS_REGION: eu-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MANAGEMENT_CLUSTER_INFRASTRUCTURE: ${{ inputs.management_cluster_infrastructure }}
GINKGO_LABEL_FILTER: full
GINKGO_TESTS: ${{ inputs.test_suite }}

jobs:
run_e2e_tests:
Expand Down Expand Up @@ -80,10 +84,10 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and push e2e image
if: ${{ inputs.use_eks }}
if: ${{ inputs.management_cluster_infrastructure == 'eks' }}
run: make e2e-image-push
- name: Run e2e tests
run: GINKGO_LABEL_FILTER=full USE_EKS=${{ inputs.use_eks }} GINKGO_TESTS=${{ inputs.test_suite }} make test-e2e
run: make test-e2e
- name: Collect run artifacts
if: always()
uses: actions/upload-artifact@v4
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ E2E_CONF_FILE ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/config/operator.yaml
GINKGO_ARGS ?=
SKIP_RESOURCE_CLEANUP ?= false
USE_EXISTING_CLUSTER ?= false
USE_EKS ?= true
ISOLATED_MODE ?= false
GITEA_CUSTOM_INGRESS ?= false
GINKGO_NOCOLOR ?= false
GINKGO_LABEL_FILTER ?= short
GINKGO_TESTS ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/suites/...

MANAGEMENT_CLUSTER_INFRASTRUCTURE ?= eks
E2ECONFIG_VARS ?= MANAGEMENT_CLUSTER_INFRASTRUCTURE=$(MANAGEMENT_CLUSTER_INFRASTRUCTURE)

# to set multiple ginkgo skip flags, if any
ifneq ($(strip $(GINKGO_SKIP)),)
_SKIP_ARGS := $(foreach arg,$(strip $(GINKGO_SKIP)),-skip="$(arg)")
Expand Down Expand Up @@ -529,7 +530,7 @@ release-chart: $(HELM) $(NOTES) build-chart verify-gen

.PHONY: test-e2e
test-e2e: $(GINKGO) $(HELM) $(CLUSTERCTL) kubectl e2e-image ## Run the end-to-end tests
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
$(E2ECONFIG_VARS) $(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" --label-filter="$(GINKGO_LABEL_FILTER)" \
$(_SKIP_ARGS) --nodes=$(GINKGO_NODES) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) $(GINKGO_TESTS) -- \
Expand All @@ -540,8 +541,6 @@ test-e2e: $(GINKGO) $(HELM) $(CLUSTERCTL) kubectl e2e-image ## Run the end-to-en
-e2e.chart-path=$(ROOT_DIR)/$(CHART_RELEASE_DIR) \
-e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) \
-e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER) \
-e2e.isolated-mode=$(ISOLATED_MODE) \
-e2e.use-eks=$(USE_EKS) \
-e2e.gitea-custom-ingress=$(GITEA_CUSTOM_INGRESS)

.PHONY: e2e-image
Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ intervals:
default/wait-turtles-uninstall: ["10m", "30s"]

variables:
MANAGEMENT_CLUSTER_INFRASTRUCTURE: "isolated-kind" # supported options are eks, isolated-kind, kind
RANCHER_VERSION: "v2.8.1"
KUBERNETES_VERSION: "v1.28.6"
KUBERNETES_MANAGEMENT_VERSION: "v1.27.0"
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ const (
NginxIngressDeployment = "ingress-nginx-controller"
)

type ManagementClusterInfrastuctureType string

const (
ManagementClusterInfrastuctureEKS ManagementClusterInfrastuctureType = "eks"
ManagementClusterInfrastuctureIsolatedKind ManagementClusterInfrastuctureType = "isolated-kind"
ManagementClusterInfrastuctureKind ManagementClusterInfrastuctureType = "kind"
)

const (
ManagementClusterInfrastucture = "MANAGEMENT_CLUSTER_INFRASTRUCTURE"

KubernetesManagementVersionVar = "KUBERNETES_MANAGEMENT_VERSION"

KubernetesVersionVar = "KUBERNETES_VERSION"
Expand Down
9 changes: 0 additions & 9 deletions test/e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ type FlagValues struct {
// UseExistingCluster instructs the test to use the current cluster instead of creating a new one (default discovery rules apply).
UseExistingCluster bool

// UseEKS instructs the test to create an EKS cluster instead of using kind.
UseEKS bool

// ArtifactFolder is the folder to store e2e test artifacts.
ArtifactFolder string

Expand All @@ -48,10 +45,6 @@ type FlagValues struct {
// ChartPath is the path to the operator chart.
ChartPath string

// IsolatedMode instructs the test to run without ngrok and exposing the cluster to the internet. This setup will only work with CAPD
// or other providers that run in the same network as the bootstrap cluster.
IsolatedMode bool

// ClusterctlBinaryPath is the path to the clusterctl binary to use.
ClusterctlBinaryPath string

Expand All @@ -65,11 +58,9 @@ func InitFlags(values *FlagValues) {
flag.StringVar(&values.ArtifactFolder, "e2e.artifacts-folder", "_artifacts", "folder where e2e test artifact should be stored")
flag.BoolVar(&values.SkipCleanup, "e2e.skip-resource-cleanup", false, "if true, the resource cleanup after tests will be skipped")
flag.BoolVar(&values.UseExistingCluster, "e2e.use-existing-cluster", false, "if true, the test uses the current cluster instead of creating a new one (default discovery rules apply)")
flag.BoolVar(&values.UseEKS, "e2e.use-eks", true, "if true, the test uses EKS for the management cluster")
flag.StringVar(&values.HelmBinaryPath, "e2e.helm-binary-path", "helm", "path to the helm binary")
flag.StringVar(&values.HelmExtraValuesDir, "e2e.helm-extra-values-path", "/tmp", "path to the extra values file")
flag.StringVar(&values.ClusterctlBinaryPath, "e2e.clusterctl-binary-path", "helm", "path to the clusterctl binary")
flag.StringVar(&values.ChartPath, "e2e.chart-path", "", "path to the operator chart")
flag.BoolVar(&values.IsolatedMode, "e2e.isolated-mode", false, "if true, the test will run without ngrok and exposing the cluster to the internet. This setup will only work with CAPD or other providers that run in the same network as the bootstrap cluster.")
flag.BoolVar(&values.GiteaCustomIngress, "e2e.gitea-custom-ingress", false, "if true, the test will use a custom ingress for Gitea")
}
Loading