Skip to content

Commit

Permalink
Added Helm unit tests (#15)
Browse files Browse the repository at this point in the history
* Updated GitHub Workflow

* Added initial unit tests

* Bumped chart version
  • Loading branch information
mway-niels committed Mar 14, 2024
1 parent 6de56ad commit 1ffd73b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
- name: Set up chart-testing
uses: helm/[email protected]

- name: Set up helm-unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest
- name: Install subchart dependencies
run: |
helm dependency build ./charts/relution
- name: Run chart-testing (list-changed)
id: list-changed
run: |
Expand All @@ -40,6 +48,10 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: Run helm-unittest
run: |
helm unittest ./charts/relution
- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion charts/relution/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ maintainers:

type: application

version: 2.2.5-3
version: 2.2.6-1

appVersion: "5.22.3"

Expand Down
45 changes: 45 additions & 0 deletions charts/relution/ci/full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ingress:
enabled: true
hosts:
- host: "test.relution.io"
paths:
- path: /
pathType: ImplementationSpecific

relution:
preRunScript: |
#!/bin/bash
echo "Prerun script ran." > /tmp/prerun.txt
config:
relution:
database:
type: mariadb
url: jdbc:mariadb://mariadb:3306/relution
username: relution
password: relution
environment:
RELUTION_SERVER_EXTERNALURL: https://test.relution.io
RELUTION_DATABASE_TYPE: mariadb
RELUTION_DATABASE_URL: jdbc:mariadb://mariadb:3306/relution
RELUTION_DATABASE_USERNAME: relution
secrets:
RELUTION_DATABASE_PASSWORD: relution

autoscaling:
enabled: true

heapDumpExporter:
enabled: true
s3:
bucket: s3://test-relution-io
awsAccessKeyId: relution
awsSecretAccessKey: relution

mariadb:
enabled: true
fullnameOverride: mariadb
auth:
rootPassword: relution
username: relution
password: relution
database: relution
11 changes: 11 additions & 0 deletions charts/relution/tests/config_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: test config
values:
- ../ci/minimal-values.yaml
templates:
- config.yaml
tests:
- it: should work
asserts:
- template: config.yaml
isKind:
of: ConfigMap
23 changes: 23 additions & 0 deletions charts/relution/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
suite: test deployment
values:
- ../ci/minimal-values.yaml
templates:
- deployment.yaml
- config.yaml
tests:
- it: should work
set:
image.tag: latest
imageMagick.enabled: false
asserts:
- template: deployment.yaml
isKind:
of: Deployment
- template: deployment.yaml
matchRegex:
path: metadata.name
pattern: -relution$
- template: deployment.yaml
equal:
path: spec.template.spec.containers[0].image
value: relution/relution:latest
21 changes: 21 additions & 0 deletions charts/relution/tests/ensure_helm_labels_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
suite: helm labels
values:
- ../ci/full.yaml
templates:
- "*.yaml"
tests:
- it: should contain default helm labels
set:
mariadb:
enabled: false
asserts:
- exists:
path: metadata.labels['helm.sh/chart']
- exists:
path: metadata.labels['app.kubernetes.io/version']
- exists:
path: metadata.labels['app.kubernetes.io/managed-by']
- exists:
path: metadata.labels['app.kubernetes.io/name']
- exists:
path: metadata.labels['app.kubernetes.io/instance']
11 changes: 11 additions & 0 deletions charts/relution/tests/environment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: test environment
values:
- ../ci/full.yaml
templates:
- environment.yaml
tests:
- it: should work
asserts:
- template: environment.yaml
isKind:
of: ConfigMap
11 changes: 11 additions & 0 deletions charts/relution/tests/secrets_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: test secrets
values:
- ../ci/full.yaml
templates:
- secrets.yaml
tests:
- it: should work
asserts:
- template: secrets.yaml
isKind:
of: Secret

0 comments on commit 1ffd73b

Please sign in to comment.