-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathkitchen.yml
339 lines (330 loc) · 11 KB
/
kitchen.yml
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# NOTE: This test-kitchen file contains ERB code to cut-down on boilerplate;
# YAML linters will complain!
# yamllint disable
# spell-checker: disable
<%
require 'open3'
require 'json'
# Parse the outputs of the test harness
tf_output, rc = Open3.capture2('terraform -chdir=test/setup output -json')
if rc != 0
abort 'Failed to capture Terraform output from test/setup'
end
harness_outputs = JSON.parse(tf_output).map { |k,v| [k, v['value']] }.to_h
def tf_client(version)
full_version, rc = Open3.capture2("asdf latest terraform #{version}")
if rc != 0
abort "Failed to determine latest terraform version matching #{version}"
end
client, rc = Open3.capture2("asdf where terraform #{full_version.chomp}")
if rc != 0
abort "Failed to locate installed terraform #{full_version.chomp} command"
end
"#{client.chomp}/bin/terraform"
end
def hash_to_input_var(params)
"{#{params.map do |k, v|
case v
when nil
"\\\"#{k}\\\"=null"
when Hash
"\\\"#{k}\\\"=#{hash_to_input_var(v)}"
when Array
"\\\"#{k}\\\"=[#{v.map do |e|
case e
when nil
"null"
when Hash
hash_to_input_var(e)
when String
"\\\"#{e}\\\""
else
"#{e}"
end
end.join(',')}]"
when String
"\\\"#{k}\\\"=\\\"#{v}\\\""
else
"\\\"#{k}\\\"=#{v}"
end
end.join(',')}}"
end
tf_clients = [0.14, 0.15, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8].map{ |v| ["tf#{v}".sub(/\W/, "-"), tf_client(v)]}.to_h
regional_replication = harness_outputs['replication'].reject{|k,_| k == 'global'}
%>
---
driver:
name: terraform
verify_version: true
variables:
project_id: <%= harness_outputs['project_id'] %>
transport:
name: terraform
command_timeout: 60
provisioner:
name: terraform
verifier:
name: terraform
color: true
systems:
- name: secrets
backend: gcp
profile_locations:
- test/profiles/secrets
platforms:
<% tf_clients.each do |k,v| %>
- name: <%= k %>
transport:
client: <%= v %>
driver:
variables:
prefix: <%= "#{harness_outputs['prefix']}-#{k}" %>
<% end %>
suites:
- name: root-minimal
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-minimal
secret: terribleS3cr3t
- name: root-all
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-all
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
annotations: '<%= hash_to_input_var(harness_outputs['annotations']) %>'
labels: '<%= hash_to_input_var(harness_outputs['labels']) %>'
auto_replication_kms_key_name: '<%= harness_outputs['replication']['global']['kms_key_name'] %>'
replication: '<%= hash_to_input_var(regional_replication) %>'
secret: terribleS3cr3t
topics: '[\"<%= harness_outputs['topic'] %>\"]'
ttl_secs: '120'
- name: root-secret-null
transport:
root_module_directory: test/fixtures/root-secret-null
driver:
variables:
test_name: root-secret-null
- name: root-empty-secret
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-empty-secret
secret: ''
- name: root-replication
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-replication
replication: '<%= hash_to_input_var(regional_replication) %>'
secret: terribleS3cr3t
- name: root-replication-values-null
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-replication-values-null
replication: '<%= hash_to_input_var(regional_replication.map{|k,_| [k, nil]}.to_h) %>'
secret: terribleS3cr3t
- name: root-replication-keys-null
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-replication-keys-null
replication: '<%= hash_to_input_var(regional_replication.map{|k,_| [k, {'kms_key_name' => nil}]}.to_h) %>'
secret: terribleS3cr3t
- name: root-replication-keys-empty
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-replication-keys-empty
replication: '<%= hash_to_input_var(regional_replication.map{|k,_| [k, {'kms_key_name' => ''}]}.to_h) %>'
secret: terribleS3cr3t
- name: root-replication-null
transport:
root_module_directory: test/fixtures/root-replication-null
driver:
variables:
test_name: root-replication-null
secret: terribleS3cr3t
- name: root-auto-replication-key
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-auto-replication-key
secret: terribleS3cr3t
auto_replication_kms_key_name: '<%= harness_outputs['replication']['global']['kms_key_name'] %>'
- name: root-auto-replication-null
transport:
root_module_directory: test/fixtures/root-auto-replication-null
driver:
variables:
test_name: root-auto-replication-null
secret: terribleS3cr3t
- name: root-topics
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-topics
secret: terribleS3cr3t
topics: '[\"<%= harness_outputs['topic'] %>\"]'
- name: root-topics-null
transport:
root_module_directory: test/fixtures/root-topics-null
driver:
variables:
test_name: root-topics-null
secret: terribleS3cr3t
- name: root-accessors
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-accessors
secret: terribleS3cr3t
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
- name: root-accessors-null
transport:
root_module_directory: test/fixtures/root-accessors-null
driver:
variables:
test_name: root-accessors-null
secret: terribleS3cr3t
- name: root-annotations
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-annotations
secret: terribleS3cr3t
annotations: '<%= hash_to_input_var({'test.case' => 'root-accessors', 'long-key' => '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'}) %>'
- name: root-annotations-null
transport:
root_module_directory: test/fixtures/root-annotations-null
driver:
variables:
test_name: root-annotations-null
secret: terribleS3cr3t
- name: root-labels
transport:
root_module_directory: test/fixtures/root
driver:
variables:
test_name: root-labels
secret: terribleS3cr3t
labels: '<%= hash_to_input_var({'test_case' => 'root-accessors'}) %>'
- name: root-labels-null
transport:
root_module_directory: test/fixtures/root-labels-null
driver:
variables:
test_name: root-labels-null
secret: terribleS3cr3t
- name: example-accessors
transport:
root_module_directory: test/fixtures/examples/accessors
driver:
variables:
test_name: example-accessors
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
secret: terribleS3cr3t
- name: example-all-options
transport:
root_module_directory: test/fixtures/examples/all-options
driver:
variables:
test_name: example-all-options
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
annotations: '<%= hash_to_input_var(harness_outputs['annotations']) %>'
labels: '<%= hash_to_input_var(harness_outputs['labels']) %>'
replication: '<%= hash_to_input_var(regional_replication) %>'
secret: terribleS3cr3t
topics: '[\"<%= harness_outputs['topic'] %>\"]'
ttl_secs: '120'
- name: example-simple
transport:
root_module_directory: test/fixtures/examples/simple
driver:
variables:
test_name: example-simple
secret: terribleS3cr3t
- name: example-with-random-provider
transport:
root_module_directory: test/fixtures/examples/with-random-provider
driver:
variables:
test_name: example-with-random-provider
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
- name: example-user-managed-replication
transport:
root_module_directory: test/fixtures/examples/user-managed-replication
driver:
variables:
test_name: example-user-managed-replication
secret: terribleS3cr3t
replication: '<%= hash_to_input_var(regional_replication.map{|k,_| [k, nil]}.to_h) %>'
- name: example-user-managed-replication-accessors
transport:
root_module_directory: test/fixtures/examples/user-managed-replication-accessors
driver:
variables:
test_name: example-user-managed-replication-accessors
accessors: '[\"serviceAccount:<%= harness_outputs['service_account_email'] %>\"]'
secret: terribleS3cr3t
replication: '<%= hash_to_input_var(regional_replication.map{|k,_| [k, nil]}.to_h) %>'
- name: example-user-managed-replication-with-keys
transport:
root_module_directory: test/fixtures/examples/user-managed-replication-with-keys
driver:
variables:
test_name: example-user-managed-replication-with-keys
replication: '<%= hash_to_input_var(regional_replication) %>'
secret: terribleS3cr3t
- name: example-empty-secret-value
transport:
root_module_directory: test/fixtures/examples/empty-secret-value
driver:
variables:
test_name: example-empty-secret-value
- name: verify-issue-51
excludes:
- tf0-14
transport:
root_module_directory: test/fixtures/issue-51
driver:
variables:
test_name: issue-51
secret: terribleS3cr3t
- name: example-auto-replication-with-key
transport:
root_module_directory: test/fixtures/examples/auto-replication-with-key
driver:
variables:
test_name: example-auto-replication-with-key
auto_replication_kms_key_name: '<%= harness_outputs['replication']['global']['kms_key_name'] %>'
secret: terribleS3cr3t
- name: example-pubsub
transport:
root_module_directory: test/fixtures/examples/pubsub
driver:
variables:
test_name: example-pubsub
secret: terribleS3cr3t
topics: '[\"<%= harness_outputs['topic'] %>\"]'
- name: example-ttl
transport:
root_module_directory: test/fixtures/examples/ttl
driver:
variables:
test_name: example-ttl
secret: terribleS3cr3t
ttl_secs: '120'