-
Notifications
You must be signed in to change notification settings - Fork 8
375 lines (364 loc) · 15.6 KB
/
integ-test.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
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
name: integ-test
on:
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
inputs:
integ_tests_include:
type: string
description: |-
List integration tests to include.
Use "*" to run all tests.
Use regex like 'node|^git_issue' to run only a subset.
default: "*"
# dns_config|time_server - NTP cannot be reconfigured if DNS is invalid
# git_issues - slow, do not run on each push. TODO - run them only once a day
# oidc_config - during reconfiguration API returns 500/502 errors for other requests
# utils_login - it uses OIDC user to login
# smtp - email_alert test requires a configured SMTP
# role_cluster_config - role cluster_config reconfigures DNS, SMTP, OIDC. And it is slow.
# version_update_single_node - role would change version, VSNS system cannot be updated.
# vm_replication vm_clone__replicated - VSNS were not configured with replication
integ_tests_exclude:
type: string
description: |-
List integration tests to exclude.
Use "*" to exclude all tests.
Use regex like 'node|^git_issue|^dns_config$' to exclude only a subset.
default: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$|^version_update__shutdown_restart_vms$|^utils_login$|^certificate$|^vm_replication$|^vm_replication_info$|^vm_clone__replicated$|^support_tunnel$"
integ_seq_tests_include:
type: string
description: |-
List seq integration tests to include.
# We want to run sequentially all tests that cannot run in parallel (e.g. all that listed in integ_tests_exclude).
# Some tests can be tested on VSNS - those are run on VSNS.
# Some cannot, those are run on test cluster 10.5.11.50.
# Some cannot be tested at all - shutdown and version update.
default: "^dns_config$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update__shutdown_restart_vms$|^utils_login$|^certificate$"
integ_seq_tests_exclude:
type: string
description: |-
List seq integration tests to exclude.
default: ""
examples_tests_include:
type: string
description: |-
List examples to include into testing.
Use "*" to test all examples.
default: "iso_info"
examples_tests_exclude:
type: string
description: |-
List examples to exclude from testing.
default: "^version_update_single_node.yml$|^vm_os_upgrade$|^vm_snapshot_attach_disk.yml$|^url2template$"
env:
INTEG_TESTS_INCLUDE_SCHEDULE: "*"
INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$|^version_update__shutdown_restart_vms$|^utils_login$|^certificate$|^vm_replication$|^vm_replication_info$|^vm_clone__replicated$|^support_tunnel$"
INTEG_SEQ_TESTS_INCLUDE_SCHEDULE: "^dns_config$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update__shutdown_restart_vms$|^utils_login$|^certificate$"
INTEG_SEQ_TESTS_EXCLUDE_SCHEDULE: ""
EXAMPLES_TESTS_INCLUDE_SCHEDULE: "*"
EXAMPLES_TESTS_EXCLUDE_SCHEDULE: "^version_update_single_node.yml$|^vm_os_upgrade$|^vm_snapshot_attach_disk.yml$|^url2template$"
# ansible-test needs special directory structure.
# WORKDIR is a subdir of GITHUB_WORKSPACE
WORKDIR: work-dir/ansible_collections/scale_computing/hypercore
LANG: C.UTF-8
# Run only one workflow for specific branch.
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
# This should be run at least once before first integration tests run.
# As long as prepared HC3 host remains prepared, we do not need (except on very first run)
# to delay integ-test until integration-prepare-env finishes.
integration-prepare-env:
runs-on: [self-hosted2]
container: quay.io/justinc1_github/scale_ci_integ:10
env:
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
defaults:
run:
working-directory: ${{ env.WORKDIR }}
strategy:
fail-fast: false
matrix:
sc_host:
- https://10.5.11.200 # HC 9.1.x
- https://10.5.11.201 # HC 9.2.x
- https://10.5.11.203 # HC 9.3.x
- https://10.5.11.205 # HC 9.4.x
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
- run: ansible-galaxy collection install community.crypto community.general
- run: ansible-galaxy collection list
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
with:
sc_host: ${{ matrix.sc_host }}
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
oidc_users_0_password: ${{ secrets.OIDC_USERS_0_PASSWORD }}
working_directory: ${{ env.WORKDIR }}
- run: ansible-playbook tests/integration/prepare/prepare_iso.yml
- run: ansible-playbook tests/integration/prepare/prepare_vm.yml
- run: ansible-playbook tests/integration/prepare/prepare_examples.yml
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"
integ-matrix:
runs-on: [ubuntu-latest]
container: quay.io/justinc1_github/scale_ci_integ:10
defaults:
run:
working-directory: ${{ env.WORKDIR }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
# We want to run all integ tests periodically - "integ_tests_include || '*'", the '*' is used.
# When running with workflow-dispatch, user is required to put some non-empty string into integ_tests_include.
- run: echo 'INTEG_TESTS_INCLUDE=${{ github.event.inputs.integ_tests_include || env.INTEG_TESTS_INCLUDE_SCHEDULE }}' >> $GITHUB_ENV
- run: echo 'INTEG_TESTS_EXCLUDE=${{ github.event.inputs.integ_tests_exclude || env.INTEG_TESTS_EXCLUDE_SCHEDULE }}' >> $GITHUB_ENV
- id: set-matrix
shell: bash
run: |-
echo "matrix=$(
ls -r tests/integration/targets |
grep -v -E "${{ env.INTEG_TESTS_EXCLUDE || '^dummy-no-such-test$' }}" |
grep -E "${{ env.INTEG_TESTS_INCLUDE }}" |
jq -R -s -c 'split("\n")[:-1]'
)" >> $GITHUB_OUTPUT
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"
integ-seq-matrix:
needs:
- integ-matrix
runs-on: [ubuntu-latest]
container: quay.io/justinc1_github/scale_ci_integ:10
defaults:
run:
working-directory: ${{ env.WORKDIR }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
- run: echo 'INTEG_SEQ_TESTS_INCLUDE=${{ github.event.inputs.integ_seq_tests_include || env.INTEG_SEQ_TESTS_INCLUDE_SCHEDULE }}' >> $GITHUB_ENV
- run: echo 'INTEG_SEQ_TESTS_EXCLUDE=${{ github.event.inputs.integ_seq_tests_exclude || env.INTEG_SEQ_TESTS_EXCLUDE_SCHEDULE }}' >> $GITHUB_ENV
- id: set-matrix
shell: bash
run: |-
echo "matrix=$(
ls -r tests/integration/targets |
grep -v -E "${{ env.INTEG_SEQ_TESTS_EXCLUDE || '^dummy-no-such-test$' }}" |
grep -E "${{ env.INTEG_SEQ_TESTS_INCLUDE }}" |
jq -R -s -c 'split("\n")[:-1]'
)" >> $GITHUB_OUTPUT
if: "${{ github.event.inputs.integ_seq_tests_include || github.event.schedule }}"
examples-matrix:
needs:
- integ-seq-matrix
runs-on: [ ubuntu-latest ]
container: quay.io/justinc1_github/scale_ci_integ:10
defaults:
run:
working-directory: ${{ env.WORKDIR }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
- run: echo 'EXAMPLES_TESTS_INCLUDE=${{ github.event.inputs.examples_tests_include || env.EXAMPLES_TESTS_INCLUDE_SCHEDULE }}' >> $GITHUB_ENV
- run: echo 'EXAMPLES_TESTS_EXCLUDE=${{ github.event.inputs.examples_tests_exclude || env.EXAMPLES_TESTS_EXCLUDE_SCHEDULE }}' >> $GITHUB_ENV
# A few files are not an example playbook:
# hypercore_inventory.yml - inventory example
# cloud-init-user-data-example.yml - cloud-init user-data example
- id: set-matrix
shell: bash
run: |-
echo "matrix=$(
ls -r examples |
grep -v -E "^README.md$|^hypercore_inventory.yml$|^cloud-init-user-data-example.yml$" |
grep -v -E "${{ env.EXAMPLES_TESTS_EXCLUDE || '^dummy-no-such-example$' }}" |
grep -E "${{ env.EXAMPLES_TESTS_INCLUDE }}" |
jq -R -s -c 'split("\n")[:-1]'
)" >> $GITHUB_OUTPUT
if: "${{ github.event.inputs || github.event.schedule }}"
examples-run:
needs:
- examples-matrix
# run examples after integ - they will both try to modify say syslog_server etc
- integ-seq-run
if: "(!cancelled()) && (needs.examples-matrix.result=='success')"
runs-on: [ self-hosted2 ]
container: quay.io/justinc1_github/scale_ci_integ:10
env:
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
DEBIAN_FRONTEND: noninteractive
defaults:
run:
working-directory: ${{ env.WORKDIR }}
strategy:
fail-fast: false
matrix:
ansible: [ 2.16.0 ]
example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
- name: SKIP test if it succeeded before
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
X_GITHUB_JOB_NAME: "examples-run (${{ matrix.ansible }}, ${{ matrix.example_name }})"
run: |
if ! .github/job_retry_needed.py
then
echo SKIP test, job retry not needed
echo 'X_GITHUB_SKIP_TEST=1' >> $GITHUB_ENV
else
echo 'X_GITHUB_SKIP_TEST=0' >> $GITHUB_ENV
fi
- name: Install prerequisites
shell: bash
run: |
[ "$X_GITHUB_SKIP_TEST" == "1" ] && exit 0
pip install ansible-core~=${{ matrix.ansible }}
ansible-galaxy collection install community.crypto community.general
ansible-galaxy collection list
# ${{ env.WORKDIR }} cannot be used in "uses:"
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
with:
sc_host: https://10.5.11.205
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
oidc_users_0_password: ${{ secrets.OIDC_USERS_0_PASSWORD }}
working_directory: ${{ env.WORKDIR }}
- name: Debug test config
shell: bash
run: |
pwd
ls -al tests/integration/integration_config.yml
head tests/integration/integration_config.yml
- name: Run test
shell: bash
run: |
[ "$X_GITHUB_SKIP_TEST" == "1" ] && exit 0
eval export SC_HOST=$(cat tests/integration/integration_config.yml | yq '.sc_host')
eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_config."https://10.5.11.200".sc_username')
eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_config."https://10.5.11.200".sc_password')
eval export SC_TIMEOUT=$(cat tests/integration/integration_config.yml | yq '.sc_timeout')
ansible-playbook -i localhost, -e hypercore_example_check_mode=true examples/${{ matrix.example_name }}
integ-run:
needs:
- integ-matrix
if: "(!cancelled()) && (needs.integ-matrix.result=='success')"
strategy:
fail-fast: false
matrix:
sc_host:
- https://10.5.11.200
- https://10.5.11.201
- https://10.5.11.203
- https://10.5.11.205
secrets: inherit
uses: ./.github/workflows/z_ansible-test.yml
with:
sc_host: ${{ matrix.sc_host }}
test_names: ${{ needs.integ-matrix.outputs.matrix }}
outer_job_name: integ-run
integ-seq-run:
needs:
- integ-seq-matrix
- integ-run
if: "(!cancelled()) && (needs.integ-seq-matrix.result=='success')"
strategy:
fail-fast: false
matrix:
sc_host:
- https://10.5.11.200
- https://10.5.11.201
- https://10.5.11.203
- https://10.5.11.205
secrets: inherit
uses: ./.github/workflows/z_ansible-test.yml
with:
sc_host: ${{ matrix.sc_host }}
test_names: ${{ needs.integ-seq-matrix.outputs.matrix }}
outer_job_name: integ-seq-run
# On physical HyperCore
integ-physical:
secrets: inherit
uses: ./.github/workflows/z_ansible-test.yml
with:
sc_host: https://10.5.11.50
test_names: >-
[
"vm_replication",
'vm_replication_info",
"vm_clone__replicated",
"support_tunnel"
]
outer_job_name: integ-physical
replica_cleanup:
needs: []
runs-on: [self-hosted2]
container: quay.io/justinc1_github/scale_ci_integ:10
env:
ANSIBLE_COLLECTIONS_PATH: $GITHUB_WORKSPACE/work-dir
defaults:
run:
working-directory: ${{ env.WORKDIR }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
- run: pip install ansible-core~=2.16.0
# ${{ env.WORKDIR }} cannot be used
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
with:
sc_host: https://10.5.11.50
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
oidc_users_0_password: ${{ secrets.OIDC_USERS_0_PASSWORD }}
working_directory: ${{ env.WORKDIR }}
- run: ansible-galaxy collection install community.general
- run: ansible-playbook tests/integration/cleanup/ci_replica_cleanup.yml
smb_cleanup:
needs: []
runs-on: [self-hosted2]
container: quay.io/justinc1_github/scale_ci_integ:10
defaults:
run:
working-directory: ${{ env.WORKDIR }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
# ${{ env.WORKDIR }} cannot be used
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
with:
sc_host: https://10.5.11.200
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
oidc_users_0_password: ${{ secrets.OIDC_USERS_0_PASSWORD }}
working_directory: ${{ env.WORKDIR }}
- run: |
cd tests/integration/cleanup && ./smb_cleanup.sh \
"$(cat ../integration_config.yml | yq '.smb_server' | sed -e 's/^"//' -e 's/"$//')" \
"$(cat ../integration_config.yml | yq '.smb_share' | sed -e 's/^"//' -e 's/"$//')" \
"$(cat ../integration_config.yml | yq '.smb_username' | sed -e 's/^"//' -e 's/"$//')" \
"$(cat ../integration_config.yml | yq '.smb_password' | sed -e 's/^"//' -e 's/"$//')"