Skip to content

Commit ab2c3c0

Browse files
authored
chore: migrate from kuttl to chainsaw (#2630)
1 parent f0d7ba3 commit ab2c3c0

File tree

122 files changed

+2349
-1197
lines changed

Some content is hidden

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

122 files changed

+2349
-1197
lines changed

.chainsaw.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Configuration
4+
metadata:
5+
name: configuration
6+
spec:
7+
parallel: 4
8+
timeouts:
9+
assert: 5m0s
10+
cleanup: 5m0s
11+
delete: 5m0s
12+
error: 5m0s

.github/workflows/e2e.yaml

+16-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ concurrency:
1212

1313
jobs:
1414
e2e-tests:
15-
name: End-to-end tests ${{ matrix.group }} on K8s ${{ matrix.kube-version }}
1615
runs-on: ubuntu-22.04
1716
strategy:
1817
fail-fast: false
@@ -25,13 +24,13 @@ jobs:
2524
- "1.29"
2625
group:
2726
- e2e
28-
- e2e-instrumentation
29-
- e2e-upgrade
3027
- e2e-autoscale
31-
- e2e-pdb
28+
- e2e-instrumentation
3229
- e2e-opampbridge
33-
- e2e-targetallocator
30+
- e2e-pdb
3431
- e2e-prometheuscr
32+
- e2e-targetallocator
33+
- e2e-upgrade
3534
- e2e-multi-instrumentation
3635
include:
3736
- group: e2e-prometheuscr
@@ -42,33 +41,38 @@ jobs:
4241
steps:
4342
- name: Check out code into the Go module directory
4443
uses: actions/checkout@v4
45-
4644
- name: Set up Go
4745
uses: actions/setup-go@v5
4846
with:
4947
go-version: "~1.21.3"
50-
5148
- name: Cache tools
5249
uses: actions/cache@v4
5350
with:
5451
path: bin
5552
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
56-
53+
- name: Install chainsaw
54+
uses: kyverno/[email protected]
5755
- name: Install tools
5856
run: make install-tools
59-
60-
- name: "run tests"
57+
- name: Prepare e2e tests
6158
env:
6259
KUBE_VERSION: ${{ matrix.kube-version }}
6360
run: |
61+
set -e
6462
make ${{ matrix.setup != '' && matrix.setup || 'prepare-e2e' }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
63+
- name: Run e2e tests
64+
env:
65+
KUBE_VERSION: ${{ matrix.kube-version }}
66+
run: |
67+
set -e
6568
make ${{ matrix.group }}
66-
6769
- name: "log operator if failed"
6870
if: ${{ failure() }}
6971
env:
7072
KUBE_VERSION: ${{ matrix.kube-version }}
71-
run: make e2e-log-operator KUBE_VERSION=$KUBE_VERSION
73+
run: |
74+
set -e
75+
make e2e-log-operator KUBE_VERSION=$KUBE_VERSION
7276
7377
e2e-tests-check:
7478
runs-on: ubuntu-22.04

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ KUBEBUILDER_ASSETS=$(./bin/setup-envtest use -p path 1.23) go test ./pkg...
118118

119119
### End to end tests
120120

121-
To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`kuttl`](https://kuttl.dev). Refer to their documentation for installation instructions.
121+
To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`chainsaw`](https://kyverno.github.io/chainsaw). Refer to their documentation for installation instructions.
122122

123123
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will setup a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.
124124

125-
The tests are located under `tests/e2e` and are written to be used with `kuttl`. Refer to their documentation to understand how tests are written.
125+
The tests are located under `tests/e2e` and are written to be used with `chainsaw`. Refer to their documentation to understand how tests are written.
126126

127127
To evert the changes made by the `make prepare-e2e` run `make reset`.
128128

@@ -133,7 +133,7 @@ To install the OpenTelemetry operator, please follow the instructions in [Opera
133133

134134
Once the operator is installed, the tests can be executed using `make e2e-openshift`, which will call to the `e2e-openshift` target. Note that `kind` is disabled for the TestSuite as the requirement is to use an OpenShift cluster for these test cases.
135135

136-
The tests are located under `tests/e2e-openshift` and are written to be used with `kuttl`.
136+
The tests are located under `tests/e2e-openshift` and are written to be used with `chainsaw`.
137137

138138
### Undeploying the operator from the local cluster
139139

Makefile

+53-44
Original file line numberDiff line numberDiff line change
@@ -197,39 +197,18 @@ generate: controller-gen
197197

198198
# end-to-tests
199199
.PHONY: e2e
200-
e2e:
201-
$(KUTTL) test
202-
203-
204-
# instrumentation end-to-tests
205-
.PHONY: e2e-instrumentation
206-
e2e-instrumentation:
207-
$(KUTTL) test --config kuttl-test-instrumentation.yaml
208-
209-
# end-to-end-test for PrometheusCR E2E tests
210-
.PHONY: e2e-prometheuscr
211-
e2e-prometheuscr:
212-
$(KUTTL) test --config kuttl-test-prometheuscr.yaml
213-
214-
# end-to-end-test for testing upgrading
215-
.PHONY: e2e-upgrade
216-
e2e-upgrade: undeploy
217-
$(KUTTL) test --config kuttl-test-upgrade.yaml
200+
e2e: chainsaw
201+
$(CHAINSAW) test --test-dir ./tests/e2e
218202

219203
# end-to-end-test for testing autoscale
220204
.PHONY: e2e-autoscale
221-
e2e-autoscale:
222-
$(KUTTL) test --config kuttl-test-autoscale.yaml
223-
224-
# end-to-end-test for testing pdb support
225-
.PHONY: e2e-pdb
226-
e2e-pdb:
227-
$(KUTTL) test --config kuttl-test-pdb.yaml
205+
e2e-autoscale: chainsaw
206+
$(CHAINSAW) test --test-dir ./tests/e2e-autoscale
228207

229-
# end-to-end-test for testing OpenShift cases
230-
.PHONY: e2e-openshift
231-
e2e-openshift:
232-
$(KUTTL) test --config kuttl-test-openshift.yaml
208+
# instrumentation end-to-tests
209+
.PHONY: e2e-instrumentation
210+
e2e-instrumentation: chainsaw
211+
$(CHAINSAW) test --test-dir ./tests/e2e-instrumentation
233212

234213
.PHONY: e2e-log-operator
235214
e2e-log-operator:
@@ -238,24 +217,41 @@ e2e-log-operator:
238217

239218
# end-to-tests for multi-instrumentation
240219
.PHONY: e2e-multi-instrumentation
241-
e2e-multi-instrumentation:
242-
$(KUTTL) test --config kuttl-test-multi-instr.yaml
220+
e2e-multi-instrumentation: chainsaw
221+
$(CHAINSAW) test --test-dir ./tests/e2e-multi-instrumentation
243222

244223
# OpAMPBridge CR end-to-tests
245224
.PHONY: e2e-opampbridge
246-
e2e-opampbridge:
247-
$(KUTTL) test --config kuttl-test-opampbridge.yaml
225+
e2e-opampbridge: chainsaw
226+
$(CHAINSAW) test --test-dir ./tests/e2e-opampbridge
227+
228+
# end-to-end-test for testing pdb support
229+
.PHONY: e2e-pdb
230+
e2e-pdb: chainsaw
231+
$(CHAINSAW) test --test-dir ./tests/e2e-pdb
232+
233+
# end-to-end-test for PrometheusCR E2E tests
234+
.PHONY: e2e-prometheuscr
235+
e2e-prometheuscr: chainsaw
236+
$(CHAINSAW) test --test-dir ./tests/e2e-prometheuscr
248237

249238
# Target allocator end-to-tests
250239
.PHONY: e2e-targetallocator
251-
e2e-targetallocator:
252-
$(KUTTL) test --config kuttl-test-targetallocator.yaml
240+
e2e-targetallocator: chainsaw
241+
$(CHAINSAW) test --test-dir ./tests/e2e-targetallocator
242+
243+
# end-to-end-test for testing upgrading
244+
.PHONY: e2e-upgrade
245+
e2e-upgrade: undeploy chainsaw
246+
kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml
247+
go run hack/check-operator-ready.go
248+
$(CHAINSAW) test --test-dir ./tests/e2e-upgrade
253249

254250
.PHONY: prepare-e2e
255-
prepare-e2e: kuttl set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
251+
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
256252

257253
.PHONY: prepare-e2e-with-featuregates
258-
prepare-e2e-with-featuregates: kuttl enable-operator-featuregates prepare-e2e
254+
prepare-e2e-with-featuregates: chainsaw enable-operator-featuregates prepare-e2e
259255

260256
.PHONY: scorecard-tests
261257
scorecard-tests: operator-sdk
@@ -361,7 +357,6 @@ cmctl:
361357

362358
KUSTOMIZE ?= $(LOCALBIN)/kustomize
363359
KIND ?= $(LOCALBIN)/kind
364-
KUTTL ?= $(LOCALBIN)/kubectl-kuttl
365360
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
366361
ENVTEST ?= $(LOCALBIN)/setup-envtest
367362
CHLOGGEN ?= $(LOCALBIN)/chloggen
@@ -371,10 +366,16 @@ KUSTOMIZE_VERSION ?= v5.0.3
371366
CONTROLLER_TOOLS_VERSION ?= v0.12.0
372367
GOLANGCI_LINT_VERSION ?= v1.54.0
373368
KIND_VERSION ?= v0.20.0
374-
KUTTL_VERSION ?= 0.15.0
369+
370+
# Checks if chainsaw is in your PATH
371+
ifneq ($(shell which chainsaw),)
372+
CHAINSAW ?= $(shell which chainsaw)
373+
else
374+
CHAINSAW ?= $(LOCALBIN)/chainsaw
375+
endif
375376

376377
.PHONY: install-tools
377-
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kuttl kind operator-sdk
378+
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw
378379

379380
.PHONY: kustomize
380381
kustomize: ## Download kustomize locally if necessary.
@@ -403,6 +404,18 @@ CRDOC = $(shell pwd)/bin/crdoc
403404
crdoc: ## Download crdoc locally if necessary.
404405
$(call go-get-tool,$(CRDOC), fybrik.io/crdoc,v0.5.2)
405406

407+
.PHONY: chainsaw
408+
chainsaw: ## Find or download chainsaw
409+
ifeq (, $(shell which chainsaw))
410+
@{ \
411+
set -e ;\
412+
go install github.com/kyverno/[email protected] ;\
413+
}
414+
CHAINSAW ?= $(GOBIN)/chainsaw
415+
else
416+
CHAINSAW ?= $(shell which chainsaw)
417+
endif
418+
406419
# go-get-tool will 'go get' any package $2 and install it to $1.
407420
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
408421
define go-get-tool
@@ -418,10 +431,6 @@ rm -rf $$TMP_DIR ;\
418431
}
419432
endef
420433

421-
.PHONY: kuttl
422-
kuttl: $(LOCALBIN)
423-
@KUTTL=$(KUTTL) KUTTL_VERSION=$(KUTTL_VERSION) ./hack/install-kuttl.sh
424-
425434
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
426435
.PHONY: operator-sdk
427436
operator-sdk: $(LOCALBIN)

hack/install-kuttl.sh

-12
This file was deleted.

kuttl-test-autoscale.yaml

-6
This file was deleted.

kuttl-test-instrumentation.yaml

-5
This file was deleted.

kuttl-test-multi-instr.yaml

-6
This file was deleted.

kuttl-test-opampbridge.yaml

-6
This file was deleted.

kuttl-test-openshift.yaml

-6
This file was deleted.

kuttl-test-pdb.yaml

-6
This file was deleted.

kuttl-test-prometheuscr.yaml

-16
This file was deleted.

kuttl-test-targetallocator.yaml

-6
This file was deleted.

kuttl-test-upgrade.yaml

-19
This file was deleted.

kuttl-test.yaml

-7
This file was deleted.

tests/e2e-autoscale/autoscale/03-delete.yaml

-8
This file was deleted.

0 commit comments

Comments
 (0)