From 2e370437c62d3fae0c3236f143bef77c74c4c6b8 Mon Sep 17 00:00:00 2001 From: Shubham Gupta <69793468+shubham-cmyk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:10:27 +0530 Subject: [PATCH] Merge the e2e Test Files (#623) Signed-off-by: Shubham Gupta Signed-off-by: Matt Robinson --- api/v1beta2/rediscluster_types.go | 1 + kuttl-test.yaml | 12 ------ .../_config/kind-config.yaml | 0 tests/_config/kuttl-test.yaml | 8 ++++ tests/e2e/setup/ready-standalone.yaml | 7 ---- tests/e2e/{ => v1beta1}/setup/00-install.yaml | 5 +-- .../setup/cluster.yaml} | 32 +++++++------- .../setup/ready-cluster-sts.yaml} | 4 +- tests/e2e/v1beta1/setup/ready-cluster.yaml | 7 ++++ tests/e2e/v1beta2/setup/00-install.yaml | 7 ++++ tests/e2e/{ => v1beta2}/setup/cluster.yaml | 11 ++--- .../e2e/v1beta2/setup/ready-cluster-sts.yaml | 17 ++++++++ tests/e2e/v1beta2/setup/ready-cluster.yaml | 7 ++++ tests/readme.md | 42 +++++++++++++++++++ 14 files changed, 116 insertions(+), 44 deletions(-) delete mode 100644 kuttl-test.yaml rename kind-config.yaml => tests/_config/kind-config.yaml (100%) create mode 100644 tests/_config/kuttl-test.yaml delete mode 100644 tests/e2e/setup/ready-standalone.yaml rename tests/e2e/{ => v1beta1}/setup/00-install.yaml (54%) rename tests/e2e/{setup/standalone.yaml => v1beta1/setup/cluster.yaml} (57%) rename tests/e2e/{setup/ready-cluster.yaml => v1beta1/setup/ready-cluster-sts.yaml} (70%) create mode 100644 tests/e2e/v1beta1/setup/ready-cluster.yaml create mode 100644 tests/e2e/v1beta2/setup/00-install.yaml rename tests/e2e/{ => v1beta2}/setup/cluster.yaml (82%) create mode 100644 tests/e2e/v1beta2/setup/ready-cluster-sts.yaml create mode 100644 tests/e2e/v1beta2/setup/ready-cluster.yaml create mode 100644 tests/readme.md diff --git a/api/v1beta2/rediscluster_types.go b/api/v1beta2/rediscluster_types.go index 1de719f9c..69e0e5ff9 100644 --- a/api/v1beta2/rediscluster_types.go +++ b/api/v1beta2/rediscluster_types.go @@ -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"` diff --git a/kuttl-test.yaml b/kuttl-test.yaml deleted file mode 100644 index e39b34d9b..000000000 --- a/kuttl-test.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestSuite -startKIND: true -kindConfig: "./kind-config.yaml" -crdDir: "./config/crd/bases" -testDirs: -- "./tests/e2e/" -# parallel: 3 -timeout: 1000 -namespace : ot-container -suppress : - - events \ No newline at end of file diff --git a/kind-config.yaml b/tests/_config/kind-config.yaml similarity index 100% rename from kind-config.yaml rename to tests/_config/kind-config.yaml diff --git a/tests/_config/kuttl-test.yaml b/tests/_config/kuttl-test.yaml new file mode 100644 index 000000000..ab9b63777 --- /dev/null +++ b/tests/_config/kuttl-test.yaml @@ -0,0 +1,8 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestSuite +startKIND: false +kindConfig: "./kind-config.yaml" +parallel: 1 +timeout: 300 +suppress : + - events \ No newline at end of file diff --git a/tests/e2e/setup/ready-standalone.yaml b/tests/e2e/setup/ready-standalone.yaml deleted file mode 100644 index 8e92cf47b..000000000 --- a/tests/e2e/setup/ready-standalone.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: redis-standalone -status: - replicas: 1 - readyReplicas: 1 \ No newline at end of file diff --git a/tests/e2e/setup/00-install.yaml b/tests/e2e/v1beta1/setup/00-install.yaml similarity index 54% rename from tests/e2e/setup/00-install.yaml rename to tests/e2e/v1beta1/setup/00-install.yaml index e9c279616..94b166978 100644 --- a/tests/e2e/setup/00-install.yaml +++ b/tests/e2e/v1beta1/setup/00-install.yaml @@ -1,8 +1,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep apply : - - standalone.yaml - cluster.yaml assert : - - ready-standalone.yaml - - ready-cluster.yaml \ No newline at end of file + - ready-cluster.yaml + - ready-cluster-sts.yaml \ No newline at end of file diff --git a/tests/e2e/setup/standalone.yaml b/tests/e2e/v1beta1/setup/cluster.yaml similarity index 57% rename from tests/e2e/setup/standalone.yaml rename to tests/e2e/v1beta1/setup/cluster.yaml index bbd480202..73afc2b4a 100644 --- a/tests/e2e/setup/standalone.yaml +++ b/tests/e2e/v1beta1/setup/cluster.yaml @@ -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: diff --git a/tests/e2e/setup/ready-cluster.yaml b/tests/e2e/v1beta1/setup/ready-cluster-sts.yaml similarity index 70% rename from tests/e2e/setup/ready-cluster.yaml rename to tests/e2e/v1beta1/setup/ready-cluster-sts.yaml index a232d81f1..8c0fec94c 100644 --- a/tests/e2e/setup/ready-cluster.yaml +++ b/tests/e2e/v1beta1/setup/ready-cluster-sts.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: redis-cluster-leader + name: redis-cluster-v1beta1-leader status: replicas: 3 readyReplicas: 3 @@ -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 diff --git a/tests/e2e/v1beta1/setup/ready-cluster.yaml b/tests/e2e/v1beta1/setup/ready-cluster.yaml new file mode 100644 index 000000000..79a48407b --- /dev/null +++ b/tests/e2e/v1beta1/setup/ready-cluster.yaml @@ -0,0 +1,7 @@ +apiVersion: redis.redis.opstreelabs.in/v1beta1 +kind: RedisCluster +metadata: + name: redis-cluster-v1beta1 +status: + readyFollowerReplicas: 3 + readyLeaderReplicas: 3 diff --git a/tests/e2e/v1beta2/setup/00-install.yaml b/tests/e2e/v1beta2/setup/00-install.yaml new file mode 100644 index 000000000..94b166978 --- /dev/null +++ b/tests/e2e/v1beta2/setup/00-install.yaml @@ -0,0 +1,7 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply : + - cluster.yaml +assert : + - ready-cluster.yaml + - ready-cluster-sts.yaml \ No newline at end of file diff --git a/tests/e2e/setup/cluster.yaml b/tests/e2e/v1beta2/setup/cluster.yaml similarity index 82% rename from tests/e2e/setup/cluster.yaml rename to tests/e2e/v1beta2/setup/cluster.yaml index 80aa3efaa..09b11b18b 100644 --- a/tests/e2e/setup/cluster.yaml +++ b/tests/e2e/v1beta2/setup/cluster.yaml @@ -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 @@ -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: @@ -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: @@ -38,9 +38,10 @@ spec: resources: requests: storage: 1Gi + nodeConfVolume: true nodeConfVolumeClaimTemplate: spec: accessModes: ["ReadWriteOnce"] resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file diff --git a/tests/e2e/v1beta2/setup/ready-cluster-sts.yaml b/tests/e2e/v1beta2/setup/ready-cluster-sts.yaml new file mode 100644 index 000000000..2b6704dbe --- /dev/null +++ b/tests/e2e/v1beta2/setup/ready-cluster-sts.yaml @@ -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 diff --git a/tests/e2e/v1beta2/setup/ready-cluster.yaml b/tests/e2e/v1beta2/setup/ready-cluster.yaml new file mode 100644 index 000000000..57d53c708 --- /dev/null +++ b/tests/e2e/v1beta2/setup/ready-cluster.yaml @@ -0,0 +1,7 @@ +apiVersion: redis.redis.opstreelabs.in/v1beta1 +kind: RedisCluster +metadata: + name: redis-cluster-v1beta2 +status: + # readyFollowerReplicas: 3 + readyLeaderReplicas: 3 diff --git a/tests/readme.md b/tests/readme.md new file mode 100644 index 000000000..155b89fb3 --- /dev/null +++ b/tests/readme.md @@ -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 +```