Skip to content

Commit

Permalink
test & fix: add test cases for workloads, fix labels of hooks (#51)
Browse files Browse the repository at this point in the history
* chore: bump risingwave to v1.7.1 and release

Signed-off-by: arkbriar <[email protected]>

* Add test cases for meta store and state store, deprecate root fields

Signed-off-by: arkbriar <[email protected]>

* Add tests for standalone

Signed-off-by: arkbriar <[email protected]>

* Fix typo

Signed-off-by: arkbriar <[email protected]>

---------

Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar authored Mar 19, 2024
1 parent e4cec63 commit 3e24ea7
Show file tree
Hide file tree
Showing 15 changed files with 1,539 additions and 591 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test:
@$(foreach chart,$(HELM_CHARTS),helm unittest --strict -f 'tests/**/*_test.yaml' charts/$(chart);)

define test-uncommitted-for-chart
$(eval uncommitted_files := $(shell git diff --name-only head -- charts/$(1)/tests | sed -e "s/charts\/$(1)\///g"))
$(eval uncommitted_files := $(shell git diff --name-status head -- charts/$(1)/tests | grep -v '^D' | awk '{print $$2}' | sed -e "s/charts\/$(1)\///g"))
if [ "$(uncommitted_files)" != "" ]; then \
helm unittest --strict $(addprefix -f ,$(uncommitted_files)) charts/$(1); \
fi
Expand Down
17 changes: 14 additions & 3 deletions charts/risingwave/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ Create the name of credential Secret to use. Return empty string if the Secret i
{{- end }}
{{- end }}
{{/*
Create the meta backend type string to use.
*/}}
{{- define "risingwave.metaBackend" -}}
{{- if or (include "risingwave.bundle.etcd.enabled" .) .Values.metaStore.etcd.enabled }}
{{- print "etcd" }}
{{- else }}
{{- print "" }}
{{- end }}
{{- end }}
{{/*
Create the hummock connection string to use.
*/}}
Expand All @@ -212,11 +223,11 @@ Create the hummock connection string to use.
{{- else if .Values.stateStore.oss.enabled }}
{{- printf "hummock+oss://%s" .Values.stateStore.oss.bucket }}
{{- else if .Values.stateStore.azblob.enabled }}
{{- printf "hummock+azblob://%s@%s" .Values.stateStore.azblob.container .Values.stateStore.azblob.root }}
{{- printf "hummock+azblob://%s" .Values.stateStore.azblob.container }}
{{- else if .Values.stateStore.gcs.enabled }}
{{- printf "hummock+gcs://%s@%s" .Values.stateStore.gcs.bucket .Values.stateStore.gcs.root }}
{{- printf "hummock+gcs://%s" .Values.stateStore.gcs.bucket }}
{{- else if .Values.stateStore.hdfs.enabled }}
{{- printf "hummock+hdfs://%s@%s" .Values.stateStore.hdfs.nameNode .Values.stateStore.hdfs.root }}
{{- printf "hummock+hdfs://%s" .Values.stateStore.hdfs.nameNode }}
{{- else if .Values.stateStore.obs.enabled }}
{{- printf "hummock+obs://%s" .Values.stateStore.obs.bucket }}
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ metadata:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-10"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- include "risingwave.annotations" . | nindent 4 }}
spec:
backoffLimit: 10
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ metadata:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- include "risingwave.annotations" . | nindent 4 }}
spec:
backoffLimit: 10
template:
Expand Down
1 change: 1 addition & 0 deletions charts/risingwave/templates/hooks/post-install-wait.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ metadata:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-20"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- include "risingwave.annotations" . | nindent 4 }}
spec:
backoffLimit: 10
template:
Expand Down
4 changes: 3 additions & 1 deletion charts/risingwave/templates/meta-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ spec:
- name: RW_DASHBOARD_HOST
value: "0.0.0.0:{{ .Values.ports.meta.dashboard }}"
- name: RW_BACKEND
value: etcd
value: {{ include "risingwave.metaBackend" . }}
{{- if or .Values.metaStore.etcd.enabled (include "risingwave.bundle.etcd.enabled" .) }}
- name: RW_ETCD_ENDPOINTS
value: {{ include "risingwave.metaStoreEtcdEndpoints" . }}
- name: RW_ETCD_AUTH
value: {{ include "risingwave.metaStoreAuthRequired" . | quote }}
{{- end }}
{{- if (include "risingwave.bundle.etcd.enabled" .) }}
{{- if .Values.etcd.auth.rbac.create }}
- name: RW_ETCD_USERNAME
Expand Down
4 changes: 3 additions & 1 deletion charts/risingwave/templates/standalone/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,13 @@ spec:
- name: RW_DATA_DIRECTORY
value: {{ include "risingwave.stateStoreDataDirectory" . }}
- name: RW_BACKEND
value: etcd
value: {{ include "risingwave.metaBackend" . }}
{{- if or .Values.metaStore.etcd.enabled (include "risingwave.bundle.etcd.enabled" .) }}
- name: RW_ETCD_ENDPOINTS
value: {{ include "risingwave.metaStoreEtcdEndpoints" . }}
- name: RW_ETCD_AUTH
value: {{ include "risingwave.metaStoreAuthRequired" . | quote }}
{{- end }}
{{- if (include "risingwave.bundle.etcd.enabled" .) }}
{{- if .Values.etcd.auth.rbac.create }}
- name: RW_ETCD_USERNAME
Expand Down
80 changes: 80 additions & 0 deletions charts/risingwave/tests/diagnostic_mode_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
suite: Test diagnose mode
templates:
- templates/meta-sts.yaml
- templates/compute-sts.yaml
- templates/frontend-deploy.yaml
- templates/compactor-deploy.yaml
- templates/standalone/standalone-sts.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
set:
diagnosticMode:
enabled: true
command:
- sleep
args:
- infinity
tests:
- it: pods must not have probes (cluster)
templates:
- templates/meta-sts.yaml
- templates/compute-sts.yaml
- templates/frontend-deploy.yaml
- templates/compactor-deploy.yaml
asserts:
- hasDocuments:
count: 1
- notExists:
path: spec.template.spec.livenessProbe
- notExists:
path: spec.template.spec.readinessProbe
- notExists:
path: spec.template.spec.startupProbe
- it: pods must not have probes (standalone)
set:
standalone.enabled: true
templates:
- templates/standalone/standalone-sts.yaml
asserts:
- hasDocuments:
count: 1
- notExists:
path: spec.template.spec.livenessProbe
- notExists:
path: spec.template.spec.readinessProbe
- notExists:
path: spec.template.spec.startupProbe
- it: pods must start with debug command and arguments (cluster)
templates:
- templates/meta-sts.yaml
- templates/compute-sts.yaml
- templates/frontend-deploy.yaml
- templates/compactor-deploy.yaml
asserts:
- hasDocuments:
count: 1
- equal:
path: spec.template.spec.containers[0].command
value:
- sleep
- equal:
path: spec.template.spec.containers[0].args
value:
- infinity
- it: pods must start with debug command and arguments (standalone)
set:
standalone.enabled: true
templates:
- templates/standalone/standalone-sts.yaml
asserts:
- hasDocuments:
count: 1
- equal:
path: spec.template.spec.containers[0].command
value:
- sleep
- equal:
path: spec.template.spec.containers[0].args
value:
- infinity
176 changes: 176 additions & 0 deletions charts/risingwave/tests/metastore/meta-sts_env_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
suite: Test meta store env vars (meta-sts)
templates:
- templates/meta-sts.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
# Tests for etcd.
## true-negative (etcd)
- it: envs must not contain etcd endpoints (non-etcd)
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_ENDPOINTS
any: true
- it: envs must not contain etcd auth (non-etcd)
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_AUTH
any: true
- it: envs must not contain etcd username (non-etcd)
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_USERNAME
any: true
- it: envs must not contain etcd password (non-etcd)
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_PASSWORD
any: true
## true-positive (etcd)
- it: envs must contain backend set to etcd (etcd)
set:
metaStore:
etcd:
enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_BACKEND
value: etcd
- it: envs must contain etcd endpoints (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_ENDPOINTS
value: ep1
- it: envs must support multiple etcd endpoints (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
- ep2
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_ENDPOINTS
value: ep1,ep2
- it: envs must reflect auth, true (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
authentication:
enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_AUTH
value: "true"
- it: envs must reflect auth, false (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
authentication:
enabled: false
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_AUTH
value: "false"
- equal:
path: spec.template.spec.containers[0].envFrom
value: null
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_USERNAME
any: true
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_PASSWORD
any: true
- it: env from must contain the secret if username/password provided (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
authentication:
enabled: true
username: u
password: p
asserts:
- contains:
path: spec.template.spec.containers[0].envFrom
content:
secretRef:
name: RELEASE-NAME-risingwave-etcd
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_USERNAME
any: true
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_PASSWORD
any: true
- it: env must contain the secret if existing secret provided (etcd)
set:
metaStore:
etcd:
enabled: true
endpoints:
- ep1
authentication:
enabled: true
existingSecretName: s
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom
value: null
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_USERNAME
valueFrom:
secretKeyRef:
key: username
name: s
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_ETCD_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: s
Loading

0 comments on commit 3e24ea7

Please sign in to comment.