Skip to content

Commit 879c81c

Browse files
krichter722Torsten Walter
and
Torsten Walter
authored
[alertmanager] Unit test sample for ingress version (prometheus-community#1149)
* Unit test sample for ingress version in alertmanager Signed-off-by: Karl-Philipp Richter <[email protected]> * Activate execution of unit tests in githooks Signed-off-by: Karl-Philipp Richter <[email protected]> * More compatible helm plugin URL in lint-test.yaml Signed-off-by: Karl-Philipp Richter <[email protected]> * Combine file patterns in order to avoid confusing output Co-authored-by: Torsten Walter <[email protected]> Signed-off-by: Karl-Philipp Richter <[email protected]> * Adjust to directory unittests Signed-off-by: Karl-Philipp Richter <[email protected]> Co-authored-by: Torsten Walter <[email protected]>
1 parent 920d2c4 commit 879c81c

File tree

6 files changed

+69
-1
lines changed

6 files changed

+69
-1
lines changed

.github/workflows/lint-test.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
if [[ -n "$changed" ]]; then
2727
echo "::set-output name=changed::true"
2828
fi
29+
- name: install helm unittest plugin
30+
if: steps.list-changed.outputs.changed == 'true'
31+
run: |
32+
helm env
33+
helm plugin install https://github.com/quintush/helm-unittest.git --version 0.2.6
2934
- name: Run chart-testing (lint)
3035
run: ct lint --config ct.yaml
3136
- name: Create kind cluster

charts/alertmanager/.helmignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
.idea/
2222
*.tmproj
2323
.vscode/
24+
25+
unittests/

charts/alertmanager/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/a
66
sources:
77
- https://github.com/prometheus/alertmanager
88
type: application
9-
version: 0.12.1
9+
version: 0.12.2
1010
appVersion: v0.22.1
1111
maintainers:
1212
- name: monotek
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
should match snapshot of default values:
2+
1: |
3+
apiVersion: networking.k8s.io/v1beta1
4+
kind: Ingress
5+
metadata:
6+
labels:
7+
app.kubernetes.io/instance: RELEASE-NAME
8+
app.kubernetes.io/managed-by: Helm
9+
app.kubernetes.io/name: alertmanager
10+
app.kubernetes.io/version: 1.0.0
11+
helm.sh/chart: alertmanager-1.0.0
12+
name: RELEASE-NAME-alertmanager
13+
spec:
14+
rules:
15+
- host: alertmanager.domain.com
16+
http:
17+
paths: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
suite: test ingress
2+
templates:
3+
- ingress.yaml
4+
tests:
5+
- it: should be empty if ingress is not enabled
6+
asserts:
7+
- hasDocuments:
8+
count: 0
9+
- it: should have apiVersion extensions/v1beta1 for k8s < 1.14
10+
set:
11+
ingress.enabled: true
12+
capabilities:
13+
majorVersion: 1
14+
minorVersion: 13
15+
asserts:
16+
- hasDocuments:
17+
count: 1
18+
- isKind:
19+
of: Ingress
20+
- isAPIVersion:
21+
of: extensions/v1beta1
22+
- it: should have apiVersion networking.k8s.io/v1beta1 for k8s >= 1.14 < 1.19
23+
set:
24+
ingress.enabled: true
25+
capabilities:
26+
majorVersion: 1
27+
minorVersion: 15
28+
asserts:
29+
- hasDocuments:
30+
count: 1
31+
- isKind:
32+
of: Ingress
33+
- isAPIVersion:
34+
of: networking.k8s.io/v1beta1
35+
- it: should match snapshot of default values
36+
set:
37+
ingress.enabled: true
38+
chart:
39+
version: 1.0.0
40+
appVersion: 1.0.0
41+
asserts:
42+
- matchSnapshot: { }

ct.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ helm-extra-args: --timeout 600s
1111
excluded-charts:
1212
# If not running on GCE, will error: "Failed to get GCE config"
1313
- prometheus-to-sd
14+
additional-commands:
15+
- helm unittest --helm3 --strict --file unittests/*.yaml --file 'unittests/**/*.yaml' {{ .Path }}

0 commit comments

Comments
 (0)