Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #190] Add e2e workflow #205

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: E2E tests

on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]

jobs:
test:
name: ${{ matrix.testpath }}
runs-on: ubuntu-latest
strategy:
matrix:
testpath:
- ./tests/e2e/v1alpha1/setup/

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Dockerfile
run: docker build . --file Dockerfile --tag rocketmq-operator:e2e

- 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/kuttl
chmod +x /usr/local/bin/kuttl

- name: Create k8s Kind Cluster
run: |
# install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

# install kind
curl -LO https://github.com/kubernetes-sigs/kind/releases/download/v0.20.0/kind-linux-amd64
sudo chmod +x kind-linux-amd64
sudo mv kind-linux-amd64 /usr/local/bin/kind
kind version

# create kind cluster
kind_node_image="kindest/node:v1.23.17"
echo "Kubernetes version: ${kind_node_image}"
kind create cluster --config tests/_config/kind-config.yaml
kubectl version
kubectl get all --all-namespaces

- name: Load Docker image into Kind
run: |
kubectl cluster-info --context kind-kind
kind load docker-image rocketmq-operator:e2e --name kind

- name: Install RocketMQ Operator
run: |
make deploy
kubectl set image deployment/rocketmq-operator manager=rocketmq-operator:e2e -n default

- name: Wait for RocketMQ Operator to be ready
run: |
kubectl wait --for=condition=available --timeout=300s deployment/rocketmq-operator -n default

- name: Run kuttl test
run: kuttl test ${{ matrix.testpath }} --config tests/_config/kuttl-test.yaml
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ tags

**/*.zip
**/zz_generated.openapi.go
**/*.sum
*.sum


bin
783 changes: 783 additions & 0 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/_config/chainsaw-configuration.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/configuration-chainsaw-v1alpha1.json

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
name: chainsaw-configuration
spec:
namespace: default
delayBeforeCleanup: 10s
timeouts:
apply: 5m
delete: 5m
assert: 15m
error: 15m
11 changes: 11 additions & 0 deletions tests/_config/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: kind
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
7 changes: 7 additions & 0 deletions tests/_config/kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
parallel: 1
namespace: default
timeout: 1200
suppress:
- events
20 changes: 20 additions & 0 deletions tests/e2e/v1alpha1/setup/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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:
name: rocketmq-cluster
spec:
steps:
- name: Create RocketMQ Cluster
try:
- apply:
file: cluster.yaml
- assert:
file: ready-cluster.yaml
- assert:
file: ready-sts.yaml
- assert:
file: ready-svc.yaml
- assert:
file: ready-pvc.yaml
120 changes: 120 additions & 0 deletions tests/e2e/v1alpha1/setup/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: broker-config
namespace: default
data:
# BROKER_MEM sets the broker JVM, if set to "" then Xms = Xmx = max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
BROKER_MEM: " -Xms2g -Xmx2g -Xmn1g "
broker-common.conf: |
# brokerClusterName, brokerName, brokerId are automatically generated by the operator and do not set it manually!!!
deleteWhen=04
fileReservedTime=48
flushDiskType=ASYNC_FLUSH
# set brokerRole to ASYNC_MASTER or SYNC_MASTER. DO NOT set to SLAVE because the replica instance will automatically be set!!!
brokerRole=ASYNC_MASTER

---
apiVersion: rocketmq.apache.org/v1alpha1
kind: Broker
metadata:
name: broker
namespace: default
spec:
size: 1
nameServers: ""
replicaPerGroup: 1
brokerImage: apacherocketmq/rocketmq-broker:4.5.0-alpine-operator-0.3.0
imagePullPolicy: Always
resources:
requests:
memory: "2048Mi"
cpu: "250m"
limits:
memory: "12288Mi"
cpu: "500m"
allowRestart: true
storageMode: StorageClass
scalePodName: broker-0-master-0
env:
- name: BROKER_MEM
valueFrom:
configMapKeyRef:
name: broker-config
key: BROKER_MEM
volumes:
- name: broker-config
configMap:
name: broker-config
items:
- key: broker-common.conf
path: broker-common.conf
volumeClaimTemplates:
- metadata:
name: broker-storage
spec:
accessModes:
- ReadWriteOnce
storageClassName: rocketmq-storage
resources:
requests:
storage: 8Gi
---
apiVersion: rocketmq.apache.org/v1alpha1
kind: NameService
metadata:
name: name-service
namespace: default
spec:
size: 1
nameServiceImage: apacherocketmq/rocketmq-nameserver:4.5.0-alpine-operator-0.3.0
imagePullPolicy: Always
hostNetwork: false
dnsPolicy: ClusterFirstWithHostNet
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1024Mi"
cpu: "500m"
storageMode: StorageClass
volumeClaimTemplates:
- metadata:
name: namesrv-storage
spec:
accessModes:
- ReadWriteOnce
storageClassName: rocketmq-storage
resources:
requests:
storage: 1Gi
---
apiVersion: rocketmq.apache.org/v1alpha1
kind: Console
metadata:
name: console
namespace: default
spec:
nameServers: ""
consoleDeployment:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rocketmq-console
spec:
replicas: 1
selector:
matchLabels:
app: rocketmq-console
template:
metadata:
labels:
app: rocketmq-console
spec:
containers:
- name: console
image: apacherocketmq/rocketmq-console:2.0.0
ports:
- containerPort: 8080
10 changes: 10 additions & 0 deletions tests/e2e/v1alpha1/setup/ready-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: rocketmq.apache.org/v1alpha1
kind: Broker
metadata:
name: broker
namespace: default
status:
nodes:
- broker-0-master-0
- broker-0-replica-1-0
size: 1
37 changes: 37 additions & 0 deletions tests/e2e/v1alpha1/setup/ready-sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: broker-0-master
namespace: default
spec:
selector:
matchLabels:
app: broker
broker_cr: broker
template:
metadata:
labels:
app: broker
broker_cr: broker
status:
readyReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: broker-0-replica-1
namespace: default
spec:
selector:
matchLabels:
app: broker
broker_cr: broker
template:
metadata:
labels:
app: broker
broker_cr: broker
status:
readyReplicas: 1
replicas: 1
Loading