-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
716 lines (689 loc) · 50.4 KB
/
.gitlab-ci.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
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# Copyright 2021-2023 VMware, Inc.
# SPDX-License-Identifier: Apache-2
---
stages:
- lint
- pre-commit
- build_svt
- test_svt
variables:
PLUGIN_PACKAGES: "*.sh"
CICD_UPSTREAM_PATH: "saltstack/open/salt-vm-tools"
CICD_SALT_SCRIPT_VERSION: "1.5"
CICD_SALT_SCRIPT_COMP_VERSION: "1.5.0"
CICD_SALT_SCRIPT_RELEASE: "1"
CICD_SALT_SCRIPT_DATE: "Thu Jan 1 1970"
CICD_SALT_SCRIPT_BRANCH: "main"
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID == null
include:
- project: saltstack/pop/cicd/ci-templates
file: /lint/pre-commit-run-all.yml
build-salt-vmtools-linux:
stage: build_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
paths:
- metadata.json
- svtminion.sh
expire_in: 120 days
# reports:
# dotenv: build.env
image: centos:7
## almalinux:8
script:
# assumes running as root
- oldpwd=$(pwd)
- mkdir /root/ || true
- echo "machine gitlab.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >> ~/.netrc
# setup environment vars
- export CICD_SALT_SCRIPT_DATE=$(date +"%a %b %0d %Y")
- export CICD_SALT_SCRIPT_VERSION_DATE=$(date "+%Y-%m-%d-%H:%M")
# generate sha256 for metadata.json file
- cd linux
- cp linux_metadata.json metadata.json
- sed -i -e 's&SALT_SCRIPT_VERSION&'${CICD_SALT_SCRIPT_VERSION}'&' metadata.json
- sed -i -e 's&SALT_SCRIPT_COMP_VERSION&'${CICD_SALT_SCRIPT_COMP_VERSION}'&' metadata.json
- svtminion_sha256=$(sha256sum svtminion.sh | cut -d ' ' -f 1)
- sed -i -e 's&SVTMINION_SHA256&'${svtminion_sha256}'&' metadata.json
- cat metadata.json
- sed -i -e 's&SCRIPT_VERSION_REPLACE&'${CICD_SALT_SCRIPT_VERSION_DATE}-${CI_COMMIT_SHORT_SHA}'&' svtminion.sh
- cp -f metadata.json ${oldpwd}/metadata.json
- cp -f svtminion.sh ${oldpwd}/svtminion.sh
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
build-salt-vmtools-windows:
stage: build_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- svtminion.ps1
expire_in: 120 days
image: centos:7
script:
- oldpwd=$(pwd)
- cd windows
- export CICD_SALT_SCRIPT_VERSION_DATE=$(date "+%Y-%m-%d-%H:%M")
- sed -i -e 's&SCRIPT_VERSION_REPLACE&'${CICD_SALT_SCRIPT_VERSION_DATE}-${CI_COMMIT_SHORT_SHA}'&' svtminion.ps1
- cp -f svtminion.ps1 ${oldpwd}/svtminion.ps1
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
build-tags-salt-vmtools-linux:
stage: build_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- metadata.json
- svtminion.sh
expire_in: 120 days
# reports:
# dotenv: build.env
image: centos:7
## almalinux:8
script:
# assumes running as root
- oldpwd=$(pwd)
- mkdir /root/ || true
- echo "machine gitlab.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >> ~/.netrc
# setup environment vars
- export CICD_SALT_SCRIPT_DATE=$(date +"%a %b %0d %Y")
# generate sha256 for metadata.json file
- cd linux
- cp linux_metadata.json metadata.json
# expect tag of version form x.y-z where -z is release number
- export CICD_SALT_SCRIPT_VERSION=$(echo "${CI_COMMIT_TAG}" | sed s/v// | cut -d '-' -f 1)
- export CICD_SALT_SCRIPT_RELEASE=$(echo "${CI_COMMIT_TAG}" | sed s/v// | cut -d '-' -f 2)
## ensure if no release number given default to 1
- if [[ "${CICD_SALT_SCRIPT_VERSION}" = "${CICD_SALT_SCRIPT_RELEASE}" ]]; then export CICD_SALT_SCRIPT_RELEASE=1; fi
- sed -i -e 's&SALT_SCRIPT_VERSION&'${CICD_SALT_SCRIPT_VERSION}'&' metadata.json
- sed -i -e 's&SALT_SCRIPT_COMP_VERSION&'${CICD_SALT_SCRIPT_VERSION}.${CICD_SALT_SCRIPT_RELEASE}'&' metadata.json
- svtminion_sha256=$(sha256sum svtminion.sh | cut -d ' ' -f 1)
- sed -i -e 's&SVTMINION_SHA256&'${svtminion_sha256}'&' metadata.json
- cat metadata.json
## this needs rework since not affecting release sub-dir in repository, but on VM
## added test to linux to check release is updated
## - sed -i -e 's&SCRIPT_VERSION_REPLACE&'${CI_COMMIT_TAG}'&' svtminion.sh
- cp -f metadata.json ${oldpwd}/metadata.json
- cp -f svtminion.sh ${oldpwd}/svtminion.sh
rules:
- if: "$CI_COMMIT_TAG != null && $CI_PROJECT_PATH == $CICD_UPSTREAM_PATH"
when: always
- when: never
build-tags-salt-vmtools-windows:
stage: build_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- svtminion.ps1
expire_in: 120 days
image: centos:7
script:
- oldpwd=$(pwd)
- cd windows
- sed -i -e 's&SCRIPT_VERSION_REPLACE&'${CI_COMMIT_TAG}'&' svtminion.ps1
- cp -f svtminion.ps1 ${oldpwd}/svtminion.ps1
rules:
- if: "$CI_COMMIT_TAG != null && $CI_PROJECT_PATH == $CICD_UPSTREAM_PATH"
when: always
- when: never
test-salt-vmtools-linux:
stage: test_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
expire_in: 120 days
needs:
- job: build-salt-vmtools-linux
tags:
- ss-custom-ec2-linux
image: saltstack/cicd/ec2-amis/glr/rocky/8/*
variables:
SPOT_INSTANCE: "false"
IMAGE_USER: "rocky"
WINDOWS_GUEST: "false"
script:
- oldpwd=$(pwd)
- sudo -u root mkdir -p /root/ || true
- echo "machine gitlab.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >> ~/.netrc
- id
- ls -alh svtminion.sh
- date
- sudo -u root yum makecache
- sudo -u root ./svtminion.sh --depend || { _retn=$?; if [[ ${_retn} -eq 126 ]]; then echo "test correct"; else echo "test failed, should be missing at least the vmtoolsd dependency, returned '${_retn}'"; exit 1; fi; }
- ls -alh /var/log/vmware-svtminion.sh-depend-*
- sudo -u root yum -y install open-vm-tools
- sudo -u root yum -y install curl
- sudo -u root yum -y install wget
- sudo -u root ./svtminion.sh --depend --loglevel info || { _retn=$?; echo "test failed, there should be no missing dependencies, returned '${_retn}'"; }
- ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l
- if [[ 2 -eq $(ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l) ]]; then echo "test correct"; else "test failed, should be 2 depend log files"; exit 1; fi
- ps -ef | grep svtminion
- sudo -u root pgrep -f "svtminion.sh"
- sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; }
- ls -alh /var/log/vmware-svtminion.sh-status-*
- sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- myhost=$(hostname)
- myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g")
- if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi
- ls -alh /opt/saltstack/salt/salt-minion
- ls -alh /usr/bin/salt-call
- ls -alh /usr/bin/salt-minion
- getent group salt | grep -w salt
- cat /etc/passwd | grep -w salt
- sudo -u root /usr/bin/salt-call --local test.versions
- sudo -u root /usr/bin/salt-call --local grains.items
- sudo -u root /usr/bin/salt-call --local cmd.run "ls -al /"
- sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --clear myminion
- cat /etc/salt/minion | grep 'id:\ myminion' 1>/dev/null
- sudo -u root ./svtminion.sh --clear
- cat /etc/salt/minion | grep '# id:\ myminion' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ myminion_' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- list_dirs_to_chk_removed="/opt/saltstack /etc/salt /var/run/salt /var/cache/salt /var/log/salt"
- for idx in ${list_dirs_to_chk_removed}; do if [[ -d "${idx}" ]]; then echo "directory ${idx} is left after a remove"; exit 1; fi; done
- list_files_to_chk_removed="/usr/bin/salt-call /usr/bin/salt-minion /usr/lib/systemd/system/salt-minion.service /etc/systemd/system/salt-minion.service"
- for idx in ${list_files_to_chk_removed}; do if [[ -f "${idx}" ]]; then echo "file ${idx} is left after a remove"; exit 1; fi; done
- sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; }
- sudo -u root ./svtminion.sh --version --loglevel debug
- ls -alh /var/log/vmware-svtminion.sh-default-*
- sudo -u root ./svtminion.sh --minionversion "3004.2-1" --install master=192.168.0.6 --loglevel debug
- ls -alh /opt/saltstack/salt/run/
- cat /etc/salt/minion | grep 'master:\ 192.168.0.6' 1>/dev/null
- myhost=$(hostname)
- myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g")
- if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- ls -l /var/log/vmware-svtminion.sh-status-*
- ls -l /var/log/vmware-svtminion.sh-status-* | wc -l
- if [[ 5 -eq $(ls -l /var/log/vmware-svtminion.sh-status-* | wc -l) ]]; then echo "test correct"; else "test failed, should be only 5 status log files"; exit 1; fi
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test source installs with repo.json
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source file:/${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m "3003.3-1"
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test source installs with repo.json post_3005
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006.6
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3007
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt_rc/salt/py3/onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test stop and start
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt/py3/onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
- sudo -u root ./svtminion.sh --stop --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 107 ]]; then echo "test correct"; else echo "test failed, salt-minion should be stopped, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion || { echo "test correct"; }
- sudo -u root ps -ef | grep salt
- sudo -u root ./svtminion.sh --start --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion || { echo "test failed, salt-minion should be running"; exit 1; }
# test reconfig
- cat /etc/salt/minion
- sudo -u root ./svtminion.sh --reconfig master=192.168.0.7 --loglevel debug
- sleep 3
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; }
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.7' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
# test 3006-3007 and upgrade
- ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sleep 1
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 id="tup" --loglevel debug --minionversion 3006
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
- if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3006 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --upgrade --install --loglevel debug --minionversion 3007
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
- if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3007 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi
# test source installs without repo.json
- cd ${oldpwd}/tests/testarea
- mv repo.json repo.json_hold
- cd ${oldpwd}
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3004-1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- cd ${oldpwd}/tests/testarea
- mv repo.json_hold repo.json
- cd ${oldpwd}
# test source installs without repo.json for post_3005
- cd ${oldpwd}/tests/testarea/test_onedir
- mv repo.json repo.json_hold
- cd ${oldpwd}
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# restore normal test source installs with 2 repo.json for post_3005
- cd ${oldpwd}/tests/testarea/test_onedir
- mv repo.json_hold repo.json
- cd ${oldpwd}
- sudo -u root bash -x ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea/test_onedir -m 3007.1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test with classic package installed
- sudo -u root rpm --import https://repo.saltproject.io/py3/redhat/8/x86_64/3005/SALTSTACK-GPG-KEY.pub
- sudo -u root curl -fsSL https://repo.saltproject.io/py3/redhat/8/x86_64/3005.repo | sudo -u root tee /etc/yum.repos.d/salt.repo
- sudo -u root yum makecache
- sudo -u root yum -y install salt-minion
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, classic salt-minion should be installed and external install detected, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed and script remove not valid, returned '${_retn}'"; exit 1; fi; }
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
test-salt-vmtools-windows:
stage: test_svt
tags:
- saas-windows-medium-amd64
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
expire_in: 120 days
needs:
- job: build-salt-vmtools-windows
script:
# Move the artifact to the original location to be tested
- Move-Item .\svtminion.ps1 .\windows\svtminion.ps1 -Force
# Make sure we can run the script
- try { .\windows\svtminion.ps1 | Out-Null } catch {} finally { if ( $LASTEXITCODE -ne 126 ) { Write-Host "Failed to execute"; exit 1 } else { $LASTEXITCODE = 0 } }
# Make sure we can display help
- try { .\windows\svtminion.ps1 -Help | Out-Null } catch {} finally { if ( $LASTEXITCODE -ne 0 ) { Write-Host "Status not 0"; exit 1 } }
# Make sure we get a status
- try { .\windows\svtminion.ps1 -Status | Out-Null } catch {} finally { if ( $LASTEXITCODE -ge 100 ) { Write-Host "Status not 102"; exit 1 } else { $LASTEXITCODE = 0 }}
# Running functional tests (must be run with powershell -file)
- powershell -file .\tests\windows\runtests.ps1
# Running integration tests (must be run with powershell -file)
- powershell -file .\tests\windows\runtests.ps1 -Integration
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
test-tags-salt-vmtools-linux:
stage: test_svt
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
expire_in: 120 days
needs:
- job: build-tags-salt-vmtools-linux
tags:
- ss-custom-ec2-linux
image: saltstack/cicd/ec2-amis/glr/rocky/8/*
variables:
SPOT_INSTANCE: "false"
IMAGE_USER: "rocky"
WINDOWS_GUEST: "false"
script:
- oldpwd=$(pwd)
- sudo -u root mkdir -p /root/ || true
- echo "machine gitlab.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >> ~/.netrc
- id
- ls -alh svtminion.sh
- date
- sudo -u root yum makecache
- sudo -u root ./svtminion.sh --depend || { _retn=$?; if [[ ${_retn} -eq 126 ]]; then echo "test correct"; else echo "test failed, should be missing at least the vmtoolsd dependency, returned '${_retn}'"; exit 1; fi; }
- ls -alh /var/log/vmware-svtminion.sh-depend-*
- sudo -u root yum -y install open-vm-tools
- sudo -u root yum -y install curl
- sudo -u root yum -y install wget
- sudo -u root ./svtminion.sh --depend --loglevel info || { _retn=$?; echo "test failed, there should be no missing dependencies, returned '${_retn}'"; }
- ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l
- if [[ 2 -eq $(ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l) ]]; then echo "test correct"; else "test failed, should be 2 depend log files"; exit 1; fi
- ps -ef | grep svtminion
- sudo -u root pgrep -f "svtminion.sh"
- sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; }
- ls -alh /var/log/vmware-svtminion.sh-status-*
- sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- myhost=$(hostname)
- myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g")
- if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi
- ls -alh /opt/saltstack/salt/salt-minion
- ls -alh /usr/bin/salt-call
- ls -alh /usr/bin/salt-minion
- getent group salt | grep -w salt
- cat /etc/passwd | grep -w salt
- sudo -u root /usr/bin/salt-call --local test.versions
- sudo -u root /usr/bin/salt-call --local grains.items
- sudo -u root /usr/bin/salt-call --local cmd.run "ls -al /"
- sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --clear myminion
- cat /etc/salt/minion | grep 'id:\ myminion' 1>/dev/null
- sudo -u root ./svtminion.sh --clear
- cat /etc/salt/minion | grep '# id:\ myminion' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ myminion_' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- list_dirs_to_chk_removed="/opt/saltstack /etc/salt /var/run/salt /var/cache/salt /var/log/salt"
- for idx in ${list_dirs_to_chk_removed}; do if [[ -d "${idx}" ]]; then echo "directory ${idx} is left after a remove"; exit 1; fi; done
- list_files_to_chk_removed="/usr/bin/salt-call /usr/bin/salt-minion /usr/lib/systemd/system/salt-minion.service /etc/systemd/system/salt-minion.service"
- for idx in ${list_files_to_chk_removed}; do if [[ -f "${idx}" ]]; then echo "file ${idx} is left after a remove"; exit 1; fi; done
- sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; }
- sudo -u root ./svtminion.sh --version --loglevel debug
- ls -alh /var/log/vmware-svtminion.sh-default-*
- sudo -u root ./svtminion.sh --minionversion "3004.2-1" --install master=192.168.0.6 --loglevel debug
- ls -alh /opt/saltstack/salt/run/
- cat /etc/salt/minion | grep 'master:\ 192.168.0.6' 1>/dev/null
- myhost=$(hostname)
- myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g")
- if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- ls -l /var/log/vmware-svtminion.sh-status-*
- ls -l /var/log/vmware-svtminion.sh-status-* | wc -l
- if [[ 5 -eq $(ls -l /var/log/vmware-svtminion.sh-status-* | wc -l) ]]; then echo "test correct"; else "test failed, should be only 5 status log files"; exit 1; fi
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test source installs with repo.json
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source file:/${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m "3003.3-1"
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test source installs with repo.json post_3005
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006.6
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir/minor --install master=192.168.0.5 --loglevel debug --minionversion 3006.7
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt_rc/salt/py3/onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test start, stop, reconfig
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt/py3/onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sleep 1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ps -ef | grep salt
- sudo -u root systemctl is-active salt-minion
- sudo -u root ./svtminion.sh --stop --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 107 ]]; then echo "test correct"; else echo "test failed, salt-minion should be stopped, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion || { echo "test correct"; }
- sudo -u root ps -ef | grep salt
- sudo -u root ./svtminion.sh --start --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion || { echo "test failed, salt-minion should be running"; exit 1; }
# test 3006-3007 and upgrade
- ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sleep 1
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 id="tup" --loglevel debug --minionversion 3006
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
- if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3006 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --upgrade --install --loglevel debug --minionversion 3007
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null
- sudo -u root ps -ef | grep salt
- systemctl is-active salt-minion
- if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3007 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi
# test source installs without repo.json
- cd ${oldpwd}/tests/testarea
- mv repo.json repo.json_hold
- cd ${oldpwd}
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3004-1
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
- cd ${oldpwd}/tests/testarea
- mv repo.json_hold repo.json
- cd ${oldpwd}
# test source installs without repo.json for post_3005
- cd ${oldpwd}/tests/testarea/test_onedir
- mv repo.json repo.json_hold
- cd ${oldpwd}
- sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# restore normal test source installs with 2 repo.json for post_3005
- cd ${oldpwd}/tests/testarea/test_onedir
- mv repo.json_hold repo.json
- cd ${oldpwd}
- sudo -u root bash -x ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea/test_onedir -m 3007.1
- cat /etc/salt/minion
- cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
- sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
# test with classic package installed
- sudo -u root rpm --import https://repo.saltproject.io/py3/redhat/8/x86_64/3005/SALTSTACK-GPG-KEY.pub
- sudo -u root curl -fsSL https://repo.saltproject.io/py3/redhat/8/x86_64/3005.repo | sudo -u root tee /etc/yum.repos.d/salt.repo
- sudo -u root yum makecache
- sudo -u root yum -y install salt-minion
- sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, classic salt-minion should be installed and external install detected, returned '${_retn}'"; exit 1; fi; }
- sudo -u root ./svtminion.sh --remove || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed and script remove not valid, returned '${_retn}'"; exit 1; fi; }
rules:
- if: "$CI_COMMIT_TAG != null && $CI_PROJECT_PATH == $CICD_UPSTREAM_PATH"
when: always
- when: never
test-tags-salt-vmtools-windows:
stage: test_svt
tags:
## - shared-windows
## - windows
## - windows-1809
- saas-windows-medium-amd64
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
expire_in: 120 days
needs:
- job: build-tags-salt-vmtools-windows
script:
# Move the artifact to the original location to be tested
- Move-Item .\svtminion.ps1 .\windows\svtminion.ps1 -Force
# Make sure we can run the script
- try { .\windows\svtminion.ps1 | Out-Null } catch {} finally { if ( $LASTEXITCODE -ne 126 ) { Write-Host "Failed to execute"; exit 1 } else { $LASTEXITCODE = 0 } }
# Make sure we can display help
- try { .\windows\svtminion.ps1 -Help | Out-Null } catch {} finally { if ( $LASTEXITCODE -ne 0 ) { Write-Host "Status not 0"; exit 1 } }
# Make sure we get a status
- try { .\windows\svtminion.ps1 -Status | Out-Null } catch {} finally { if ( $LASTEXITCODE -ge 100 ) { Write-Host "Status not 102"; exit 1 } else { $LASTEXITCODE = 0 }}
# Running functional tests (must be run with powershell -file)
- powershell -file .\tests\windows\runtests.ps1
# Running integration tests (must be run with powershell -file)
- powershell -file .\tests\windows\runtests.ps1 -Integration
rules:
- if: "$CI_COMMIT_TAG != null && $CI_PROJECT_PATH == $CICD_UPSTREAM_PATH"
when: always
- when: never