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

chore: migrate from kuttl to chainsaw #2607

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 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: 12 additions & 0 deletions .chainsaw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
name: configuration
spec:
parallel: 4
timeouts:
assert: 5m0s
cleanup: 5m0s
delete: 5m0s
error: 5m0s
28 changes: 16 additions & 12 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ concurrency:

jobs:
e2e-tests:
name: End-to-end tests ${{ matrix.group }} on K8s ${{ matrix.kube-version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand All @@ -25,13 +24,13 @@ jobs:
- "1.29"
group:
- e2e
- e2e-instrumentation
- e2e-upgrade
- e2e-autoscale
- e2e-pdb
- e2e-instrumentation
- e2e-opampbridge
- e2e-targetallocator
- e2e-pdb
- e2e-prometheuscr
- e2e-targetallocator
- e2e-upgrade
- e2e-multi-instrumentation
include:
- group: e2e-prometheuscr
Expand All @@ -42,33 +41,38 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "~1.21.3"

- name: Cache tools
uses: actions/cache@v4
with:
path: bin
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}

- name: Install tools
run: make install-tools

- name: "run tests"
- name: Install chainsaw
uses: kyverno/action-install-chainsaw@07b6c986572f2abaf6647c85d37cbecfddc4a6ab # v0.1.3
- name: Prepare e2e tests
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: |
set -e
make ${{ matrix.setup != '' && matrix.setup || 'prepare-e2e' }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
- name: Run e2e tests
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: |
set -e
make ${{ matrix.group }}

- name: "log operator if failed"
if: ${{ failure() }}
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: make e2e-log-operator KUBE_VERSION=$KUBE_VERSION
run: |
set -e
make e2e-log-operator KUBE_VERSION=$KUBE_VERSION

e2e-tests-check:
runs-on: ubuntu-22.04
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ KUBEBUILDER_ASSETS=$(./bin/setup-envtest use -p path 1.23) go test ./pkg...

### End to end tests

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.
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.

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.

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.
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.

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

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

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.

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

### Undeploying the operator from the local cluster

Expand Down
68 changes: 29 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,38 +198,17 @@ generate: controller-gen
# end-to-tests
.PHONY: e2e
e2e:
$(KUTTL) test


# instrumentation end-to-tests
.PHONY: e2e-instrumentation
e2e-instrumentation:
$(KUTTL) test --config kuttl-test-instrumentation.yaml

# end-to-end-test for PrometheusCR E2E tests
.PHONY: e2e-prometheuscr
e2e-prometheuscr:
$(KUTTL) test --config kuttl-test-prometheuscr.yaml

# end-to-end-test for testing upgrading
.PHONY: e2e-upgrade
e2e-upgrade: undeploy
$(KUTTL) test --config kuttl-test-upgrade.yaml
chainsaw test --test-dir ./tests/e2e

# end-to-end-test for testing autoscale
.PHONY: e2e-autoscale
e2e-autoscale:
$(KUTTL) test --config kuttl-test-autoscale.yaml

# end-to-end-test for testing pdb support
.PHONY: e2e-pdb
e2e-pdb:
$(KUTTL) test --config kuttl-test-pdb.yaml
chainsaw test --test-dir ./tests/e2e-autoscale

# end-to-end-test for testing OpenShift cases
.PHONY: e2e-openshift
e2e-openshift:
$(KUTTL) test --config kuttl-test-openshift.yaml
# instrumentation end-to-tests
.PHONY: e2e-instrumentation
e2e-instrumentation:
chainsaw test --test-dir ./tests/e2e-instrumentation

.PHONY: e2e-log-operator
e2e-log-operator:
Expand All @@ -239,23 +218,40 @@ e2e-log-operator:
# end-to-tests for multi-instrumentation
.PHONY: e2e-multi-instrumentation
e2e-multi-instrumentation:
$(KUTTL) test --config kuttl-test-multi-instr.yaml
chainsaw test --test-dir ./tests/e2e-multi-instrumentation

# OpAMPBridge CR end-to-tests
.PHONY: e2e-opampbridge
e2e-opampbridge:
$(KUTTL) test --config kuttl-test-opampbridge.yaml
chainsaw test --test-dir ./tests/e2e-opampbridge

# end-to-end-test for testing pdb support
.PHONY: e2e-pdb
e2e-pdb:
chainsaw test --test-dir ./tests/e2e-pdb

# end-to-end-test for PrometheusCR E2E tests
.PHONY: e2e-prometheuscr
e2e-prometheuscr:
chainsaw test --test-dir ./tests/e2e-prometheuscr

# Target allocator end-to-tests
.PHONY: e2e-targetallocator
e2e-targetallocator:
$(KUTTL) test --config kuttl-test-targetallocator.yaml
chainsaw test --test-dir ./tests/e2e-targetallocator

# end-to-end-test for testing upgrading
.PHONY: e2e-upgrade
e2e-upgrade: undeploy
kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml
go run hack/check-operator-ready.go
chainsaw test --test-dir ./tests/e2e-upgrade

.PHONY: prepare-e2e
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
prepare-e2e: 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

.PHONY: prepare-e2e-with-featuregates
prepare-e2e-with-featuregates: kuttl enable-operator-featuregates prepare-e2e
prepare-e2e-with-featuregates: enable-operator-featuregates prepare-e2e

.PHONY: scorecard-tests
scorecard-tests: operator-sdk
Expand Down Expand Up @@ -361,7 +357,6 @@ cmctl:

KUSTOMIZE ?= $(LOCALBIN)/kustomize
KIND ?= $(LOCALBIN)/kind
KUTTL ?= $(LOCALBIN)/kubectl-kuttl
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CHLOGGEN ?= $(LOCALBIN)/chloggen
Expand All @@ -371,10 +366,9 @@ KUSTOMIZE_VERSION ?= v5.0.3
CONTROLLER_TOOLS_VERSION ?= v0.12.0
GOLANGCI_LINT_VERSION ?= v1.54.0
KIND_VERSION ?= v0.20.0
KUTTL_VERSION ?= 0.15.0

.PHONY: install-tools
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kuttl kind operator-sdk
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk

.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -418,10 +412,6 @@ rm -rf $$TMP_DIR ;\
}
endef

.PHONY: kuttl
kuttl: $(LOCALBIN)
@KUTTL=$(KUTTL) KUTTL_VERSION=$(KUTTL_VERSION) ./hack/install-kuttl.sh

OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
.PHONY: operator-sdk
operator-sdk: $(LOCALBIN)
Expand Down
12 changes: 0 additions & 12 deletions hack/install-kuttl.sh

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-autoscale.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions kuttl-test-instrumentation.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-multi-instr.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-opampbridge.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-openshift.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-pdb.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions kuttl-test-prometheuscr.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions kuttl-test-targetallocator.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions kuttl-test-upgrade.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions kuttl-test.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/e2e-autoscale/autoscale/03-delete.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions tests/e2e-autoscale/autoscale/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
creationTimestamp: null
name: autoscale
spec:
steps:
- name: step-00
try:
- apply:
file: 00-install.yaml
- assert:
file: 00-assert.yaml
- name: step-01
try:
- apply:
file: 01-install.yaml
- assert:
file: 01-assert.yaml
- name: step-02
try:
- apply:
file: 02-install.yaml
- assert:
file: 02-assert.yaml
- name: step-03
try:
- delete:
ref:
apiVersion: batch/v1
kind: Job
name: telemetrygen-set-utilization
- assert:
file: 03-assert.yaml
Loading
Loading