Skip to content

Commit 200bc94

Browse files
committed
document and reorganize integration and unit tests
1 parent 2d49682 commit 200bc94

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
- name: Run helm-unittest
4343
# by default looks for tests/*_test.yaml
4444
run: |
45-
helm unittest --color --helm3 .
45+
helm unittest --color --helm3 -f tests/unit/*_test.yaml .

templates/tests/st2tests-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ metadata:
1111
heritage: {{ .Release.Service }}
1212
data:
1313
st2tests.sh: |
14-
{{ .Files.Get "tests/st2tests.sh" | indent 4 }}
14+
{{ .Files.Get "tests/integration/st2tests.sh" | indent 4 }}

tests/README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
# `stackstorm-ha` Helm chart Tests
22

3-
This directory contains Helm chart tests, powered by [BATS](https://github.com/sstephenson/bats) Bash Automated Testing System.
3+
This directory contains Helm chart integration and unit tests (under `tests/integration/` and `tests/unit/` respectively).
4+
5+
## Unit tests
6+
7+
Unit tests (under `tests/unit/`) use [`helm-unittest`](https://github.com/quintush/helm-unittest).
8+
`helm-unittest` uses a yaml-based test file to ensure that the templates generate expected features.
9+
For example, they can ensure that custom annotations are applied consistently to all of the deployments.
10+
Unit tests do not require a running kubernetes cluster.
11+
12+
Before running unit tests, install the `helm-unittest` plugin and ensure you have sub-charts installed:
13+
```
14+
helm plugin install https://github.com/quintush/helm-unittest
15+
helm dependency update
16+
```
17+
18+
To run the tests manually from the chart's root dir:
19+
```
20+
helm unittest --helm3 tests/unit/*_test.yaml .
21+
```
22+
23+
Note that `helm-unittest` still defaults to helm 2, so you must pass `--helm3` or `-3` for short.
24+
You must also tell it where the unit tests are with `-f` because we keep unit tests in the `tests/unit` directory.
25+
26+
See https://github.com/quintush/helm-unittest/blob/master/DOCUMENT.md for details on writing unit tests.
27+
28+
## Integration tests
29+
30+
Integration tests (under `tests/integration/`) use `helm-test` and are powered by [BATS](https://github.com/sstephenson/bats) (Bash Automated Testing System).
31+
As integratin tests, these require a running kubernetes cluster where helm can do test deployments of this chart.
32+
433
Despite the minimum amount of smoke tests written, they ensure that StackStorm was really deployed,
534
works correctly at its core and alive end-to-end without checking deeply specific functionality or configuration.
635
If something is terribly wrong, - it'll show up via failed tests.
@@ -18,4 +47,4 @@ To show the test results:
1847
kubectl logs <release-name>-st2tests
1948
```
2049

21-
See https://helm.sh/docs/developing_charts/#chart-tests with more information about Helm chart tests.
50+
See https://helm.sh/docs/topics/chart-tests/ with more information about Helm chart tests.

0 commit comments

Comments
 (0)