-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
162 lines (140 loc) · 4.12 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
---
# yamllint disable rule:line-length
image: registry.opensuse.org/home/okurz/container/ca/containers/tumbleweed:salt-minion-git-core-ssh
stages:
- test-static
- test
- deploy
- post-deploy
variables:
GIT_DEPTH: "3"
# make sure to apply workaround for
# https://gitlab.com/gitlab-org/gitlab-runner/issues/4119
# within script sections as salt calls can take long
salt_call: salt-call --local -l debug state.apply
.test_setup: &test_setup
stage: test
# our test steps can fail especially on repository refresh errors so let's
# retry
retry: 2
except:
- master@openqa/salt-pillars-openqa
before_script:
- ln -s $(pwd -P)/ /srv/salt
- ln -s $(pwd -P)/t/pillar /srv/pillar
- . /etc/os-release
# workaround ASCII encoding errors
# see https://github.com/saltstack/salt/issues/48522#issuecomment-404226425
- export LANG=en_US.UTF-8
# https://salt-formulas.readthedocs.io/en/latest/develop/testing-formulas.html#common-practices
- "echo 'noservices: True' >> /etc/salt/grains"
# speed up salt a lot, see https://github.com/saltstack/salt/issues/48773#issuecomment-443599880
- echo -e 'disable_grains:\n - esxi\n\ndisable_modules:\n - vsphere' >> /etc/salt/minion
test-general-mock:
<<: *test_setup
stage: test-static
script: $salt_call mock=True
test-webui-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: webui' >> /etc/salt/grains"
- $salt_call mock=True
test-worker-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: worker' >> /etc/salt/grains"
- $salt_call mock=True
test-monitor-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: monitor' >> /etc/salt/grains"
- $salt_call mock=True
test-storage-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: storage' >> /etc/salt/grains"
- $salt_call mock=True
test-jenkins-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: jenkins' >> /etc/salt/grains"
- $salt_call mock=True
test-libvirt-mock:
<<: *test_setup
stage: test-static
script:
- "echo 'roles: libvirt' >> /etc/salt/grains"
- $salt_call mock=True
test-general-test:
<<: *test_setup
script: $salt_call test=True
test-general:
<<: *test_setup
script:
- $salt_call
test-unit:
script:
- zypper --non-interactive in python3-pytest
- pytest
test-webui:
<<: *test_setup
script:
- "echo 'roles: webui' >> /etc/salt/grains"
- "echo 'webserver: apache2' >> /etc/salt/grains"
- (
- trap "kill %1" EXIT; while true; do sleep 1 && echo -n .; done &
- $salt_call
- )
# file must exist after correct salt application and can be inspected
# manually
- cat /etc/openqa/openqa.ini
test-worker:
<<: *test_setup
script:
- "echo 'roles: worker' >> /etc/salt/grains"
# just pick any example worker for testing purposes
- sed -i -e "s/openqaworker3/$HOSTNAME/" /srv/pillar/openqa/workerconf.sls
- (
- trap "kill %1" EXIT; while true; do sleep 1 && echo -n .; done &
- $salt_call
- )
- cat /etc/openqa/workers.ini
test-monitor:
<<: *test_setup
script:
- "echo 'roles: monitor' >> /etc/salt/grains"
- "echo 'webserver: nginx' >> /etc/salt/grains"
- (
- trap "kill %1" EXIT; while true; do sleep 1 && echo -n .; done &
- $salt_call
- )
# some checks on the changed or generated files
- ls /etc/nginx/vhosts.d/
- grep -q 'monitor.qa.suse.de' /etc/nginx/vhosts.d/02-grafana.conf && echo "ok -- expected nginx config file for grafana exists"
- (telegraf --test --input-filter system ||:) | grep -q 'system,host=' && echo "ok -- telegraf outputs host information" || telegraf --test
test-storage:
<<: *test_setup
script:
- "echo 'roles: storage' >> /etc/salt/grains"
- (
- trap "kill %1" EXIT; while true; do sleep 1 && echo -n .; done &
- $salt_call
- )
test-jenkins:
<<: *test_setup
script:
- "echo 'roles: jenkins' >> /etc/salt/grains"
- $salt_call
test-libvirt:
<<: *test_setup
script:
- "echo 'roles: libvirt' >> /etc/salt/grains"
- $salt_call
include:
- test-static.yml
- deploy.yml