Skip to content

Commit

Permalink
fix & test: enrich test cases and fix bug found (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar authored Mar 7, 2024
1 parent bb757ee commit e092b33
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 4 deletions.
11 changes: 8 additions & 3 deletions charts/risingwave/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@ metadata:
{{- if or $annotations .Values.service.annotations }}
annotations:
{{- if $annotations }}
{{ nindent 4 $annotations }}
{{- nindent 4 $annotations }}
{{- end }}
{{- if .Values.service.annotations }}
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{- range .Values.service.externalIPs }}
- {{ . }}
{{- end }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 2 }}
{{- range .Values.service.loadBalancerSourceRanges }}
- {{ . }}
{{- end }}
{{- end }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
sessionAffinity: {{ .Values.service.sessionAffinity }}
{{- if .Values.service.sessionAffinityConfig }}
sessionAffinityConfig: {{- toYaml .Values.service.sessionAffinityConfig | indent 4 }}
sessionAffinityConfig:
{{- toYaml .Values.service.sessionAffinityConfig | nindent 4 }}
{{- end }}
selector:
{{- include "risingwave.selectorLabels" . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/risingwave/templates/standalone/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ spec:
{{- end }}
{{- if .Values.metaStore.etcd.authentication.enabled }}
- secretRef:
name: {{- include "risingwave.etcdCredentialsSecretName" . }}
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
env:
# Disable auto region loading. Refer to the original source for more information.
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/azblob_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
73 changes: 73 additions & 0 deletions charts/risingwave/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
suite: Test config map
templates:
- templates/configmap.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: file should not render when using existing config map
set:
existingConfigMap: "CONFIG_MAP"
asserts:
- hasDocuments:
count: 0
- it: file should contain the config map
set:
configuration: |
[example]
a = b
asserts:
- containsDocument:
apiVersion: v1
kind: ConfigMap
- equal:
path: metadata.name
value: RELEASE-NAME-risingwave-configuration
- equal:
path: data
value:
risingwave.toml: |
[example]
a = b
- it: config map should contain the labels and annotations
set:
configuration: |
[example]
a = b
asserts:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
- notExists:
path: metadata.annotations
- it: config map should reflect the common labels and annotations
set:
commonLabels:
LABEL: LABEL_V
commonAnnotations:
ANNOTATION: ANNOTATION_V

configuration: |
[example]
a = b
asserts:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
5 changes: 5 additions & 0 deletions charts/risingwave/tests/etcd_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/gcs_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/minio_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/obs_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/oss_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
5 changes: 5 additions & 0 deletions charts/risingwave/tests/s3_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ tests:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
Expand Down
78 changes: 78 additions & 0 deletions charts/risingwave/tests/secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
suite: Test secret (authentication)
templates:
- templates/secret.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: file should always render
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
- equal:
path: metadata.name
value: RELEASE-NAME-risingwave
- it: secret should contains labels and annotations
asserts:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
- notExists:
path: metadata.annotations
- it: secret should reflect common labels and annotations
set:
commonLabels:
LABEL: LABEL_V
commonAnnotations:
ANNOTATION: ANNOTATION_V
asserts:
- isSubset:
path: metadata.labels
content:
helm.sh/chart: risingwave-0.0.1
app.kubernetes.io/name: risingwave
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: RELEASE-NAME
LABEL: LABEL_V
- exists:
path: metadata.annotations
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
- it: secret contains root user and random password by default
asserts:
- equal:
path: stringData.root-user
value: root
- equal:
path: stringData.root-password
value: ""
- notExists:
path: stringData.real-root-password
- it: secret must reflect root user and generate a random password for real root
set:
auth:
rootUser: ROOT_USER
rootPassword: ROOT_PASSWORD
asserts:
- equal:
path: stringData.root-user
value: ROOT_USER
- equal:
path: stringData.root-password
value: ROOT_PASSWORD
- exists:
path: stringData.real-root-password
- notEqual:
path: stringData.real-root-password
value: ""
Loading

0 comments on commit e092b33

Please sign in to comment.