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

[AMORO-2778][Helm Chart] Add Tests for Helm Chart #2794

Merged
merged 13 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

please let all tests passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

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 set type 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 set terminal 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 set terminal 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
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
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
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 when database type set to derby
Copy link
Contributor

Choose a reason for hiding this comment

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

when database type is set to derby

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

set:
amoroConf:
database:
type: derby
asserts:
- hasDocuments:
count: 0
- it: Amoro database secret should exist when database type set to mysql
Copy link
Contributor

Choose a reason for hiding this comment

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

when database type is set to mysql

Copy link
Contributor

Choose a reason for hiding this comment

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

Some similar contents in this file can be changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

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 when database type 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 when database type 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 when database type set to mysql
set:
amoroConf:
database:
type: mysql
username: "abc"
password: "123"
asserts:
- equal:
path: data.password
value: "123"
decodeBase64: true
Loading
Loading