-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathcommon_patterns_test.yaml
More file actions
204 lines (195 loc) · 6.38 KB
/
Copy pathcommon_patterns_test.yaml
File metadata and controls
204 lines (195 loc) · 6.38 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
# Common tests for Deployment charts - validates extraEnv, extraEnvFrom, resources
# This file is copied to each chart's tests/ directory by the Taskfile
# Required: each chart must have tests/fixtures/required.yaml with chart-specific values
suite: Test common deployment patterns
templates:
- templates/deployment.yaml
values:
- ../values.yaml
tests:
# ============================================================================
# extraEnv Tests
# ============================================================================
- it: should include extraEnv variables in container env
values:
- ./fixtures/required.yaml
set:
extraEnv:
TEST_EXTRA_ENV_VAR: "test-value-123"
TEST_EXTRA_ENV_FROM_FIELD:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
TEST_EXTRA_ENV_FROM_SECRET:
valueFrom:
secretKeyRef:
name: test-secret
key: test-key
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: TEST_EXTRA_ENV_VAR
value: "test-value-123"
- contains:
path: spec.template.spec.containers[0].env
content:
name: TEST_EXTRA_ENV_FROM_FIELD
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- contains:
path: spec.template.spec.containers[0].env
content:
name: TEST_EXTRA_ENV_FROM_SECRET
valueFrom:
secretKeyRef:
name: test-secret
key: test-key
# ============================================================================
# extraEnvFrom Tests
# ============================================================================
- it: should include extraEnvFrom references in container envFrom
values:
- ./fixtures/required.yaml
set:
extraEnvFrom:
- configMapRef:
name: test-config-map
- secretRef:
name: test-secret-ref
asserts:
- contains:
path: spec.template.spec.containers[0].envFrom
content:
configMapRef:
name: test-config-map
- contains:
path: spec.template.spec.containers[0].envFrom
content:
secretRef:
name: test-secret-ref
# ============================================================================
# Resources Tests
# ============================================================================
- it: should include resources when specified
values:
- ./fixtures/required.yaml
set:
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
asserts:
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: 500m
- equal:
path: spec.template.spec.containers[0].resources.limits.memory
value: 512Mi
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 100m
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 128Mi
- it: should not include resources when empty
values:
- ./fixtures/required.yaml
set:
resources: {}
asserts:
- notExists:
path: spec.template.spec.containers[0].resources
# ============================================================================
# topologySpreadConstraints Tests
# ============================================================================
- it: should include topologySpreadConstraints when specified
values:
- ./fixtures/required.yaml
set:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: test-app
asserts:
- equal:
path: spec.template.spec.topologySpreadConstraints[0].maxSkew
value: 1
- equal:
path: spec.template.spec.topologySpreadConstraints[0].topologyKey
value: kubernetes.io/hostname
- equal:
path: spec.template.spec.topologySpreadConstraints[0].whenUnsatisfiable
value: DoNotSchedule
- it: should not include topologySpreadConstraints when empty
values:
- ./fixtures/required.yaml
set:
topologySpreadConstraints: []
asserts:
- notExists:
path: spec.template.spec.topologySpreadConstraints
# ============================================================================
# Deployment Annotations Tests
# ============================================================================
- it: should include Deployment annotations when specified
values:
- ./fixtures/required.yaml
set:
annotations:
reloader.stakater.com/auto: "true"
custom.example.com/owner: "platform"
asserts:
- equal:
path: metadata.annotations["reloader.stakater.com/auto"]
value: "true"
- equal:
path: metadata.annotations["custom.example.com/owner"]
value: "platform"
- it: should not include Deployment annotations when empty
values:
- ./fixtures/required.yaml
set:
annotations: {}
asserts:
- notExists:
path: metadata.annotations
# ============================================================================
# Combined Test - All Common Patterns
# ============================================================================
- it: should correctly render all common patterns together
values:
- ./fixtures/required.yaml
set:
extraEnv:
TEST_COMBINED_VAR: "combined-test"
extraEnvFrom:
- configMapRef:
name: test-combined-configmap
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: TEST_COMBINED_VAR
value: "combined-test"
- contains:
path: spec.template.spec.containers[0].envFrom
content:
configMapRef:
name: test-combined-configmap
- isNotNull:
path: spec.template.spec.containers[0].resources