Skip to content

Commit

Permalink
test: add test cases for validation.yaml and services yaml files (#50)
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]>

* test: add test cases for validation.yaml

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

* Fix CI

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

---------

Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar authored Mar 14, 2024
1 parent 4e6b36e commit e4cec63
Show file tree
Hide file tree
Showing 9 changed files with 1,016 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
- name: Run Helm Lint
run: |
make helm-dependency-update
make lint
- name: Run Unit Tests
run: |
make test
32 changes: 28 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
HELM_CHARTS=$(shell ls charts)
#INCUBATING_HELM_CHARTS=$(shell ls incubating/charts)

helm-dependency-update:
@$(foreach chart,$(HELM_CHARTS),helm dependency update charts/$(chart);)

lint:
# for each in $(HELM_CHARTS) and $(INCUBATING_HELM_CHARTS), do helm lint
$(foreach chart,$(HELM_CHARTS),helm lint charts/$(chart);)
# for each in $(HELM_CHARTS), do helm lint
@$(foreach chart,$(HELM_CHARTS),helm lint --strict --set tags.bundle=true charts/$(chart);)
#$(foreach chart,$(INCUBATING_HELM_CHARTS),helm lint incubating/charts/$(chart);)

test:
$(foreach chart,$(HELM_CHARTS),helm unittest --strict -f 'tests/**/*_test.yaml' charts/$(chart);)
# for each in $(HELM_CHARTS), do helm unittest
@$(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"))
if [ "$(uncommitted_files)" != "" ]; then \
helm unittest --strict $(addprefix -f ,$(uncommitted_files)) charts/$(1); \
fi
endef

.PHONY: test-uncommitted
test-uncommitted: $(UNCOMMITTED_TEST_FILES)
@$(foreach chart,$(HELM_CHARTS),$(call test-uncommitted-for-chart,$(chart)))

sync-crds:
./scripts/sync-crds.sh charts/risingwave-operator/crds

sanitize:
@./scripts/sanitize.sh

# A literal space.
space :=
space +=

# Joins elements of the list in arg 2 with the given separator.
# 1. Element separator.
# 2. The list.
join-with = $(subst $(space),$1,$(strip $2))
strip-prefix = $(subst $2,,$1)
3 changes: 3 additions & 0 deletions charts/risingwave/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
name: {{ include "risingwave.serviceAccountName" . }}
labels:
{{- include "risingwave.labels" . | nindent 4 }}
{{- with.Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if or (include "risingwave.annotations" .) .Values.serviceAccount.annotations }}
annotations:
{{- $annotations := (include "risingwave.annotations" . ) | trim }}
Expand Down
75 changes: 30 additions & 45 deletions charts/risingwave/templates/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Validate state store backends.
{{ $count = add1 $count }}
{{ $name = "MinIO" }}
{{- else }}
{{- fail "Unnecessary bundled minio when $name is enabled! Try setting `tags.minio=false,tags.bundle=false` and retry!" }}
{{- printf "Unnecessary bundled minio when %s is enabled! Try setting `tags.minio=false,tags.bundle=false` and retry!" $name | fail }}
{{- end }}
{{- else }}
{{- if .Values.stateStore.oss.enabled }}{{ $count = add1 $count }}{{ $name = "MinIO" }}{{- end }}
{{- if .Values.stateStore.minio.enabled }}{{ $count = add1 $count }}{{ $name = "MinIO" }}{{- end }}
{{- end }}
{{- if (eq $count 0 ) }}
{{- fail "No state store backend!\n Please set up one of S3, MinIO, GCS, OSS, AZBLOB, HDFS, and OBS under `stateStore`, or use the bundled MinIO by setting `tags.minio=true`!" }}
{{- else if (gt $count 1) }}
{{- fail "More than one state store backend!" }}
{{- fail "More than one state store backends!" }}
{{- end }}

{{/*
Expand All @@ -58,15 +58,15 @@ Validate meta store backends.
{{ $count = add1 $count }}
{{ $name = "etcd" }}
{{- else }}
{{- fail "Unnecessary bundled etcd when $name is enabled!" }}
{{- printf "Unnecessary bundled etcd when %s is enabled!" $name | fail }}
{{- end }}
{{- else }}
{{- if .Values.metaStore.etcd.enabled }}{{ $count = add1 $count }}{{ $name = "etcd" }}{{- end }}
{{- end }}
{{- if (eq $count 0 ) }}
{{- fail "No meta store backend!\n Please set up an external etcd under `metaStore`, or use the bundled one by setting `tags.etcd=true`!" }}
{{- else if (gt $count 1) }}
{{- fail "More than one meta store backend!" }}
{{- fail "More than one meta store backends!" }}
{{- end }}

{{/*
Expand All @@ -92,17 +92,14 @@ Validate parameters of S3 state store.
{{- with .Values.stateStore.s3 }}
{{- if .enabled }}
{{- if empty .bucket }}
{{- fail "State store S3 bucket must be set" }}
{{- fail "Bucket .stateStore.s3.bucket must be set!" }}
{{- end }}
{{- if empty .region }}
{{- fail "State store S3 region must be set" }}
{{- fail "Region .stateStore.s3.region must be set!" }}
{{- end }}
{{- if and (empty .authentication.existingSecretName) (not .authentication.useServiceAccount) }}
{{- if empty .authentication.accessKey }}
{{- fail "State store S3 authentication access key must be set" }}
{{- end }}
{{- if empty .authentication.secretAccessKey }}
{{- fail "State store S3 authentication secret access key must be set" }}
{{- if or (empty .authentication.accessKey) (empty .authentication.secretAccessKey)}}
{{- fail "Either use IAM role for Service account or AccessKey/SecretAccessKey must be provided!\nCheck .stateStore.s3.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -115,17 +112,14 @@ Validate parameters of external MinIO state store.
{{- with .Values.stateStore.minio }}
{{- if .enabled }}
{{- if empty .endpoint }}
{{- fail "State store MinIO endpoint must be set" }}
{{- fail "Endpoint .stateStore.minio.endpoint must be set!" }}
{{- end }}
{{- if empty .bucket }}
{{- fail "State store MinIO bucket must be set" }}
{{- fail "Bucket .stateStore.minio.bucket must be set!" }}
{{- end }}
{{- if empty .authentication.existingSecretName }}
{{- if empty .authentication.username }}
{{- fail "State store MinIO authentication username must be set" }}
{{- end }}
{{- if empty .authentication.password }}
{{- fail "State store MinIO authentication password key must be set" }}
{{- if or (empty .authentication.username) (empty .authentication.password) }}
{{- fail "Username/password must be provided!\nCheck .stateStore.minio.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -138,11 +132,11 @@ Validate parameter of GCS state store.
{{- with .Values.stateStore.gcs }}
{{- if .enabled }}
{{- if empty .bucket }}
{{- fail "State store GCS bucket must be set" }}
{{- fail "Bucket .stateStore.gcs.bucket must be set!" }}
{{- end }}
{{- if and (empty .authentication.existingSecretName) (not .authentication.useServiceAccount) }}
{{- if empty .authentication.credentials }}
{{- fail "State store GCS authentication credentials must be set" }}
{{- if not .authentication.useServiceAccount }}
{{- if and (empty .authentication.credentials) (empty .authentication.existingSecretName) }}
{{- fail "Credentials must be provided!\nCheck .stateStore.gcs.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -154,17 +148,14 @@ Validate parameters of OSS state store.
{{- with .Values.stateStore.oss }}
{{- if .enabled }}
{{- if empty .bucket }}
{{- fail "State store OSS bucket must be set" }}
{{- fail "Bucket .stateStore.oss.bucket must be set!" }}
{{- end }}
{{- if empty .region }}
{{- fail "State store OSS region must be set" }}
{{- fail "Region .stateStore.oss.region must be set!" }}
{{- end }}
{{- if and (empty .authentication.existingSecretName) (not .authentication.useServiceAccount) }}
{{- if empty .authentication.accessKey }}
{{- fail "State store OSS authentication access key must be set" }}
{{- end }}
{{- if empty .authentication.secretAccessKey }}
{{- fail "State store OSS authentication secret access key must be set" }}
{{- if not .authentication.useServiceAccount }}
{{- if and (empty .authentication.existingSecretName) (or (empty .authentication.accessKey) (empty .authentication.secretAccessKey)) }}
{{- fail "Either use ServiceAccount to provide credentials, or AccessKey/SecretAccessKey must be provided!\nCheck .stateStore.oss.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -176,17 +167,14 @@ Validate parameters of OBS state store.
{{- with .Values.stateStore.obs }}
{{- if .enabled }}
{{- if empty .bucket }}
{{- fail "State store OBS bucket must be set" }}
{{- fail "Bucket .stateStore.obs.bucket must be set!" }}
{{- end }}
{{- if empty .region }}
{{- fail "State store OBS region must be set" }}
{{- fail "Region .stateStore.obs.region must be set!" }}
{{- end }}
{{- if and (empty .authentication.existingSecretName) (not .authentication.useServiceAccount) }}
{{- if empty .authentication.accessKey }}
{{- fail "State store OBS authentication access key must be set" }}
{{- end }}
{{- if empty .authentication.secretAccessKey }}
{{- fail "State store OBS authentication secret access key must be set" }}
{{- if or (empty .authentication.accessKey) (empty .authentication.secretAccessKey) }}
{{- fail "Either use ServiceAccount to provide credentials, or AccessKey/SecretAccessKey must be provided!\nCheck .stateStore.obs.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -198,17 +186,14 @@ Validate parameters of AzureBlob state store.
{{- with .Values.stateStore.azblob }}
{{- if .enabled }}
{{- if empty .endpoint }}
{{- fail "State store AzureBlob endpoint must be set" }}
{{- fail "Endpoint .stateStore.azblob.endpoint must be set!" }}
{{- end }}
{{- if empty .container }}
{{- fail "State store AzureBlob container must be set" }}
{{- fail "Container .stateStore.azblob.container must be set!" }}
{{- end }}
{{- if and (empty .authentication.existingSecretName) (not .authentication.useServiceAccount) }}
{{- if empty .authentication.accountKey }}
{{- fail "State store AzureBlob authentication account key must be set" }}
{{- end }}
{{- if empty .authentication.accountName }}
{{- fail "State store AzureBlob authentication account name must be set" }}
{{- if or (empty .authentication.accountName) (empty .authentication.accountKey) }}
{{- fail "Either use ServiceAccount to provide credentials, or AccountName/AccountKey must be provided!\nCheck .stateStore.azblob.authentication for details!" }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
Loading

0 comments on commit e4cec63

Please sign in to comment.