/
st2_pkg_e2e_test.yaml
450 lines (442 loc) · 14.4 KB
/
st2_pkg_e2e_test.yaml
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
---
version: '1.0'
input:
- hostname
- dns_zone
- instance_type
- environment
- key_name
- keyfile
- windows_key_name
- windows_keyfile
- distro
- windows_distro
- role
- release
- version
- dev_build
- initial_commit
- enterprise
- enterprise_key
- pkg_env
- bootstrap_branch
- bootstrap_script
- triggering_commit_url
- debug
vars:
- webui_base_url: "https://st2cicd.uswest2.stackstorm.net"
- vm_id:
- vm_windows_id:
- vm_fqdn: <% ctx().hostname %>.<% ctx().dns_zone %>
- vm_info:
- windows_hostname: <% ctx().hostname %>win
- vm_windows_fqdn: <% ctx().hostname %>win.<% ctx().dns_zone %>
- installed:
distro:
versions:
version_str: not installed
- bootstrap_script_url: <% coalesce(ctx().bootstrap_script, "https://raw.githubusercontent.com/StackStorm/st2-packages/" + ctx().bootstrap_branch + "/scripts/st2_bootstrap.sh") %>
- st2_username: st2admin
- st2_password: Ch@ngeMe
- github_status_org: StackStorm
- github_status_repo: st2
- github_status_context: st2/e2e/<% ctx().distro.toLower() %><% ctx().enterprise and '-enterprise' or '' %>
- github_status_url: ''
- result: null
- destroy_vm_iteration_count: 0
- destroy_vm_windows_iteration_count: 0
- notify_channels:
- '#thunderdome'
- notify_failure_channels:
- '#thunderdome'
- '#stackstorm'
output:
- versions: <% ctx().installed.versions %>
tasks:
get_webui_server:
action: core.noop
next:
- when: <% succeeded() and (ctx().initial_commit != null) %>
publish:
- github_status_url: https://buildstatus.stackstorm.org/execution/<% ctx().st2.action_execution_id %>
do:
- notify_start
- set_github_status_pending
- when: <% succeeded() and (ctx().initial_commit = null) %>
publish:
- github_status_url: https://buildstatus.stackstorm.org/execution/<% ctx().st2.action_execution_id %>
do:
- notify_start
- create_vm
notify_start:
with:
items: channel in <% ctx().notify_channels %>
action: slack.chat.postMessage
input:
channel: <% item(channel) %>
text: 'st2ci.st2_pkg_e2e_test: STARTED'
attachments: "[{\"fallback\": \"[st2ci.st2_pkg_e2e_test: STARTED]\", \"title\": \"[st2ci.st2_pkg_e2e_test: STARTED]\", \"title_link\": \"<% ctx().webui_base_url %>/#/history/<% ctx('st2').action_execution_id %>/general\", \"text\": \"COMMIT: <% coalesce(ctx().triggering_commit_url, 'n/a') %>\\nHOSTNAME: <% ctx().vm_fqdn %>\\nDISTRO: <% ctx().distro %>\\nENTERPRISE: <% ctx().enterprise %>\\nRELEASE: <% ctx().pkg_env %> <% ctx().release %>\\nVERSION: <% coalesce(ctx().version, 'latest') %>\\nBOOTSTRAP: <% ctx().bootstrap_script_url %>\", \"color\": \"#808080\"}]"
set_github_status_pending:
action: github.add_status
input:
user: <% ctx().github_status_org %>
repo: <% ctx().github_status_repo %>
sha: <% ctx().initial_commit %>
state: pending
context: <% ctx().github_status_context %>
description: E2E tests are running...
target_url: <% ctx().github_status_url %>
next:
- when: <% succeeded() %>
do:
- create_vm
create_vm:
action: st2cd.create_vm_role
input:
hostname: <% ctx().hostname %>
instance_type: <% ctx().instance_type %>
environment: <% ctx().environment %>
key_name: <% ctx().key_name %>
keyfile: <% ctx().keyfile %>
dns_zone: <% ctx().dns_zone %>
distro: pkg_<% ctx().distro %>
role: <% ctx().role %>
next:
- when: <% succeeded() and (ctx().distro = 'RHEL6') %>
publish:
- vm_info: <% result().output.vm_info %>
- vm_id: <% result().output.vm_info.id %>
do:
- patch_rhel6
- when: <% succeeded() and (ctx().distro != 'RHEL6') %>
publish:
- vm_info: <% result().output.vm_info %>
- vm_id: <% result().output.vm_info.id %>
do:
- get_bootstrap_script
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
patch_rhel6:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: yum-config-manager --enable rhui-REGION-rhel-server-releases-optional
next:
- when: <% succeeded() %>
do:
- patch_rhel6_curl
patch_rhel6_curl:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: yum install -y curl nss
timeout: 180
next:
- when: <% succeeded() %>
do:
- get_bootstrap_script
get_bootstrap_script:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: curl -Ss -k -o /tmp/st2_bootstrap.sh <% ctx().bootstrap_script_url %>
next:
- when: <% succeeded() and (not ctx().dev_build) %>
do:
- run_bootstrap_script
- when: <% succeeded() and (ctx().dev_build) %>
do:
- run_bootstrap_script_dev
run_bootstrap_script:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: >-
bash /tmp/st2_bootstrap.sh
--<% ctx().pkg_env %>
--<% ctx().release %>
--version=<% coalesce(ctx().version, '') %>
--user=<% ctx().st2_username %>
--password=<% ctx().st2_password %>
timeout: 900
next:
- when: <% succeeded() and (ctx().enterprise) %>
do:
- upgrade_to_enterprise
- when: <% succeeded() and (not ctx().enterprise) %>
do:
- check_debug_mode
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
run_bootstrap_script_dev:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: >-
bash /tmp/st2_bootstrap.sh --dev=<% ctx().dev_build %>
--<% ctx().pkg_env %>
--<% ctx().release %>
--user=<% ctx().st2_username %>
--password=<% ctx().st2_password %>
timeout: 900
next:
- when: <% succeeded() and (ctx().enterprise) %>
do:
- upgrade_to_enterprise
- when: <% succeeded() and (not ctx().enterprise) %>
do:
- check_debug_mode
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
upgrade_to_enterprise:
action: st2cd.st2_upgrade_to_enterprise
input:
hosts: <% ctx().vm_info.private_ip_address %>
license_key: <% ctx().enterprise_key %>
distro: <% ctx().distro %>
pkg_env: <% ctx().pkg_env %>
release: <% ctx().release %>
version: <% coalesce(ctx().version, '') %>
timeout: 150
next:
- do:
- check_debug_mode
check_debug_mode:
action: core.noop
next:
- when: <% not ctx().debug %>
do:
- get_installed_version
- when: <% ctx().debug %>
do:
- enable_debug_mode
enable_debug_mode:
action: core.remote_sudo
input:
hosts: <% ctx().vm_info.private_ip_address %>
cmd: crudini --set /etc/st2/st2.conf system debug True && st2ctl restart
timeout: 120
next:
- do:
- get_installed_version
get_installed_version:
action: st2cd.st2_get_installed_version
input:
host: <% ctx().vm_info.private_ip_address %>
next:
- when: <% succeeded() %>
publish:
- installed:
distro: <% result().output.distro %>
versions: <% result().output.versions %>
version_str: <% result().output.versions.items().select( $[0] + "=" + $[1]).join("\n\t") %>
do:
- create_vm_windows
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
create_vm_windows:
action: st2cd.create_vm_windows
input:
hostname: <% ctx().windows_hostname %>
instance_type: <% ctx().instance_type %>
environment: <% ctx().environment %>
key_name: <% ctx().windows_key_name %>
keyfile: <% ctx().windows_keyfile %>
dns_zone: <% ctx().dns_zone %>
distro: <% ctx().windows_distro %>
role: <% ctx().role %>
next:
- when: <% succeeded() %>
publish:
- vm_windows_info: <% result().output.vm_info %>
- vm_windows_id: <% result().output.vm_info.id %>
- vm_windows_username: <% result().output.vm_username %>
- vm_windows_password: <% result().output.vm_password %>
do:
- run_e2e_tests
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
run_e2e_tests:
action: st2cd.st2_e2e_tests
input:
host_ip: <% ctx().vm_info.private_ip_address %>
host_fqdn: <% ctx().vm_fqdn %>
enterprise: <% ctx().enterprise %>
version: <% ctx().version %>
st2_username: <% ctx().st2_username %>
st2_password: <% ctx().st2_password %>
windows_host_ip: <% ctx().vm_windows_info.private_ip_address %>
windows_host_fqdn: <% ctx().vm_windows_fqdn %>
windows_username: <% ctx().vm_windows_username %>
windows_password: <% ctx().vm_windows_password %>
next:
- when: <% succeeded() %>
publish:
- result: success
do:
- cleanup
- when: <% failed() %>
publish:
- result: failed
do:
- cleanup
cleanup:
action: core.noop
next:
# Don't clean anything up if we need to debug
- when: <% ctx().debug %>
do:
- done_cleanup
- when: <% not ctx().debug %>
do:
- cleanup_vm
cleanup_vm:
action: core.noop
next:
- when: <% ctx().vm_id %>
do:
- destroy_vm
- when: <% not ctx().vm_id %>
do:
- cleanup_vm_windows
destroy_vm:
action: st2cd.destroy_vm
input:
hostname: <% ctx().hostname %>
instance_id: <% ctx().vm_id %>
next:
- when: <% succeeded() %>
publish:
- vm_id: null
do:
- cleanup_vm_windows
- when: <% failed() and (ctx().destroy_vm_iteration_count >= 2) %>
publish:
- result: failed
do:
- cleanup_vm_windows
- when: <% failed() and (ctx().destroy_vm_iteration_count < 2) %>
publish:
- destroy_vm_iteration_count: <% ctx().destroy_vm_iteration_count + 1 %>
do:
- sleep_destroy_vm
sleep_destroy_vm:
action: core.local
input:
cmd: sleep 30
next:
- when: <% succeeded() %>
do:
- destroy_vm
cleanup_vm_windows:
action: core.noop
next:
- when: <% ctx().vm_windows_id %>
do:
- destroy_vm_windows
- when: <% not ctx().vm_windows_id %>
do:
- done_cleanup
destroy_vm_windows:
action: st2cd.destroy_vm
input:
hostname: <% ctx().windows_hostname %>
instance_id: <% ctx().vm_windows_id %>
next:
- when: <% succeeded() %>
publish:
- vm_windows_id: null
do:
- done_cleanup
- when: <% failed() and (ctx().destroy_vm_windows_iteration_count >= 2) %>
publish:
- result: failed
do:
- done_cleanup
- when: <% failed() and (ctx().destroy_vm_windows_iteration_count < 2) %>
publish:
- destroy_vm_windows_iteration_count: <% ctx().destroy_vm_windows_iteration_count + 1 %>
do:
- sleep_destroy_vm_windows
sleep_destroy_vm_windows:
action: core.local
input:
cmd: sleep 30
next:
- when: <% succeeded() %>
do:
- destroy_vm_windows
done_cleanup:
action: core.noop
next:
- when: <% ctx().result = "success" %>
do:
- notify_success
- when: <% ctx().result = "failed" %>
do:
- notify_failure
notify_success:
with:
items: channel in <% ctx().notify_channels %>
action: slack.chat.postMessage
input:
channel: <% item(channel) %>
text: 'st2ci.st2_pkg_e2e_test: SUCCEEDED'
attachments: "[{\"fallback\": \"[st2ci.st2_pkg_e2e_test: SUCCEEDED]\", \"title\": \"[st2ci.st2_pkg_e2e_test: SUCCEEDED]\", \"title_link\": \"<% ctx().webui_base_url %>/#/history/<% ctx('st2').action_execution_id %>/general\", \"text\": \"COMMIT: <% coalesce(ctx().triggering_commit_url, 'n/a') %>\\nHOSTNAME: <% ctx().vm_fqdn %>\\nDISTRO: <% ctx().distro %>\\nENTERPRISE: <% ctx().enterprise %>\\nRELEASE: <% ctx().pkg_env %> <% ctx().release %>\\nVERSION: <% coalesce(ctx().version, 'latest') %>\\nVERSION INSTALLED:\\n\\t<% ctx().installed.version_str %>\\nBOOTSTRAP: <% ctx().bootstrap_script_url %>\", \"color\": \"#008000\"}]"
next:
- when: <% ctx().initial_commit %>
do:
- set_github_status_success
set_github_status_success:
action: github.add_status
input:
user: <% ctx().github_status_org %>
repo: <% ctx().github_status_repo %>
sha: <% ctx().initial_commit %>
state: success
context: <% ctx().github_status_context %>
description: E2E tests have finished successfully
target_url: <% ctx().github_status_url %>
notify_failure:
with:
items: channel in <% ctx().notify_failure_channels %>
action: slack.chat.postMessage
input:
channel: <% item(channel) %>
text: 'st2ci.st2_pkg_e2e_test: FAILED'
attachments: "[{\"fallback\": \"[st2ci.st2_pkg_e2e_test: FAILED]\", \"title\": \"[st2ci.st2_pkg_e2e_test: FAILED]\", \"title_link\": \"<% ctx().webui_base_url %>/#/history/<% ctx('st2').action_execution_id %>/general\", \"text\": \"COMMIT: <% coalesce(ctx().triggering_commit_url, 'n/a') %>\\nHOSTNAME: <% ctx().vm_fqdn %>\\nDISTRO: <% ctx().distro %>\\nENTERPRISE: <% ctx().enterprise %>\\nRELEASE: <% ctx().pkg_env %> <% ctx().release %>\\nVERSION: <% coalesce(ctx().version, 'latest') %>\\nVERSION INSTALLED:\\n\\t<% ctx().installed.version_str %>\\nBOOTSTRAP: <% ctx().bootstrap_script_url %>\", \"color\": \"#FF0000\"}]"
next:
- when: <% ctx().initial_commit %>
do:
- set_github_status_failure
- when: <% not ctx().initial_commit %>
do:
- fail
set_github_status_failure:
action: github.add_status
input:
user: <% ctx().github_status_org %>
repo: <% ctx().github_status_repo %>
sha: <% ctx().initial_commit %>
state: failure
context: <% ctx().github_status_context %>
description: E2E tests have failed
target_url: <% ctx().github_status_url %>
next:
- do:
- fail