Skip to content

Commit c1de377

Browse files
authored
Extend GitLab CI with build and test jobs for sanitizers (#2174)
Add a build and test job for each of ASAN, MSAN, TSAN, and UBSAN to the GitLab pipeline such that current vulnerabilities will be more easily visible and on each new commit, we can ensure that there are no additional errors introduced. Furthermore, sanitizer test runs are run separate from the existing mysql-test-run to isolate sanitizer error from functional errors. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
1 parent fdc582f commit c1de377

File tree

1 file changed

+104
-4
lines changed

1 file changed

+104
-4
lines changed

.gitlab-ci.yml

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,39 @@ fedora-clang:
172172
- dependencies.dot
173173
- dependencies.png
174174

175+
fedora-sanitizer:
176+
stage: build
177+
variables:
178+
GIT_STRATEGY: fetch
179+
GIT_SUBMODULE_STRATEGY: normal
180+
script:
181+
- yum install -y yum-utils rpm-build openssl-devel clang
182+
- yum install -y /usr/lib64/libasan.so.6.0.0 /usr/lib64/libtsan.so.0.0.0 /usr/lib64/libubsan.so.1.0.0
183+
# This repository does not have any .spec files, so install dependencies based on Fedora spec file
184+
- yum-builddep -y mariadb-server
185+
- mkdir builddir; cd builddir
186+
- export CXX=${CXX:-clang++}
187+
- export CC=${CC:-clang}
188+
- export CXX_FOR_BUILD=${CXX_FOR_BUILD:-clang++}
189+
- export CC_FOR_BUILD=${CC_FOR_BUILD:-clang}
190+
- export CFLAGS='-Wno-unused-command-line-argument'
191+
- export CXXFLAGS='-Wno-unused-command-line-argument'
192+
- cmake -DRPM=$CI_JOB_NAME $CMAKE_FLAGS $SANITIZER .. 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log
193+
# @TODO: the build will fail consistently at 24% when trying to make using eatmydata
194+
- make package -j 2 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log
195+
- *rpm_listfiles
196+
- mkdir ../rpm; mv *.rpm ../rpm
197+
artifacts:
198+
when: always # Must be able to see logs
199+
paths:
200+
- build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log
201+
- rpmlist-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log
202+
- rpm
203+
- builddir/_CPack_Packages/Linux/RPM/SPECS/
204+
parallel:
205+
matrix:
206+
- SANITIZER: [-DWITH_ASAN=YES, -DWITH_TSAN=YES, -DWITH_UBSAN=YES, -DWITH_MSAN=YES]
207+
175208
centos8:
176209
stage: build
177210
image: quay.io/centos/centos:stream8 # CentOS 8 is deprecated, use this Stream8 instead
@@ -246,10 +279,8 @@ centos7:
246279
- rpm
247280
- builddir/_CPack_Packages/Linux/RPM/SPECS/
248281

249-
mysql-test-run:
282+
.mysql-test-run: &mysql-test-run-def
250283
stage: test
251-
dependencies:
252-
- fedora
253284
script:
254285
# Install packages so tests and the dependencies install
255286
# @TODO: RPM missing 'patch' and 'diff' as dependency, so installing it manually for now
@@ -265,7 +296,76 @@ mysql-test-run:
265296
main.flush_logs_not_windows : query 'flush logs' succeeded - should have failed with error ER_CANT_CREATE_FILE (1004)
266297
main.mysql_upgrade_noengine : upgrade output order does not match the expected
267298
" > skiplist
268-
- ./mtr --suite=main --force --parallel=auto --xml-report=$CI_PROJECT_DIR/junit.xml --skip-test-list=skiplist
299+
- ./mtr --suite=main --force --parallel=auto --xml-report=$CI_PROJECT_DIR/junit.xml --skip-test-list=skiplist $RESTART_POLICY
300+
301+
mysql-test-run:
302+
stage: test
303+
dependencies:
304+
- fedora
305+
<<: *mysql-test-run-def
306+
artifacts:
307+
when: always # Also show results when tests fail
308+
reports:
309+
junit:
310+
- junit.xml
311+
312+
# Duplicate of the above jobs, except we use sanitizer build jobs as a dependency. This is so we can keep
313+
# sanitizer errors separate from functional test failures. Currently, there is no way to run the same
314+
# job for different dependencies.
315+
#
316+
# Additionally, for each sanitizer MTR job, we enable --force-restart so that
317+
# sanitizer errors can be traced to individual tests. The difference in test
318+
# suite runtime as a result of this flag is negligable (~30s for the entire test suite).
319+
# (see https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_MYSQL_TEST_RUN_PL.html)
320+
mysql-test-run-asan:
321+
stage: test
322+
variables:
323+
RESTART_POLICY: "--force-restart"
324+
dependencies:
325+
- "fedora-sanitizer: [-DWITH_ASAN=YES]"
326+
<<: *mysql-test-run-def
327+
artifacts:
328+
when: always # Also show results when tests fail
329+
reports:
330+
junit:
331+
- junit.xml
332+
333+
mysql-test-run-tsan:
334+
stage: test
335+
variables:
336+
RESTART_POLICY: "--force-restart"
337+
dependencies:
338+
- "fedora-sanitizer: [-DWITH_TSAN=YES]"
339+
<<: *mysql-test-run-def
340+
allow_failure: true
341+
artifacts:
342+
when: always # Also show results when tests fail
343+
reports:
344+
junit:
345+
- junit.xml
346+
347+
mysql-test-run-ubsan:
348+
stage: test
349+
variables:
350+
RESTART_POLICY: "--force-restart"
351+
dependencies:
352+
- "fedora-sanitizer: [-DWITH_UBSAN=YES]"
353+
<<: *mysql-test-run-def
354+
allow_failure: true
355+
artifacts:
356+
when: always # Also show results when tests fail
357+
reports:
358+
junit:
359+
- junit.xml
360+
361+
mysql-test-run-msan:
362+
stage: test
363+
variables:
364+
RESTART_POLICY: "--force-restart"
365+
dependencies:
366+
- "fedora-sanitizer: [-DWITH_MSAN=YES]"
367+
<<: *mysql-test-run-def
368+
allow_failure: true
269369
artifacts:
270370
when: always # Also show results when tests fail
271371
reports:

0 commit comments

Comments
 (0)