Skip to content

Commit 4363d1a

Browse files
committed
kuttl integration test
Run an e2e test with ephemeral kind cluster. Usage: make test-e2e The integration test is also executed as a github action Signed-off-by: Leonardo Milleri <[email protected]>
1 parent 3ddad46 commit 4363d1a

24 files changed

+313
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Integration tests"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main 
10+
11+
env:
12+
KUTTL: /usr/local/bin/kubectl-kuttl
13+
14+
jobs:
15+
integration-tests:
16+
runs-on: ubuntu-20.04
17+
steps:
18+
19+
- uses: actions/[email protected]
20+
with:
21+
go-version: 1.21
22+
23+
- uses: actions/[email protected]
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo curl -Lo $KUTTL https://github.com/kudobuilder/kuttl/releases/download/v0.19.0/kubectl-kuttl_0.19.0_linux_x86_64
28+
sudo chmod +x $KUTTL
29+
sudo curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.24.0/kind-linux-amd64
30+
sudo chmod +x kind
31+
32+
- name: "Run integration tests"
33+
run: make test-e2e

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
172172
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
173173
$(KUSTOMIZE) build config/default > dist/install.yaml
174174

175+
# Run sample attestation in a kind cluster
176+
# pre-requirements: kuttl plugin and kind are installed
177+
# optional: you can change the trustee image by defining the env variable KBS_IMAGE_NAME
178+
# Usage: KBS_IMAGE_NAME=<trustee-image> make test-e2e
179+
.PHONY: test-e2e
180+
test-e2e:
181+
./tests/scripts/kind-with-registry.sh
182+
kubectl kuttl test || true
183+
kind delete cluster
184+
175185
##@ Build Dependencies
176186

177187
## Location to install dependencies to

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,19 @@ which provide a reconcile function responsible for synchronizing resources until
312312

313313
**NOTE:** You can also run this in one step by running: `make install run`
314314

315+
### Integration tests
316+
317+
An attestation with the sample-attester is performed in an ephemeral kind cluster
318+
Pre-requirements:
319+
- [kuttl](https://kuttl.dev/docs/cli.html#setup-the-kuttl-kubectl-plugin) plugin installed
320+
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) installed
321+
322+
Optional: set the env variable KBS_IMAGE_NAME to override the default trustee image
323+
324+
```sh
325+
KBS_IMAGE_NAME=<trustee-image> make test-e2e
326+
```
327+
315328
### Modifying the API definitions
316329

317330
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:

kuttl-test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestSuite
3+
testDirs:
4+
- tests/e2e/
5+
timeout: 120
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: trustee-operator-controller-manager
5+
namespace: trustee-operator-system
6+
status:
7+
readyReplicas: 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- command: ./install-operator.sh
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: kbs-auth-public-key
5+
namespace: trustee-operator-system
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- command: ./create-auth-secret.sh
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: kbsres1
5+
namespace: trustee-operator-system
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- command: ./create-other-secret.sh

0 commit comments

Comments
 (0)