Skip to content

Commit 61378d0

Browse files
committed
feat: port Kuttl E2E tests to Ginkgo
Signed-off-by: Jonathan West <jonwest@redhat.com>
1 parent 80f3752 commit 61378d0

File tree

98 files changed

+16252
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+16252
-48
lines changed

.github/workflows/ci-build.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,27 @@ jobs:
9999
set -o pipefail
100100
make install generate fmt vet
101101
# Use tee to flush output to the log. Other solutions like stdbuf don't work, not sure why.
102-
REDIS_CONFIG_PATH="build/redis" go run ./cmd/main.go 2>&1 | tee /tmp/e2e-operator-run.log &
103-
- name: Run tests
102+
make start-e2e 2>&1 | tee /tmp/e2e-operator-run.log &
103+
104+
- name: Run ginkgo tests
104105
run: |
105106
set -o pipefail
106-
bash hack/test.sh 2>&1 | tee /tmp/e2e-test.log
107+
LOCAL_RUN=true make e2e-tests-sequential-ginkgo e2e-tests-parallel-ginkgo 2>&1 | tee /tmp/e2e-test-ginkgo.log
108+
107109
- name: Upload operator logs
108110
uses: actions/upload-artifact@v4
109111
with:
110112
name: e2e-operator-run-${{ matrix.k3s-version }}.log
111113
path: /tmp/e2e-operator-run.log
112114
if: ${{ failure() }}
113-
- name: Upload test logs
115+
116+
- name: Upload ginkgo test logs
114117
uses: actions/upload-artifact@v4
115118
with:
116119
name: e2e-test-${{ matrix.k3s-version }}.log
117-
path: /tmp/e2e-test.log
120+
path: /tmp/e2e-test-ginkgo.log
118121
if: ${{ failure() }}
122+
119123
- name: Save application controller and server logs
120124
if: ${{ failure() }}
121125
run: |

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Integration tests
1+
name: Code scans
22
on:
33
pull_request:
44
paths-ignore:
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
lint_code:
13-
name: Run golangci-lint on PR
13+
name: Run golangci-lint and gosec
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout code

Makefile

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ fmt: ## Run go fmt against code.
101101
vet: ## Run go vet against code.
102102
go vet ./...
103103

104+
105+
# Exclude E2E tests from the list of unit test packages
106+
UNIT_TEST_PACKAGES := $(shell go list ./... | grep -E -v '/tests/ginkgo')
107+
104108
test: manifests generate fmt vet envtest ## Run tests.
105-
REDIS_CONFIG_PATH="$(shell pwd)/build/redis" go test ./... -coverprofile cover.out
109+
REDIS_CONFIG_PATH="$(shell pwd)/build/redis" go test $(UNIT_TEST_PACKAGES) -coverprofile cover.out
106110

107111
##@ Build
108112

@@ -167,6 +171,10 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
167171
e2e: ## Run operator e2e tests
168172
kubectl kuttl test ./tests/k8s --config ./tests/kuttl-tests.yaml
169173

174+
175+
start-e2e:
176+
ARGOCD_CLUSTER_CONFIG_NAMESPACES="argocd-e2e-cluster-config, argocd-test-impersonation-1-046, argocd-agent-principal-1-051" make run
177+
170178
all: test install run e2e ## UnitTest, Run the operator locally and execute e2e tests.
171179

172180
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
@@ -185,7 +193,7 @@ envtest: ## Download envtest-setup locally if necessary.
185193

186194
.PHONY: gosec
187195
gosec: go_sec
188-
$(GO_SEC) --exclude-dir "tests/auxiliary/smtplistener" ./...
196+
$(GO_SEC) --exclude-dir "tests/auxiliary/smtplistener" --exclude-dir "hack/" ./...
189197

190198
.PHONY: lint
191199
lint: golangci_lint
@@ -317,3 +325,35 @@ catalog-build: opm ## Build a catalog image.
317325
catalog-push: ## Push a catalog image.
318326
$(MAKE) docker-push IMG=$(CATALOG_IMG)
319327

328+
.PHONY: e2e-tests-sequential-ginkgo
329+
e2e-tests-sequential-ginkgo: ginkgo
330+
@echo "Running operator sequential Ginkgo E2E tests..."
331+
$(GINKGO_CLI) -v --trace --timeout 90m -r ./tests/ginkgo/sequential
332+
333+
.PHONY: e2e-tests-parallel-ginkgo
334+
e2e-tests-parallel-ginkgo: ginkgo
335+
@echo "Running operator parallel Ginkgo E2E tests..."
336+
$(GINKGO_CLI) -p -v -procs=1 --trace --timeout 90m -r ./tests/ginkgo/parallel # Only using '--procs=1' to avoid docker hub rate limiting on redis image
337+
338+
339+
GINKGO_CLI = $(shell pwd)/bin/ginkgo
340+
.PHONY: ginkgo
341+
ginkgo: ## Download ginkgo locally if necessary.
342+
$(call go-get-tool,$(GINKGO_CLI),github.com/onsi/ginkgo/v2/ginkgo@v2.22.2)
343+
344+
345+
# go-get-tool will 'go install' any package $2 and install it to $1.
346+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
347+
define go-get-tool
348+
@[ -f $(1) ] || { \
349+
set -e ;\
350+
TMP_DIR=$$(mktemp -d) ;\
351+
cd $$TMP_DIR ;\
352+
go mod init tmp ;\
353+
echo "Downloading $(2)" ;\
354+
currentver=$$(go version | { read _ _ v _; echo $$v; } | sed 's/go//g') ;\
355+
requiredver="1.19" ;\
356+
if [ $$(printf '%s\n' $$requiredver $$currentver | sort -V | head -n1) = $$requiredver ]; then export GOFLAGS=""; GOBIN=$(PROJECT_DIR)/bin go install $(2); else GOBIN=$(PROJECT_DIR)/bin go get $(2); fi;\
357+
rm -rf $$TMP_DIR ;\
358+
}
359+
endef

go.mod

Lines changed: 141 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ go 1.24.4
44

55
require (
66
github.com/argoproj/argo-cd/v3 v3.1.0-rc2
7+
github.com/argoproj/gitops-engine v0.7.1-0.20250617174952-093aef0dad58
78
github.com/cert-manager/cert-manager v1.14.4
89
github.com/go-logr/logr v1.4.3
910
github.com/google/go-cmp v0.7.0
11+
github.com/google/uuid v1.6.1-0.20241114170450-2d3c2a9cc518
1012
github.com/onsi/ginkgo v1.16.5
11-
github.com/onsi/gomega v1.36.1
13+
github.com/onsi/ginkgo/v2 v2.22.2
14+
github.com/onsi/gomega v1.36.2
1215
github.com/openshift/api v0.0.0-20240906151052-5d963dce87aa
1316
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
1417
github.com/prometheus/client_golang v1.22.0
@@ -17,48 +20,123 @@ require (
1720
go.uber.org/zap v1.27.0
1821
golang.org/x/mod v0.25.0
1922
gopkg.in/yaml.v2 v2.4.0
20-
k8s.io/api v0.33.2
21-
k8s.io/apimachinery v0.33.2
22-
k8s.io/client-go v0.33.2
23+
k8s.io/api v0.33.1
24+
k8s.io/apiextensions-apiserver v0.33.1
25+
k8s.io/apimachinery v0.33.1
26+
k8s.io/client-go v0.33.1
2327
k8s.io/kube-aggregator v0.33.1
2428
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
2529
sigs.k8s.io/controller-runtime v0.21.0
30+
sigs.k8s.io/yaml v1.4.0
2631
)
2732

2833
require (
34+
cloud.google.com/go/compute/metadata v0.6.0 // indirect
35+
dario.cat/mergo v1.0.2 // indirect
36+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
37+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 // indirect
38+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect
39+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
40+
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
41+
github.com/MakeNowJust/heredoc v1.0.0 // indirect
42+
github.com/Masterminds/semver/v3 v3.3.1 // indirect
43+
github.com/Microsoft/go-winio v0.6.2 // indirect
44+
github.com/ProtonMail/go-crypto v1.1.6 // indirect
45+
github.com/argoproj/pkg v0.13.6 // indirect
46+
github.com/argoproj/pkg/v2 v2.0.1 // indirect
2947
github.com/beorn7/perks v1.0.1 // indirect
3048
github.com/blang/semver/v4 v4.0.0 // indirect
49+
github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect
50+
github.com/bombsimon/logrusr/v4 v4.1.0 // indirect
51+
github.com/bradleyfalzon/ghinstallation/v2 v2.16.0 // indirect
52+
github.com/casbin/casbin/v2 v2.107.0 // indirect
53+
github.com/casbin/govaluate v1.7.0 // indirect
3154
github.com/cespare/xxhash/v2 v2.3.0 // indirect
55+
github.com/chai2010/gettext-go v1.0.3 // indirect
56+
github.com/cloudflare/circl v1.6.1 // indirect
57+
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
3258
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
59+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
60+
github.com/distribution/reference v0.6.0 // indirect
3361
github.com/dlclark/regexp2 v1.11.5 // indirect
3462
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
63+
github.com/emirpasic/gods v1.18.1 // indirect
3564
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
65+
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
66+
github.com/fatih/camelcase v1.0.0 // indirect
3667
github.com/fsnotify/fsnotify v1.9.0 // indirect
3768
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
69+
github.com/go-errors/errors v1.5.1 // indirect
70+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
71+
github.com/go-git/go-billy/v5 v5.6.2 // indirect
72+
github.com/go-git/go-git/v5 v5.16.2 // indirect
3873
github.com/go-logr/zapr v1.3.0 // indirect
3974
github.com/go-openapi/jsonpointer v0.21.1 // indirect
4075
github.com/go-openapi/jsonreference v0.21.0 // indirect
4176
github.com/go-openapi/swag v0.23.1 // indirect
77+
github.com/go-redis/cache/v9 v9.0.0 // indirect
78+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
4279
github.com/gobwas/glob v0.2.3 // indirect
4380
github.com/gogo/protobuf v1.3.2 // indirect
81+
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
82+
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
83+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
4484
github.com/google/btree v1.1.3 // indirect
4585
github.com/google/gnostic-models v0.6.9 // indirect
46-
github.com/google/uuid v1.6.1-0.20241114170450-2d3c2a9cc518 // indirect
86+
github.com/google/go-github/v69 v69.2.0 // indirect
87+
github.com/google/go-github/v72 v72.0.0 // indirect
88+
github.com/google/go-querystring v1.1.0 // indirect
89+
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
90+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
91+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
92+
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
93+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
94+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
95+
github.com/jonboulle/clockwork v0.5.0 // indirect
4796
github.com/josharian/intern v1.0.0 // indirect
4897
github.com/json-iterator/go v1.1.12 // indirect
98+
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
99+
github.com/kevinburke/ssh_config v1.2.0 // indirect
100+
github.com/klauspost/compress v1.18.0 // indirect
101+
github.com/kylelemons/godebug v1.1.0 // indirect
102+
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
49103
github.com/mailru/easyjson v0.9.0 // indirect
104+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
105+
github.com/moby/spdystream v0.5.0 // indirect
106+
github.com/moby/term v0.5.2 // indirect
50107
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
51108
github.com/modern-go/reflect2 v1.0.2 // indirect
109+
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
52110
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
111+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
53112
github.com/nxadm/tail v1.4.8 // indirect
113+
github.com/opencontainers/go-digest v1.0.0 // indirect
114+
github.com/opencontainers/image-spec v1.1.1 // indirect
115+
github.com/patrickmn/go-cache v2.1.1-0.20191004192108-46f407853014+incompatible // indirect
116+
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
117+
github.com/pjbgf/sha1cd v0.3.2 // indirect
118+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
54119
github.com/pkg/errors v0.9.1 // indirect
55120
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
56121
github.com/prometheus/client_model v0.6.2 // indirect
57122
github.com/prometheus/common v0.64.0 // indirect
58123
github.com/prometheus/procfs v0.16.1 // indirect
124+
github.com/redis/go-redis/v9 v9.8.0 // indirect
125+
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e // indirect
126+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
127+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
59128
github.com/sirupsen/logrus v1.9.3 // indirect
129+
github.com/skeema/knownhosts v1.3.1 // indirect
130+
github.com/spf13/cobra v1.9.1 // indirect
60131
github.com/spf13/pflag v1.0.6 // indirect
132+
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
133+
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
134+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
61135
github.com/x448/float16 v0.8.4 // indirect
136+
github.com/xanzy/ssh-agent v0.3.3 // indirect
137+
github.com/xlab/treeprint v1.2.0 // indirect
138+
go.opentelemetry.io/otel v1.36.0 // indirect
139+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
62140
go.uber.org/multierr v1.11.0 // indirect
63141
golang.org/x/crypto v0.39.0 // indirect
64142
golang.org/x/net v0.41.0 // indirect
@@ -68,18 +146,74 @@ require (
68146
golang.org/x/term v0.32.0 // indirect
69147
golang.org/x/text v0.26.0 // indirect
70148
golang.org/x/time v0.12.0 // indirect
149+
golang.org/x/tools v0.33.0 // indirect
71150
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
151+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
152+
google.golang.org/grpc v1.73.0 // indirect
72153
google.golang.org/protobuf v1.36.6 // indirect
73154
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
74155
gopkg.in/inf.v0 v0.9.1 // indirect
75156
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
157+
gopkg.in/warnings.v0 v0.1.2 // indirect
76158
gopkg.in/yaml.v3 v3.0.1 // indirect
77-
k8s.io/apiextensions-apiserver v0.33.1 // indirect
159+
k8s.io/apiserver v0.33.1 // indirect
160+
k8s.io/cli-runtime v0.33.1 // indirect
161+
k8s.io/component-base v0.33.1 // indirect
162+
k8s.io/component-helpers v0.33.1 // indirect
163+
k8s.io/controller-manager v0.33.1 // indirect
78164
k8s.io/klog/v2 v2.130.1 // indirect
79165
k8s.io/kube-openapi v0.0.0-20250610211856-8b98d1ed966a // indirect
166+
k8s.io/kubectl v0.33.1 // indirect
167+
k8s.io/kubernetes v1.33.1 // indirect
168+
oras.land/oras-go/v2 v2.6.0 // indirect
80169
sigs.k8s.io/gateway-api v1.0.0 // indirect
81170
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
171+
sigs.k8s.io/kustomize/api v0.19.0 // indirect
172+
sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect
82173
sigs.k8s.io/randfill v1.0.0 // indirect
83174
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
84-
sigs.k8s.io/yaml v1.4.0 // indirect
175+
)
176+
177+
replace (
178+
github.com/golang/protobuf => github.com/golang/protobuf v1.5.4
179+
github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.16.0
180+
181+
// Avoid CVE-2022-3064
182+
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0
183+
184+
// Avoid CVE-2022-28948
185+
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
186+
187+
k8s.io/api => k8s.io/api v0.33.1
188+
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.33.1
189+
k8s.io/apimachinery => k8s.io/apimachinery v0.33.1
190+
k8s.io/apiserver => k8s.io/apiserver v0.33.1
191+
k8s.io/cli-runtime => k8s.io/cli-runtime v0.33.1
192+
k8s.io/client-go => k8s.io/client-go v0.33.1
193+
k8s.io/cloud-provider => k8s.io/cloud-provider v0.33.1
194+
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.33.1
195+
k8s.io/code-generator => k8s.io/code-generator v0.33.1
196+
k8s.io/component-base => k8s.io/component-base v0.33.1
197+
k8s.io/component-helpers => k8s.io/component-helpers v0.33.1
198+
k8s.io/controller-manager => k8s.io/controller-manager v0.33.1
199+
k8s.io/cri-api => k8s.io/cri-api v0.33.1
200+
k8s.io/cri-client => k8s.io/cri-client v0.33.1
201+
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.33.1
202+
k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.33.1
203+
k8s.io/endpointslice => k8s.io/endpointslice v0.33.1
204+
k8s.io/externaljwt => k8s.io/externaljwt v0.33.1
205+
k8s.io/kms => k8s.io/kms v0.33.1
206+
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.33.1
207+
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.33.1
208+
k8s.io/kube-proxy => k8s.io/kube-proxy v0.33.1
209+
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.33.1
210+
k8s.io/kubectl => k8s.io/kubectl v0.33.1
211+
k8s.io/kubelet => k8s.io/kubelet v0.33.1
212+
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.33.1
213+
k8s.io/metrics => k8s.io/metrics v0.33.1
214+
k8s.io/mount-utils => k8s.io/mount-utils v0.33.1
215+
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.33.1
216+
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.33.1
217+
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.33.1
218+
k8s.io/sample-controller => k8s.io/sample-controller v0.33.1
85219
)

0 commit comments

Comments
 (0)