-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbasic_test.yaml
More file actions
207 lines (191 loc) · 5.25 KB
/
basic_test.yaml
File metadata and controls
207 lines (191 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
suite: test basic chart functionality
templates:
- deployment.yaml
- service.yaml
- serviceaccount.yaml
- config.yaml
- pvc.yaml
tests:
- it: should render with default values
values:
- ../values.lint.yaml
asserts:
# Test that deployment is created
- hasDocuments:
count: 1
template: deployment.yaml
- isKind:
of: Deployment
template: deployment.yaml
# Test that service is created
- hasDocuments:
count: 1
template: service.yaml
- isKind:
of: Service
template: service.yaml
# Test that serviceaccount is created
- hasDocuments:
count: 1
template: serviceaccount.yaml
- isKind:
of: ServiceAccount
template: serviceaccount.yaml
# Test that configmap is created
- hasDocuments:
count: 1
template: config.yaml
- isKind:
of: ConfigMap
template: config.yaml
# Test that PVC is created (persistence enabled by default)
- hasDocuments:
count: 1
template: pvc.yaml
- isKind:
of: PersistentVolumeClaim
template: pvc.yaml
- it: should set correct app labels
values:
- ../values.lint.yaml
asserts:
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: sourcebot
template: deployment.yaml
- equal:
path: metadata.labels["app.kubernetes.io/instance"]
value: RELEASE-NAME
template: deployment.yaml
- equal:
path: metadata.labels["app.kubernetes.io/managed-by"]
value: Helm
template: deployment.yaml
- it: should include root additional labels
values:
- ../values.lint.yaml
set:
additionalLabels.component: sourcebot
asserts:
- equal:
path: metadata.labels.component
value: sourcebot
template: deployment.yaml
- it: should include sourcebot additional labels
values:
- ../values.lint.yaml
set:
sourcebot.additionalLabels.component: sourcebot
asserts:
- equal:
path: metadata.labels.component
value: sourcebot
template: deployment.yaml
- it: should use correct image when tag is specified
values:
- ../values.lint.yaml
set:
sourcebot.image.tag: "v1.2.3"
asserts:
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "ghcr.io/sourcebot-dev/sourcebot:v1.2.3$"
template: deployment.yaml
- it: should use digest when specified
values:
- ../values.lint.yaml
set:
sourcebot.image.digest: "sha256:abcdef123456"
asserts:
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "ghcr.io/sourcebot-dev/sourcebot@sha256:abcdef123456$"
template: deployment.yaml
- it: should set replica count
values:
- ../values.lint.yaml
set:
sourcebot.replicaCount: 3
asserts:
- equal:
path: spec.replicas
value: 3
template: deployment.yaml
- it: should mount persistence volume when enabled
values:
- ../values.lint.yaml
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: sourcebot-data
persistentVolumeClaim:
claimName: RELEASE-NAME-sourcebot-data
template: deployment.yaml
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: sourcebot-data
mountPath: /data
template: deployment.yaml
- it: should not create PVC when persistence is disabled
values:
- ../values.lint.yaml
set:
sourcebot.persistence.enabled: false
asserts:
- hasDocuments:
count: 0
template: pvc.yaml
- it: should not mount volume when persistence is disabled
values:
- ../values.lint.yaml
set:
sourcebot.persistence.enabled: false
asserts:
- notContains:
path: spec.template.spec.volumes
content:
name: sourcebot-data
template: deployment.yaml
- it: should use existingClaim when specified
values:
- ../values.lint.yaml
set:
sourcebot.persistence.existingClaim: "my-existing-pvc"
asserts:
# PVC should not be created
- hasDocuments:
count: 0
template: pvc.yaml
# But volume should reference the existing claim
- contains:
path: spec.template.spec.volumes
content:
name: sourcebot-data
persistentVolumeClaim:
claimName: my-existing-pvc
template: deployment.yaml
- it: should set service type correctly
values:
- ../values.lint.yaml
set:
sourcebot.service.type: "LoadBalancer"
asserts:
- equal:
path: spec.type
value: LoadBalancer
template: service.yaml
- it: should include config in configmap
values:
- ../values.lint.yaml
set:
sourcebot.config:
$schema: "https://example.com/schema.json"
connections:
test:
type: github
asserts:
- isNotEmpty:
path: data["config.json"]
template: config.yaml