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

[Test] : e2e Test for Redis Cluster #623

Merged
merged 1 commit into from
Sep 15, 2023
Merged
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
1 change: 1 addition & 0 deletions api/v1beta2/rediscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type RedisFollower struct {
}

// RedisClusterStatus defines the observed state of RedisCluster
// +kubebuilder:subresource:status
type RedisClusterStatus struct {
State status.RedisClusterState `json:"state,omitempty"`
Reason string `json:"reason,omitempty"`
Expand Down
12 changes: 0 additions & 12 deletions kuttl-test.yaml

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions tests/_config/kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
startKIND: false
kindConfig: "./kind-config.yaml"
parallel: 1
timeout: 300
suppress :
- events
7 changes: 0 additions & 7 deletions tests/e2e/setup/ready-standalone.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply :
- standalone.yaml
- cluster.yaml
assert :
- ready-standalone.yaml
- ready-cluster.yaml
- ready-cluster.yaml
- ready-cluster-sts.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
kind: RedisCluster
metadata:
name: redis-standalone
name: redis-cluster-v1beta1
spec:
podSecurityContext:
clusterSize: 3
clusterVersion: v7
persistenceEnabled: true
securityContext:
runAsUser: 1000
fsGroup: 1000
fsGroup: 1000
kubernetesConfig:
image: quay.io/opstree/redis:v7.0.12
image: quay.io/opstree/redis:v7.0.7
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 10m
memory: 10Mi
cpu: 101m
memory: 128Mi
limits:
cpu: 10m
memory: 10Mi
cpu: 101m
memory: 128Mi
redisExporter:
enabled: false
enabled: true
image: quay.io/opstree/redis-exporter:v1.44.0
imagePullPolicy: Always
resources:
requests:
cpu: 10m
memory: 10Mi
cpu: 100m
memory: 128Mi
limits:
cpu: 10m
memory: 12Mi
cpu: 100m
memory: 128Mi
storage:
volumeClaimTemplate:
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-cluster-leader
name: redis-cluster-v1beta1-leader
status:
replicas: 3
readyReplicas: 3
Expand All @@ -11,7 +11,7 @@ status:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-cluster-follower
name: redis-cluster-v1beta1-follower
status:
replicas: 3
readyReplicas: 3
7 changes: 7 additions & 0 deletions tests/e2e/v1beta1/setup/ready-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisCluster
metadata:
name: redis-cluster-v1beta1
status:
readyFollowerReplicas: 3
readyLeaderReplicas: 3
7 changes: 7 additions & 0 deletions tests/e2e/v1beta2/setup/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply :
- cluster.yaml
assert :
- ready-cluster.yaml
- ready-cluster-sts.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: redis.redis.opstreelabs.in/v1beta1
apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisCluster
metadata:
name: redis-cluster
name: redis-cluster-v1beta2
spec:
clusterSize: 3
clusterVersion: v7
Expand All @@ -10,7 +10,7 @@ spec:
runAsUser: 1000
fsGroup: 1000
kubernetesConfig:
image: quay.io/opstree/redis:v7.0.12
image: quay.io/opstree/redis:v7.0.11
imagePullPolicy: IfNotPresent
resources:
requests:
Expand All @@ -20,7 +20,7 @@ spec:
cpu: 101m
memory: 128Mi
redisExporter:
enabled: false
enabled: true
image: quay.io/opstree/redis-exporter:v1.44.0
imagePullPolicy: Always
resources:
Expand All @@ -38,9 +38,10 @@ spec:
resources:
requests:
storage: 1Gi
nodeConfVolume: true
nodeConfVolumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
storage: 1Gi
17 changes: 17 additions & 0 deletions tests/e2e/v1beta2/setup/ready-cluster-sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-cluster-v1beta2-leader
status:
replicas: 3
readyReplicas: 3

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-cluster-v1beta2-follower
status:
replicas: 3
readyReplicas: 3
7 changes: 7 additions & 0 deletions tests/e2e/v1beta2/setup/ready-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisCluster
metadata:
name: redis-cluster-v1beta2
status:
# readyFollowerReplicas: 3
readyLeaderReplicas: 3
42 changes: 42 additions & 0 deletions tests/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# E2E Testing of the Redis Cluster with Kuttl

This guide will walk you through the process of end-to-end (E2E) testing a Redis cluster using the `kuttl` utility.

## **Prerequisites**

Ensure you have the following tools installed:

- **kuttl**: For testing. [Installation Guide](https://kuttl.dev/docs/installation/)
- **kind**: For local Kubernetes clusters. [Installation Guide](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
- **kubectl**: Kubernetes command-line tool. [Installation Guide](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- **helm**: Package manager for Kubernetes. [Installation Guide](https://helm.sh/docs/intro/install/)

## **Steps**

### **1. Set Up a 3-node Kind Cluster**

## Steps to Follow

### 1. Set Up a 3-node Kind Cluster

Create a 3-node kind cluster using the provided configuration:

```bash
kind create cluster --config /redis-operator/tests/_config/kind-example-config.yaml
```

### 2. Install the Redis Operator

To install the Redis operator, utilize the Helm chart from the repository provided:

- [OT-CONTAINER-KIT Redis Operator Helm Chart](https://github.com/OT-CONTAINER-KIT/helm-charts/tree/main/charts/redis-operator#readme)

Please refer to the repository's README for detailed instructions on installing the operator using Helm.

### 3. Execute Kuttl Test

Execute the kuttl test using the following command:

```bash
kubectl kuttl test redis-operator/tests/e2e/v1beta2 --config /redis-operator/tests/_config/kuttl-test.yaml --timeout 10m
```
Loading