Skip to content

Commit f0a2c98

Browse files
authored
Provide e2e testing based on kuttl (#154)
* feat: add e2e testing workflow with kuttl
1 parent 92c4598 commit f0a2c98

11 files changed

+162
-0
lines changed

Diff for: .github/workflows/e2e.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: e2e
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
e2e:
11+
name: e2e
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: checkout
15+
uses: actions/checkout@v4
16+
17+
- name: install kuttl
18+
run: |
19+
curl -L https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64 -o /usr/local/bin/kubectl-kuttl
20+
chmod +x /usr/local/bin/kubectl-kuttl
21+
22+
- name: create kind cluster
23+
uses: helm/[email protected]
24+
25+
- name: set up helm
26+
uses: azure/setup-helm@v3
27+
28+
- name: run e2e test
29+
run: kubectl kuttl test

Diff for: kuttl-test.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestSuite
3+
testDirs:
4+
- tests/
5+
commands:
6+
- command: kubectl apply -f ./deploy/crds.yml
7+
timeout: 120

Diff for: tests/nack.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jetstream:
2+
enabled: true
3+
4+
nats:
5+
url: nats://nats:4222
6+
7+
namespaced: true

Diff for: tests/nats.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
global:
3+
labels:
4+
app: main-jetstream
5+
6+
natsBox:
7+
enabled: false
8+
9+
config:
10+
cluster:
11+
enabled: false
12+
13+
gateway:
14+
enabled: false
15+
16+
jetstream:
17+
enabled: true
18+
19+
memoryStore:
20+
enabled: true
21+
maxSize: 256Mi
22+
23+
memoryStore:
24+
enabled: true
25+
pvc:
26+
enabled: true
27+
size: 256Mi

Diff for: tests/stream-creation/00-nack.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
unitTest: false
4+
commands:
5+
- command: helm uninstall --namespace $NAMESPACE nats
6+
ignoreFailure: true
7+
- command: helm uninstall --namespace $NAMESPACE nack
8+
ignoreFailure: true
9+
- command: helm repo add nats https://nats-io.github.io/k8s/helm/charts
10+
- command: helm upgrade --install --wait --namespace $NAMESPACE nats nats/nats -f ../nats.yaml
11+
- command: helm upgrade --install --wait --namespace $NAMESPACE nack nats/nack -f ../nack.yaml

Diff for: tests/stream-creation/01-stream.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
apply:
4+
- rides-stream.yaml
5+
assert:
6+
- asserted-rides-stream.yaml
7+
unitTest: false

Diff for: tests/stream-creation/02-natscli-stream.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
apply:
4+
- natscli.yaml
5+
assert:
6+
- asserted-natscli.yaml
7+
unitTest: false

Diff for: tests/stream-creation/asserted-natscli.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
run: natscli
6+
name: natscli
7+
status:
8+
phase: Succeeded

Diff for: tests/stream-creation/asserted-rides-stream.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: jetstream.nats.io/v1beta2
2+
kind: Stream
3+
metadata:
4+
name: rides
5+
spec:
6+
allowDirect: false
7+
allowRollup: false
8+
compression: ""
9+
creds: ""
10+
denyDelete: false
11+
discard: old
12+
discardPerSubject: false
13+
firstSequence: 0
14+
maxAge: ""
15+
maxBytes: -1
16+
maxConsumers: -1
17+
maxMsgSize: -1
18+
maxMsgs: -1
19+
maxMsgsPerSubject: 0
20+
name: rides
21+
nkey: ""
22+
noAck: false
23+
preventDelete: false
24+
preventUpdate: false
25+
replicas: 1
26+
retention: limits
27+
servers: []
28+
storage: memory
29+
subjects:
30+
- rides.>

Diff for: tests/stream-creation/natscli.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
run: natscli
6+
name: natscli
7+
spec:
8+
restartPolicy: Never
9+
containers:
10+
- image: natsio/nats-box
11+
name: natscli
12+
command:
13+
- nats
14+
args:
15+
- -s
16+
- nats://nats:4222
17+
- stream
18+
- info
19+
- rides

Diff for: tests/stream-creation/rides-stream.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: jetstream.nats.io/v1beta2
2+
kind: Stream
3+
metadata:
4+
name: rides
5+
spec:
6+
name: rides
7+
subjects:
8+
- "rides.>"
9+
storage: memory
10+
replicas: 1

0 commit comments

Comments
 (0)