Skip to content

Commit

Permalink
[AMORO-2778][Helm Chart] Add Tests for Helm Chart (#2794)
Browse files Browse the repository at this point in the history
* [AMORO-2778] add Tests for Helm Charts

* Add Tests for Helm Chart Templates

* [AMORO-2778] add Tests for Helm Charts With Lisence

* [AMORO-2778][helm chart] fix syntax errors on test names, and add a workflow to run unittest when aubmit pr

* [AMORO2778] debug workflow

* [AMORO2778] debug workflow

* Update .github/workflows/pull-request-on-helmchat.yml

Co-authored-by: baiyangtx <xiangnebula@163.com>

* Update and rename pull-request-on-helmchat.yml to helm-charts-ci.yml

---------

Co-authored-by: baiyangtx <xiangnebula@163.com>
  • Loading branch information
lianneli and baiyangtx authored May 4, 2024
1 parent 568feca commit 75ac177
Show file tree
Hide file tree
Showing 11 changed files with 1,280 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/helm-charts-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


# This workflow will execute Tests when submit a PR.

name: "CI for Helm Charts"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths:
- 'charts/**'
push:
paths:
- 'charts/**'
merge_group:
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@v4

- name: Install helm-unittests
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
- name: Rebuild Chart with Dependency
run: |
cd charts/amoro
helm dependency build
- name: Run Unit Tests
run: |
helm unittest charts/amoro
3 changes: 2 additions & 1 deletion charts/amoro/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
*.tmproj
.vscode/
# test files
test-values.yaml
test-values.yaml
tests/
18 changes: 17 additions & 1 deletion charts/amoro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,20 @@ Configuration guide documentation for Amoro lives [on the website](https://amoro

## Contributing

Want to help build Amoro? Check out our [contributing documentation](https://amoro.apache.org/join-community/).
Want to help build Amoro? Check out our [contributing documentation](https://amoro.apache.org/join-community/).

### Unit Test

Helm Chart for Amoro supports Unit Tests by [helm-unittest](https://github.com/helm-unittest/helm-unittest). Before
submitting PRs, please let all the tests passed .

2 Steps for test. (Same as above,you should rebuild the charts/ first)

- Install `helm-unittest`
```shell
helm plugin install https://github.com/helm-unittest/helm-unittest.git
```
- Execute Tests.
```shell
helm unittest ../amoro
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}
labels:
app.kubernetes.io/name: amoro-database-secret
{{- include "amoro.labels" . | nindent 4 }}
type: Opaque
data:
Expand Down
123 changes: 123 additions & 0 deletions charts/amoro/tests/amoro-configmap_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


suite: Test Amoro ConfigMap
templates:
- amoro-configmap.yaml
chart:
appVersion: 0.1.0
version: 0.6.0
tests:
- it: Amoro ConfigMap should override name if set
set:
fullnameOverride: test
asserts:
- containsDocument:
kind: ConfigMap
apiVersion: v1
name: test
- hasDocuments:
count: 1
- it: Amoro configMap should reflect jvmOptions
set:
jvmOptions:
xms=8196
asserts:
- matchRegex:
path: data["jvm.properties"]
pattern:
|
xms=8196
- it: Amoro configMap should reflect ports
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
bind-port: 1260
- it: Amoro configMap should reflect database.username if type is set to mysql
set:
amoroConf:
database:
type: mysql
username: aaa
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
username: "aaa"
- it: Amoro configMap should reflect terminal iceberg params if terminal.backend is set to local
set:
amoroConf:
terminal:
backend: local
icebergHandleTimestampWithoutTimezone: true
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
local.spark.sql.iceberg.handle-timestamp-without-timezone: true
- it: Amoro configMap should show kyuubi url if terminal.backend is set to kyuubi
set:
amoroConf:
terminal:
backend: kyuubi
kyuubiJdbcUrl: jdbc:hive2://127.0.0.1:10009/
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
kyuubi.jdbc.url: "jdbc:hive2://127.0.0.1:10009/"
- it: Amoro configMap should show flink if flink optimizer enabled is set true
set:
optimizer:
flink:
enabled: true
name: flink1
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
- name: flink1
- it: Amoro configMap should show spark if spark optimizer enabled is set true
set:
optimizer:
spark:
enabled: true
name: spark1
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
- name: spark1
- it: Amoro configMap should show local if local optimizer enabled is set true
set:
optimizer:
local:
enabled: true
name: local1
asserts:
- matchRegex:
path: data["config.yaml"]
pattern:
|
- name: local1
86 changes: 86 additions & 0 deletions charts/amoro/tests/amoro-database-secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


suite: Test Amoro Database Secret
templates:
- amoro-database-secret.yaml
chart:
appVersion: 0.1.0
version: 0.6.0
tests:
- it: Amoro database secret should not exist if database type is set to derby
set:
amoroConf:
database:
type: derby
asserts:
- hasDocuments:
count: 0
- it: Amoro database secret should exist if database type is set to mysql
set:
fullnameOverride: test
amoroConf:
database:
type: mysql
username: "abc"
password: "123"
asserts:
- containsDocument:
kind: Secret
apiVersion: v1
name: test
- hasDocuments:
count: 1
- it: Amoro database secret should exist if database type is set to postgres
set:
fullnameOverride: test
amoroConf:
database:
type: postgres
username: "abc"
password: "123"
asserts:
- containsDocument:
kind: Secret
apiVersion: v1
name: test
- hasDocuments:
count: 1
- it: Amoro database secret should reflect username if database type is set to mysql
set:
amoroConf:
database:
type: mysql
username: "abc"
password: "123"
asserts:
- equal:
path: data.username
value: "abc"
decodeBase64: true
- it: Amoro database secret should reflect password if database type is set to mysql
set:
amoroConf:
database:
type: mysql
username: "abc"
password: "123"
asserts:
- equal:
path: data.password
value: "123"
decodeBase64: true
Loading

0 comments on commit 75ac177

Please sign in to comment.