Skip to content

Commit

Permalink
chore: migrate from kuttl to chainsaw
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Feb 8, 2024
1 parent 94c8420 commit ca9b077
Show file tree
Hide file tree
Showing 15 changed files with 362 additions and 129 deletions.
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
68 changes: 65 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
group:
- e2e
- e2e-instrumentation
- e2e-upgrade
# - e2e-upgrade
- e2e-autoscale
- e2e-pdb
# - e2e-pdb
- e2e-opampbridge
- e2e-prometheuscr
# - e2e-prometheuscr
- e2e-multi-instrumentation
include:
- group: e2e-prometheuscr
Expand Down Expand Up @@ -85,3 +85,65 @@ jobs:
echo "One or more matrix jobs failed."
false
fi
chainsaw-tests:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# The e2e tests are run on the lowest and highest supported k8s version.
# All Kubernetes version in between expose the same APIs, hence the operator
# should be compatible with them.
kube-version:
- "1.23"
- "1.29"
group:
# - e2e
# - e2e-instrumentation
# - e2e-autoscale
- e2e-pdb
- e2e-prometheuscr
- e2e-upgrade
# - e2e-opampbridge
# - e2e-multi-instrumentation
include:
- group: e2e-prometheuscr
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.observability.prometheus"
- group: e2e-multi-instrumentation
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.autoinstrumentation.multi-instrumentation"

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: Install chainsaw
uses: kyverno/action-install-chainsaw@07b6c986572f2abaf6647c85d37cbecfddc4a6ab # v0.1.3
- name: Prepare e2e tests
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 chainsaw-${{ matrix.group }}
- name: "log operator if failed"
if: ${{ failure() }}
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: |
set -e
make e2e-log-operator KUBE_VERSION=$KUBE_VERSION
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ lint: golangci-lint
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

#########
# KUTTL #
#########

# end-to-tests
.PHONY: e2e
e2e:
$(KUTTL) test


# instrumentation end-to-tests
.PHONY: e2e-instrumentation
e2e-instrumentation:
Expand Down Expand Up @@ -246,6 +249,25 @@ e2e-multi-instrumentation:
e2e-opampbridge:
$(KUTTL) test --config kuttl-test-opampbridge.yaml

############
# CHAINSAW #
############

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

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

# end-to-end-test for testing upgrading
.PHONY: chainsaw-e2e-upgrade
chainsaw-e2e-upgrade: undeploy
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

Expand Down
14 changes: 14 additions & 0 deletions tests/e2e-pdb/pdb/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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: pdb
spec:
steps:
- name: step-00
try:
- apply:
file: 00-install.yaml
- assert:
file: 00-assert.yaml
14 changes: 14 additions & 0 deletions tests/e2e-pdb/target-allocator/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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: target-allocator
spec:
steps:
- name: step-00
try:
- apply:
file: 00-install.yaml
- assert:
file: 00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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: create-pm-prometheus-exporters
spec:
steps:
- name: step-00
try:
- apply:
file: 00-install.yaml
- name: step-01
try:
- apply:
file: 01-install-app.yaml
- assert:
file: 01-assert.yaml

This file was deleted.

113 changes: 0 additions & 113 deletions tests/e2e-prometheuscr/create-sm-prometheus-exporters/08-install.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: ta
namespace: create-sm-prometheus
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ta
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- services
- endpoints
- configmaps
- secrets
- namespaces
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
- statefulsets
- services
- endpoints
verbs:
- get
- watch
- list
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- get
- watch
- list
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- watch
- list
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
- podmonitors
verbs:
- get
- watch
- list
- nonResourceURLs:
- /metrics
verbs:
- get
Loading

0 comments on commit ca9b077

Please sign in to comment.