Skip to content

Commit

Permalink
Provide e2e testing based on kuttl (#154)
Browse files Browse the repository at this point in the history
* feat: add e2e testing workflow with kuttl
  • Loading branch information
1995parham authored Dec 11, 2023
1 parent 92c4598 commit f0a2c98
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: e2e

on:
push:
branches:
- main
pull_request:

jobs:
e2e:
name: e2e
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: install kuttl
run: |
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
chmod +x /usr/local/bin/kubectl-kuttl
- name: create kind cluster
uses: helm/[email protected]

- name: set up helm
uses: azure/setup-helm@v3

- name: run e2e test
run: kubectl kuttl test
7 changes: 7 additions & 0 deletions kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
testDirs:
- tests/
commands:
- command: kubectl apply -f ./deploy/crds.yml
timeout: 120
7 changes: 7 additions & 0 deletions tests/nack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jetstream:
enabled: true

nats:
url: nats://nats:4222

namespaced: true
27 changes: 27 additions & 0 deletions tests/nats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
global:
labels:
app: main-jetstream

natsBox:
enabled: false

config:
cluster:
enabled: false

gateway:
enabled: false

jetstream:
enabled: true

memoryStore:
enabled: true
maxSize: 256Mi

memoryStore:
enabled: true
pvc:
enabled: true
size: 256Mi
11 changes: 11 additions & 0 deletions tests/stream-creation/00-nack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
unitTest: false
commands:
- command: helm uninstall --namespace $NAMESPACE nats
ignoreFailure: true
- command: helm uninstall --namespace $NAMESPACE nack
ignoreFailure: true
- command: helm repo add nats https://nats-io.github.io/k8s/helm/charts
- command: helm upgrade --install --wait --namespace $NAMESPACE nats nats/nats -f ../nats.yaml
- command: helm upgrade --install --wait --namespace $NAMESPACE nack nats/nack -f ../nack.yaml
7 changes: 7 additions & 0 deletions tests/stream-creation/01-stream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- rides-stream.yaml
assert:
- asserted-rides-stream.yaml
unitTest: false
7 changes: 7 additions & 0 deletions tests/stream-creation/02-natscli-stream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- natscli.yaml
assert:
- asserted-natscli.yaml
unitTest: false
8 changes: 8 additions & 0 deletions tests/stream-creation/asserted-natscli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
labels:
run: natscli
name: natscli
status:
phase: Succeeded
30 changes: 30 additions & 0 deletions tests/stream-creation/asserted-rides-stream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: jetstream.nats.io/v1beta2
kind: Stream
metadata:
name: rides
spec:
allowDirect: false
allowRollup: false
compression: ""
creds: ""
denyDelete: false
discard: old
discardPerSubject: false
firstSequence: 0
maxAge: ""
maxBytes: -1
maxConsumers: -1
maxMsgSize: -1
maxMsgs: -1
maxMsgsPerSubject: 0
name: rides
nkey: ""
noAck: false
preventDelete: false
preventUpdate: false
replicas: 1
retention: limits
servers: []
storage: memory
subjects:
- rides.>
19 changes: 19 additions & 0 deletions tests/stream-creation/natscli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
labels:
run: natscli
name: natscli
spec:
restartPolicy: Never
containers:
- image: natsio/nats-box
name: natscli
command:
- nats
args:
- -s
- nats://nats:4222
- stream
- info
- rides
10 changes: 10 additions & 0 deletions tests/stream-creation/rides-stream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: jetstream.nats.io/v1beta2
kind: Stream
metadata:
name: rides
spec:
name: rides
subjects:
- "rides.>"
storage: memory
replicas: 1

0 comments on commit f0a2c98

Please sign in to comment.