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: initiate unit tests and the PR workflow #28

Merged
merged 1 commit into from
Mar 4, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Charts

on:
pull_request:
branches:
- main
paths:
- 'charts/**'
push:
branches:
- main
paths:
- 'charts/**'
workflow_dispatch:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v3

- name: Install helm-unittests
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git

- name: Run Unit Tests
run: |
make test
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline at the end of the file (or make it consistent across all files)

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ Network Trash Folder
Temporary Items
.apdisk

.idea
.idea
**/.debug
**/__snapshot__
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ lint:
$(foreach chart,$(HELM_CHARTS),helm lint charts/$(chart);)
#$(foreach chart,$(INCUBATING_HELM_CHARTS),helm lint incubating/charts/$(chart);)

test:
$(foreach chart,$(HELM_CHARTS),helm unittest charts/$(chart);)

sync-crds:
./scripts/sync-crds.sh charts/risingwave-operator/crds
1 change: 1 addition & 0 deletions charts/risingwave-operator/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
.idea/
*.tmproj
.vscode/
tests
1 change: 1 addition & 0 deletions charts/risingwave/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
.idea/
*.tmproj
.vscode/
tests
4 changes: 2 additions & 2 deletions charts/risingwave/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ appVersion: v1.6.1

dependencies:
- name: etcd
version: "9.1.*"
version: "~9.14.3"
repository: https://charts.bitnami.com/bitnami
tags:
- etcd
- name: minio
version: "12.6.*"
version: "~13.7.0"
repository: https://charts.bitnami.com/bitnami
condition: stateStore.minio.enabled
tags:
Expand Down
97 changes: 97 additions & 0 deletions charts/risingwave/tests/azblob_secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
suite: Test azblob secret
templates:
- templates/azblob-secret.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: disabled azblob should not render secret
set:
stateStore:
azblob:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: azblob authenticating with service account should not render secret
set:
stateStore:
minio:
enabled: false
azblob:
enabled: true
authentication:
useServiceAccount: true
asserts:
- hasDocuments:
count: 0
- it: azblob authenticating with existing secret should not render secret
set:
stateStore:
minio:
enabled: false
azblob:
enabled: true
authentication:
useServiceAccount: false
existingSecretName: AZBLOB_SECRET
asserts:
- hasDocuments:
count: 0
- it: azblob authenticating with credentials should pass
set:
stateStore:
minio:
enabled: false
azblob:
enabled: true
authentication:
useServiceAccount: false
accountName: ACCOUNT_NAME
accountKey: ACCOUNT_KEY
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
- equal:
path: metadata.name
value: RELEASE-NAME-risingwave-azblob
- 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
- equal:
path: stringData
value:
AZBLOB_ACCOUNT_NAME: "ACCOUNT_NAME"
AZBLOB_ACCOUNT_KEY: "ACCOUNT_KEY"
- it: common labels and annotations should work
set:
commonLabels:
LABEL: LABEL_V
commonAnnotations:
ANNOTATION: ANNOTATION_V
stateStore:
minio:
enabled: false
azblob:
enabled: true
asserts:
- isSubset:
path: metadata.labels
content:
LABEL: LABEL_V
- exists:
path: metadata.annotations
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
83 changes: 83 additions & 0 deletions charts/risingwave/tests/etcd_secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
suite: Test etcd secret
templates:
- templates/etcd-secret.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: bundled etcd should not render secret
set:
tags.etcd: true
metaStore.etcd.authentication.enabled: true
asserts:
- hasDocuments:
count: 0
- it: external etcd without authentication should not render secret
set:
tags.etcd: false
metaStore.etcd.authentication.enabled: false
template: etcd-secret.yaml
asserts:
- hasDocuments:
count: 0
- it: external etcd with authentication should pass
set:
tags.etcd: false
metaStore:
etcd:
endpoints:
- external-etcd:1234
authentication:
enabled: true
username: USERNAME
password: PASSWORD
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
- equal:
path: metadata.name
value: RELEASE-NAME-risingwave-etcd
- 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
- equal:
path: stringData
value:
RW_ETCD_USERNAME: "USERNAME"
RW_ETCD_PASSWORD: "PASSWORD"
- it: external etcd with authentication contains common labels and annotations
set:
tags.etcd: false
commonLabels:
LABEL: LABEL_V
commonAnnotations:
ANNOTATION: ANNOTATION_V
metaStore:
etcd:
endpoints:
- external-etcd:1234
authentication:
enabled: true
username: USERNAME
password: PASSWORD
asserts:
- isSubset:
path: metadata.labels
content:
LABEL: LABEL_V
- exists:
path: metadata.annotations
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
95 changes: 95 additions & 0 deletions charts/risingwave/tests/gcs_secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
suite: Test gcs secret
templates:
- templates/gcs-secret.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: disabled gcs should not render secret
set:
stateStore:
gcs:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: gcs authenticating with service account should not render secret
set:
stateStore:
minio:
enabled: false
gcs:
enabled: true
authentication:
useServiceAccount: true
asserts:
- hasDocuments:
count: 0
- it: gcs authenticating with existing secret should not render secret
set:
stateStore:
minio:
enabled: false
gcs:
enabled: true
authentication:
useServiceAccount: false
existingSecretName: GCS_SECRET
asserts:
- hasDocuments:
count: 0
- it: gcs authenticating with credentials should pass
set:
stateStore:
minio:
enabled: false
gcs:
enabled: true
authentication:
useServiceAccount: false
credentials: CREDENTIALS
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
- equal:
path: metadata.name
value: RELEASE-NAME-risingwave-gcs
- 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
- equal:
path: stringData
value:
GOOGLE_APPLICATION_CREDENTIALS: "CREDENTIALS"
- it: common labels and annotations should work
set:
commonLabels:
LABEL: LABEL_V
commonAnnotations:
ANNOTATION: ANNOTATION_V
stateStore:
minio:
enabled: false
gcs:
enabled: true
asserts:
- isSubset:
path: metadata.labels
content:
LABEL: LABEL_V
- exists:
path: metadata.annotations
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
Loading
Loading