-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from StackStorm/helm-unittest
Add helm-unittest
- Loading branch information
Showing
6 changed files
with
246 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
helm-unittest: | ||
|
||
runs-on: ubuntu-latest | ||
# strategy: | ||
# matrix: | ||
# Relevant tools installed by default on ubuntu 20.04: | ||
# - helm 3.8.0 | ||
# - jq 1.6 | ||
# - kind 0.11.1 | ||
# - kubectl 1.23.3 | ||
# - minikube 1.25.1 | ||
# - python 3.8.10 | ||
# - yamllint 1.26.3 | ||
# - yq 4.19.1 | ||
# see: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install helm-unittest | ||
# We should periodically check to see if another fork has taken over maintenance, | ||
# as the de-facto "best" fork has changed several times over the years. | ||
run: | | ||
helm plugin install https://github.com/quintush/helm-unittest | ||
- name: Install chart dependencies | ||
run: | | ||
helm dependency update | ||
- name: Run helm-unittest | ||
# by default looks for tests/*_test.yaml | ||
run: | | ||
helm unittest --color --helm3 -f tests/unit/*_test.yaml . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
--- | ||
suite: Custom Annotations | ||
templates: | ||
# primary template files | ||
- deployments.yaml | ||
- ingress.yaml | ||
- jobs.yaml | ||
- service-account.yaml | ||
- services.yaml | ||
|
||
# included templates must also be listed | ||
- configmaps_packs.yaml | ||
- configmaps_rbac.yaml | ||
- configmaps_st2-conf.yaml | ||
- configmaps_st2-urls.yaml | ||
- configmaps_st2web.yaml | ||
- secrets_datastore_crypto_key.yaml | ||
- secrets_ssh.yaml | ||
- secrets_st2apikeys.yaml | ||
- secrets_st2auth.yaml | ||
- secrets_st2chatops.yaml | ||
|
||
tests: | ||
- it: ServiceAccount accepts custom annotations | ||
template: service-account.yaml | ||
set: | ||
serviceAccount: | ||
create: true | ||
serviceAccountAnnotations: &annotations | ||
foo: bar | ||
answer: "42" | ||
asserts: &annotations_asserts | ||
- isNotNull: | ||
path: metadata.annotations | ||
- equal: | ||
path: metadata.annotations.foo | ||
value: bar | ||
- equal: | ||
path: metadata.annotations.answer | ||
value: "42" | ||
|
||
- it: st2web Ingress accepts custom annotations | ||
template: ingress.yaml | ||
set: | ||
st2web: | ||
service: | ||
hostname: some-host-name | ||
ingress: | ||
enabled: true | ||
annotations: *annotations | ||
asserts: *annotations_asserts | ||
|
||
# st2auth, st2api, st2stream services do not accept custom annotations | ||
|
||
- it: st2web Service accepts custom annotations | ||
template: services.yaml | ||
documentIndex: 3 | ||
set: | ||
st2web: | ||
service: | ||
hostname: some-host-name | ||
annotations: *annotations | ||
asserts: *annotations_asserts | ||
|
||
# st2chatops service does not accept custom annotations | ||
|
||
- it: Deployments+Pods accept custom annotations | ||
template: deployments.yaml | ||
set: | ||
st2auth: | ||
annotations: &deployment_annotations | ||
foo: bar | ||
answer: "42" | ||
st2api: | ||
annotations: *deployment_annotations | ||
st2stream: | ||
annotations: *deployment_annotations | ||
st2web: | ||
annotations: *deployment_annotations | ||
st2rulesengine: | ||
annotations: *deployment_annotations | ||
st2timersengine: | ||
annotations: *deployment_annotations | ||
st2workflowengine: | ||
annotations: *deployment_annotations | ||
st2scheduler: | ||
annotations: *deployment_annotations | ||
st2notifier: | ||
annotations: *deployment_annotations | ||
st2sensorcontainer: | ||
annotations: *deployment_annotations | ||
st2: { packs: { sensors: [] } } # ensure only 1 sensor | ||
st2actionrunner: | ||
annotations: *deployment_annotations | ||
st2garbagecollector: | ||
annotations: *deployment_annotations | ||
st2client: | ||
annotations: *deployment_annotations | ||
st2chatops: | ||
enabled: true | ||
annotations: *deployment_annotations | ||
asserts: | ||
- hasDocuments: | ||
count: 14 | ||
# st2auth, st2api, | ||
# st2stream, st2web, | ||
# st2rulesengine, st2timersengine, | ||
# st2workflowengine, st2scheduler, | ||
# st2notifier, (1) st2sensorcontainer, | ||
# st2actionrunner, st2garbagecollector, | ||
# st2client, st2chatops | ||
|
||
# deployment annotations | ||
- isNotNull: | ||
path: metadata.annotations | ||
- equal: | ||
path: metadata.annotations.foo | ||
value: bar | ||
- equal: | ||
path: metadata.annotations.answer | ||
value: "42" | ||
|
||
# pod annotations | ||
- isNotNull: | ||
path: spec.template.metadata.annotations | ||
- equal: | ||
path: spec.template.metadata.annotations.foo | ||
value: bar | ||
- equal: | ||
path: spec.template.metadata.annotations.answer | ||
value: "42" | ||
|
||
- it: Jobs+Pods accept custom annotations | ||
template: jobs.yaml | ||
set: | ||
st2: | ||
rbac: | ||
enabled: true # enable rbac job | ||
jobs: | ||
annotations: | ||
foo: bar | ||
answer: "42" | ||
asserts: | ||
- hasDocuments: | ||
count: 4 | ||
# job-st2-apply-rbac-defintions | ||
# job-st2-apikey-load | ||
# job-st2-key-load | ||
# job-st2-register-content | ||
|
||
# job annotations | ||
- isNotNull: | ||
path: metadata.annotations | ||
- equal: | ||
path: metadata.annotations.foo | ||
value: bar | ||
- equal: | ||
path: metadata.annotations.answer | ||
value: "42" | ||
|
||
# pod annotations | ||
- isNotNull: | ||
path: spec.template.metadata.annotations | ||
- equal: | ||
path: spec.template.metadata.annotations.foo | ||
value: bar | ||
- equal: | ||
path: spec.template.metadata.annotations.answer | ||
value: "42" |