forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest_ci_options.py
More file actions
331 lines (311 loc) · 10.4 KB
/
test_ci_options.py
File metadata and controls
331 lines (311 loc) · 10.4 KB
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
#!/usr/bin/env python3
# type: ignore
import unittest
from ci_config import CI
from ci_settings import CiSettings
_TEST_BODY_1 = """
#### Run only:
- [ ] <!---ci_set_required--> Some Set
- [x] <!---ci_set_aarch64--> Integration tests (aarch64)
- [x] <!---ci_include_foo--> Integration tests
- [x] <!---ci_include_foo_Bar--> Integration tests
- [ ] <!---ci_include_bar--> Integration tests
- [x] <!---ci_exclude_foo--> some invalid mask - should be skipped
- [x] <!---ci_exclude_Foo_bar--> Integration tests
- [ ] <!---ci_exclude_bar--> Integration tests
#### CI options:
- [ ] <!---do_not_test--> do not test (only style check)
- [x] <!---woolen_wolfdog--> Woolen Wolfdog CI
- [x] <!---no_merge_commit--> disable merge-commit (no merge from master before tests)
- [ ] <!---no_ci_cache--> disable CI cache (job reuse)
#### Only specified batches in multi-batch jobs:
- [x] <!---batch_0--> 1
- [ ] <!---batch_1--> 2
"""
_TEST_BODY_2 = """
- [x] <!---ci_include_integration--> MUST include integration tests
- [x] <!---ci_include_stateless--> MUST include stateless tests
- [x] <!---ci_include_azure--> MUST include azure
- [x] <!---ci_include_foo_Bar--> no action must be applied
- [ ] <!---ci_include_bar--> no action must be applied
- [x] <!---ci_exclude_tsan|foobar--> MUST exclude tsan
- [x] <!---ci_exclude_aarch64--> MUST exclude aarch64
- [x] <!---ci_exclude_analyzer--> MUST exclude test with analazer
- [ ] <!---ci_exclude_bar--> no action applied
- [x] <!---ci_exclude_s3_storage--> Must exclude statless test with s3 storage
- [x] <!---ci_exclude_coverage--> Must exclude tests on coverage build
"""
_TEST_BODY_3 = """
- [x] <!---ci_include_analyzer--> Must include all tests for analyzer
"""
_TEST_BODY_4 = """
"""
_TEST_JOB_LIST = [
"Style check",
"Fast test",
"package_release",
"package_asan",
"package_aarch64",
"package_release_coverage",
"package_debug",
"package_tsan",
"package_ubsan",
"binary_release",
"fuzzers",
"Docker server image",
"Docker keeper image",
"Install packages (release)",
"Install packages (aarch64)",
"Stateless tests (debug)",
"Stateless tests (release)",
"Stateless tests (coverage)",
"Stateless tests (aarch64)",
"Stateless tests (asan)",
"Stateless tests (tsan)",
"Stateless tests (msan)",
"Stateless tests (ubsan)",
"Stateless tests (release, old analyzer, s3, DatabaseReplicated)",
"Stateless tests (release, ParallelReplicas, s3 storage)"
"Stateless tests (debug, s3 storage)",
"Stateless tests (tsan, s3 storage)",
"Stateless tests (asan, flaky check)",
"Stateless tests (azure, asan)",
"Stress test (asan)",
"Stress test (tsan)",
"Stress test (ubsan)",
"Stress test (msan)",
"Stress test (debug)",
"Integration tests (release)",
"Integration tests (asan)",
"Integration tests (asan, old analyzer)",
"Integration tests (tsan)",
"Integration tests (aarch64)",
"Integration tests (asan, flaky check)",
"Upgrade check (debug)",
"Upgrade check (asan)",
"Upgrade check (tsan)",
"Upgrade check (msan)",
"Unit tests (binary)",
"Unit tests (asan)",
"Unit tests (msan)",
"Unit tests (tsan)",
"Unit tests (ubsan)",
"AST fuzzer (debug)",
"AST fuzzer (asan)",
"AST fuzzer (msan)",
"AST fuzzer (tsan)",
"AST fuzzer (ubsan)",
"BuzzHouse (debug)",
"BuzzHouse (asan)",
"BuzzHouse (msan)",
"BuzzHouse (tsan)",
"BuzzHouse (ubsan)",
"ClickHouse Keeper Jepsen",
"ClickHouse Server Jepsen",
"Performance Comparison (release)",
"Performance Comparison (aarch64)",
"Sqllogic test (release)",
"SQLancer (release)",
"SQLancer (debug)",
"SQLTest",
"Compatibility check (release)",
"Compatibility check (aarch64)",
"ClickBench (release)",
"ClickBench (aarch64)",
"libFuzzer tests",
"Builds",
"Bugfix validation",
]
_TEST_JOB_LIST_2 = ["Style check", "Fast test", "fuzzers"]
class TestCIOptions(unittest.TestCase):
def test_pr_body_parsing(self):
ci_options = CiSettings.create_from_pr_message(
_TEST_BODY_1, update_from_api=False
)
self.assertFalse(ci_options.do_not_test)
self.assertFalse(ci_options.no_ci_cache)
self.assertTrue(ci_options.no_merge_commit)
self.assertTrue(ci_options.woolen_wolfdog)
self.assertEqual(ci_options.ci_sets, ["ci_set_aarch64"])
self.assertCountEqual(ci_options.include_keywords, ["foo", "foo_bar"])
self.assertCountEqual(ci_options.exclude_keywords, ["foo", "foo_bar"])
def test_options_applied(self):
self.maxDiff = None
ci_options = CiSettings.create_from_pr_message(
_TEST_BODY_2, update_from_api=False
)
self.assertFalse(ci_options.woolen_wolfdog)
self.assertCountEqual(
ci_options.include_keywords,
["integration", "foo_bar", "stateless", "azure"],
)
self.assertCountEqual(
ci_options.exclude_keywords,
["tsan", "foobar", "aarch64", "analyzer", "s3_storage", "coverage"],
)
jobs_configs = {
job: CI.JobConfig(runner_type=CI.Runners.STYLE_CHECKER)
for job in _TEST_JOB_LIST
}
# check "fuzzers" appears in the result due to the label
jobs_configs["fuzzers"].run_by_labels = ["TEST_LABEL"]
jobs_configs["Integration tests (asan)"].release_only = (
True # still must be included as it's set with include keywords
)
filtered_jobs = list(
ci_options.apply(
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
filtered_jobs,
[
"Style check",
"fuzzers",
"package_release",
"package_asan",
"package_debug",
"package_ubsan",
"package_aarch64",
"package_release_coverage",
"package_tsan",
"binary_release",
"Stateless tests (asan)",
"Stateless tests (azure, asan)",
"Stateless tests (asan, flaky check)",
"Stateless tests (ubsan)",
"Stateless tests (debug)",
"Stateless tests (release)",
"Integration tests (release)",
"Integration tests (asan)",
"Integration tests (asan, flaky check)",
"Builds",
],
)
def test_options_applied_2(self):
jobs_configs = {
job: CI.JobConfig(runner_type=CI.Runners.STYLE_CHECKER)
for job in _TEST_JOB_LIST_2
}
jobs_configs["Style check"].release_only = True
jobs_configs["Fast test"].pr_only = True
jobs_configs["fuzzers"].run_by_labels = ["TEST_LABEL"]
# no settings are set
filtered_jobs = list(
CiSettings().apply(
jobs_configs, is_release=False, is_pr=False, is_mq=True, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
[
"Fast test",
],
)
filtered_jobs = list(
CiSettings().apply(
jobs_configs, is_release=False, is_pr=True, is_mq=False, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
[
"Fast test",
],
)
filtered_jobs = list(
CiSettings().apply(
jobs_configs, is_release=True, is_pr=False, is_mq=False, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
[
"Style check",
],
)
def test_options_applied_3(self):
ci_settings = CiSettings()
ci_settings.include_keywords = ["Style"]
jobs_configs = {
job: CI.JobConfig(runner_type=CI.Runners.STYLE_CHECKER)
for job in _TEST_JOB_LIST_2
}
jobs_configs["Style check"].release_only = True
jobs_configs["Fast test"].pr_only = True
# no settings are set
filtered_jobs = list(
ci_settings.apply(
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
filtered_jobs,
[
"Style check",
"fuzzers",
],
)
ci_settings.include_keywords = ["Fast"]
filtered_jobs = list(
ci_settings.apply(
jobs_configs,
is_release=True,
is_pr=False,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
filtered_jobs,
["Style check", "fuzzers"],
)
def test_options_applied_4(self):
self.maxDiff = None
ci_options = CiSettings.create_from_pr_message(
_TEST_BODY_3, update_from_api=False
)
self.assertCountEqual(ci_options.include_keywords, ["analyzer"])
self.assertIsNone(ci_options.exclude_keywords)
jobs_configs = {
job: CI.JobConfig(runner_type=CI.Runners.STYLE_CHECKER)
for job in _TEST_JOB_LIST
}
# check "fuzzers" does not appears in the result
jobs_configs["fuzzers"].run_by_labels = ["TEST_LABEL"]
jobs_configs["Integration tests (asan)"].release_only = True
filtered_jobs = list(
ci_options.apply(
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
filtered_jobs,
[
"Style check",
"Integration tests (asan, old analyzer)",
"package_release",
"Stateless tests (release, old analyzer, s3, DatabaseReplicated)",
"package_asan",
"fuzzers",
"package_aarch64",
"package_release_coverage",
"package_debug",
"package_tsan",
"package_ubsan",
"binary_release",
"Builds",
],
)