Skip to content

Commit dd23123

Browse files
authored
test: use kyverno/chainsaw for E2E testing (#642)
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
1 parent d549144 commit dd23123

39 files changed

+274
-133
lines changed

.chainsaw-local.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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-local
6+
spec:
7+
template: true
8+
timeouts:
9+
assert: 2m
10+
error: 2m

.chainsaw.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
skipDelete: true
8+
template: true
9+
timeouts:
10+
assert: 2m
11+
error: 2m

.github/workflows/e2e.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: E2E-Test
2+
on:
3+
workflow_call:
4+
inputs:
5+
kind_tag:
6+
description: "Tag of Kind image"
7+
type: "string"
8+
env:
9+
GO_VERSION: "~1.21"
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
e2e-test:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Download image
22+
uses: actions/download-artifact@v3
23+
with:
24+
name: open-feature-operator-local-${{ github.sha }}
25+
path: ${{ github.workspace }}
26+
27+
- name: Cache build tools
28+
id: cache-build-tools
29+
uses: actions/cache@v4
30+
with:
31+
path: ./bin
32+
key: build-tools-${{ github.ref_name }}
33+
34+
- name: Load open-feature-operator image into docker
35+
run: |
36+
docker load --input ${{ github.workspace }}/open-feature-operator-local.tar
37+
38+
- name: Create k8s Kind Cluster
39+
uses: helm/kind-action@v1.9.0
40+
with:
41+
config: ./test/e2e/kind-cluster.yml
42+
cluster_name: open-feature-operator-test
43+
node_image: kindest/node:${{ inputs.kind_tag }}
44+
45+
- name: Load open-feature-operator image into Kind cluster
46+
run: |
47+
kind load docker-image open-feature-operator-local:${{ github.sha }} --name open-feature-operator-test
48+
49+
- name: Install Chainsaw
50+
uses: kyverno/action-install-chainsaw@748066cc1580718e7924c9b689a8d366bde05100 # v0.2.0
51+
52+
- name: Install OFO
53+
run: |
54+
IMG=open-feature-operator-local:${{ github.sha }} make deploy-operator
55+
56+
- name: Run e2e test
57+
run: |
58+
make e2e-test-chainsaw
59+
60+
- name: Create reports
61+
if: failure()
62+
working-directory: ./.github/scripts
63+
run: ./create-reports.sh
64+
65+
- name: Upload cluster logs
66+
if: failure()
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: e2e-tests
70+
path: .github/scripts/logs

.github/workflows/pr-checks.yml

+8-59
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212
env:
1313
# Default minimum version of Go to support.
1414
DEFAULT_GO_VERSION: "~1.21"
15-
# renovate: datasource=github-tags depName=kudobuilder/kuttl
16-
KUTTL_VERSION: "v0.15.0"
1715

1816
permissions:
1917
contents: read
@@ -97,62 +95,13 @@ jobs:
9795
name: open-feature-operator-local-${{ github.sha }}
9896
path: ${{ github.workspace }}/open-feature-operator-local.tar
9997

100-
e2e-test:
101-
runs-on: ubuntu-22.04
102-
needs: docker-local
98+
e2e_tests:
99+
name: E2E Tests
100+
needs:
101+
- docker-local
103102
strategy:
104103
matrix:
105-
node_image: [ v1.22.17, v1.23.17, v1.24.15, v1.25.11, v1.26.3, v1.27.3, v1.28.0 ]
106-
steps:
107-
- name: Install Go
108-
uses: actions/setup-go@v4
109-
with:
110-
go-version: ${{ env.DEFAULT_GO_VERSION }}
111-
- name: Checkout
112-
uses: actions/checkout@v4
113-
114-
- name: Download image
115-
uses: actions/download-artifact@v3
116-
with:
117-
name: open-feature-operator-local-${{ github.sha }}
118-
path: ${{ github.workspace }}
119-
120-
- name: Cache build tools
121-
id: cache-build-tools
122-
uses: actions/cache@v4
123-
with:
124-
path: ./bin
125-
key: build-tools-${{ github.ref_name }}
126-
127-
- name: Load open-feature-operator image into docker
128-
run: |
129-
docker load --input ${{ github.workspace }}/open-feature-operator-local.tar
130-
- name: Create k8s Kind Cluster
131-
uses: helm/kind-action@v1.9.0
132-
with:
133-
config: ./test/e2e/kind-cluster.yml
134-
cluster_name: open-feature-operator-test
135-
node_image: kindest/node:${{ matrix.node_image }}
136-
- name: Download KUTTL
137-
run: |
138-
curl -fL https://github.com/kudobuilder/kuttl/releases/download/${{ env.KUTTL_VERSION }}/kubectl-kuttl_${KUTTL_VERSION#v}_linux_x86_64 -o kubectl-kuttl
139-
chmod +x kubectl-kuttl
140-
mv kubectl-kuttl /usr/local/bin
141-
- name: Load open-feature-operator image into Kind cluster
142-
run: |
143-
kind load docker-image open-feature-operator-local:${{ github.sha }} --name open-feature-operator-test
144-
- name: Run e2e test
145-
run: |
146-
IMG=open-feature-operator-local:${{ github.sha }} make deploy-operator
147-
IMG=open-feature-operator-local:${{ github.sha }} make e2e-test-kuttl
148-
- name: Create reports
149-
if: failure()
150-
working-directory: ./.github/scripts
151-
run: ./create-reports.sh
152-
153-
- name: Upload cluster logs
154-
if: failure()
155-
uses: actions/upload-artifact@v3
156-
with:
157-
name: e2e-tests
158-
path: .github/scripts/logs
104+
kind_tag: [ v1.22.17, v1.23.17, v1.24.15, v1.25.11, v1.26.3, v1.27.3, v1.28.0 ]
105+
with:
106+
kind_tag: ${{ matrix.kind_tag }}
107+
uses: ./.github/workflows/e2e.yml

Makefile

+11-8
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,25 @@ unit-test: manifests fmt vet generate envtest ## Run tests.
7474
cat cover-operator.out cover-apis.out >> cover.out
7575
rm cover-operator.out cover-apis.out
7676

77-
## e2e tests require the operator to be deployed in a real cluster
78-
.PHONY: e2e-test-kuttl
79-
e2e-test-kuttl:
80-
kubectl kuttl test --start-kind=false --config=./kuttl-test.yaml
77+
############
78+
# CHAINSAW #
79+
############
8180

82-
.PHONY: e2e-test-kuttl-local
83-
e2e-test-kuttl-local:
84-
kubectl kuttl test --start-kind=false --config=./kuttl-test-local.yaml
81+
.PHONY: e2e-test-chainsaw #these tests should run on a real cluster!
82+
e2e-test-chainsaw:
83+
chainsaw test --test-dir ./test/e2e/chainsaw
84+
85+
.PHONY: e2e-test-chainsaw-local #these tests should run on a real cluster!
86+
e2e-test-chainsaw-local:
87+
chainsaw test --test-dir ./test/e2e/chainsaw --config ./.chainsaw-local.yaml
8588

8689
.PHONY: e2e-test-validate-local
8790
e2e-test-validate-local:
8891
docker build . -t open-feature-operator-local:validate
8992
kind create cluster --config ./test/e2e/kind-cluster.yml --name e2e-tests
9093
kind load docker-image open-feature-operator-local:validate --name e2e-tests
9194
IMG=open-feature-operator-local:validate make deploy-operator
92-
IMG=open-feature-operator-local:validate make e2e-test-kuttl
95+
IMG=open-feature-operator-local:validate make e2e-test-chainsaw
9396
kind delete cluster --name e2e-tests
9497

9598
.PHONY: lint

kuttl-test-local.yaml

-6
This file was deleted.

kuttl-test.yaml

-7
This file was deleted.

test/e2e/kuttl/assets/manifests.yaml test/e2e/chainsaw/assets/manifests.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ spec:
8787
apiVersion: batch/v1
8888
kind: Job
8989
metadata:
90-
name: flagd-query-test
90+
name: (join('-', [$namespace, 'job1']))
91+
labels:
92+
kind: e2e-test-job
9193
spec:
9294
backoffLimit: 10
9395
template:

test/e2e/kuttl/flagd-disabled/00-install.yaml test/e2e/chainsaw/flagd-disabled/00-install.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ spec:
9090
apiVersion: batch/v1
9191
kind: Job
9292
metadata:
93-
name: flagd-query-test
93+
name: (join('-', [$namespace, 'job1']))
94+
labels:
95+
kind: flagd-disabled
9496
spec:
9597
backoffLimit: 5
9698
template:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: flagd-disabled
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: 00-install.yaml
13+
- wait:
14+
timeout: 5m
15+
resource: job
16+
selector: kind=flagd-disabled
17+
for:
18+
condition:
19+
name: complete
20+
- name: step-01
21+
try:
22+
- assert:
23+
file: 00-assert.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: flagd-with-ingress-custom-paths
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: 00-install.yaml
13+
- assert:
14+
file: 00-assert.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: flagd-with-ingress-default-paths
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: 00-install.yaml
13+
- assert:
14+
file: 00-assert.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: fsconfig-file-sync
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: ../assets/manifests.yaml
13+
- name: step-01
14+
try:
15+
- apply:
16+
file: 00-install.yaml
17+
- wait:
18+
timeout: 5m
19+
resource: job
20+
selector: kind=e2e-test-job
21+
for:
22+
condition:
23+
name: complete
24+
- name: step-02
25+
try:
26+
- assert:
27+
file: 00-assert.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: fsconfig-flagd-proxy-sync
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: ../assets/manifests.yaml
13+
- name: step-01
14+
try:
15+
- apply:
16+
file: 00-install.yaml
17+
- wait:
18+
timeout: 5m
19+
resource: job
20+
selector: kind=e2e-test-job
21+
for:
22+
condition:
23+
name: complete
24+
- name: step-02
25+
try:
26+
- assert:
27+
file: 00-assert.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: fsconfig-k8s-sync
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: ../assets/manifests.yaml
13+
- name: step-01
14+
try:
15+
- apply:
16+
file: 00-install.yaml
17+
- wait:
18+
timeout: 5m
19+
resource: job
20+
selector: kind=e2e-test-job
21+
for:
22+
condition:
23+
name: complete
24+
- name: step-02
25+
try:
26+
- assert:
27+
file: 00-assert.yaml

0 commit comments

Comments
 (0)