From ce623a23416eb192ce70116fd14992e84e7ccbbe Mon Sep 17 00:00:00 2001
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
Date: Mon, 10 Jun 2019 10:57:01 +0300
Subject: [PATCH] Enable GitLab CI testing

Implemented GitLab CI testing process additionally to existing Travis
CI. The new testing process is added to run tests faster. It requires to
control a load of machines to avoid flaky fails on timeouts. GitLab CI
allows us to run testing on our machines.

Created 2 stages for testing and deploying packages.

The testing stage contains the following jobs that are run for all
branches:

* Debian 9 (Stretch): release/debug gcc.
* Debian 10 (Buster): release clang8 + lto.
* OSX 14 (Mojave): release.
* FreeBSD 12: release gcc.

And the following jobs that are run of long-term branches (release
branches: for now it is 1.10, 2.1 and master):

* OSX 13 (Sierra): release clang.
* OSX 14 (Mojave): release clang + lto.

The deployment stage contains the same jobs as we have in Travis CI.
They however just build tarballs and packages: don't push them to S3 and
packagecloud.

In order to run full testing on a short-term branch one can name it with
'-full-ci' suffix.

The additional manual work is needed when dependencies are changed in
.travis.mk file ('deps_debian' or 'deps_buster_clang_8' goals):

 | make GITLAB_USER=foo -f .gitlab.mk docker_bootstrap

This command pushes docker images into GitLab Registry and then they are
used in testing. Pre-built images speed up testing.

Fixes #4156
---
 .gitlab-ci.yml                              | 321 ++++++++++++++++++++
 .gitlab.mk                                  | 107 +++++++
 .travis.mk                                  | 105 +++++--
 .travis.yml                                 |   3 +
 test/app-tap/console.skipcond               |   7 +
 test/app-tap/debug.skipcond                 |   8 +
 test/app-tap/http_client.skipcond           |   7 +
 test/app-tap/minimal.skipcond               |   8 +
 test/app-tap/pwd.skipcond                   |   8 +
 test/app-tap/tarantoolctl.skipcond          |   8 +
 test/app/crypto.skipcond                    |   7 +
 test/app/digest.skipcond                    |   7 +
 test/app/socket.skipcond                    |   5 +
 test/box-tap/cfg.skipcond                   |   8 +
 test/box/net.box.skipcond                   |   7 +
 test/box/net_msg_max.skipcond               |   7 +
 test/replication/misc.skipcond              |   7 +
 test/replication/skip_conflict_row.skipcond |   7 +
 test/wal_off/snapshot_stress.skipcond       |   7 +
 19 files changed, 618 insertions(+), 26 deletions(-)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 .gitlab.mk
 create mode 100644 test/app-tap/console.skipcond
 create mode 100644 test/app-tap/debug.skipcond
 create mode 100644 test/app-tap/http_client.skipcond
 create mode 100644 test/app-tap/minimal.skipcond
 create mode 100644 test/app-tap/pwd.skipcond
 create mode 100644 test/app-tap/tarantoolctl.skipcond
 create mode 100644 test/app/crypto.skipcond
 create mode 100644 test/app/digest.skipcond
 create mode 100644 test/box-tap/cfg.skipcond
 create mode 100644 test/box/net.box.skipcond
 create mode 100644 test/box/net_msg_max.skipcond
 create mode 100644 test/replication/misc.skipcond
 create mode 100644 test/replication/skip_conflict_row.skipcond
 create mode 100644 test/wal_off/snapshot_stress.skipcond

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000000..9d374cd619
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,321 @@
+stages:
+  - test
+  - deploy
+
+variables:
+  IMAGE_TEST: "${CI_REGISTRY}/${CI_PROJECT_PATH}/testing/debian-stretch:latest"
+  IMAGE_TEST_LTO: "${CI_REGISTRY}/${CI_PROJECT_PATH}/testing/debian-buster:latest"
+  GITLAB_MAKE: "make -f .gitlab.mk"
+
+# Tests
+
+release:
+  image: ${IMAGE_TEST}
+  stage: test
+  tags:
+    - docker_test
+  script:
+    - ${GITLAB_MAKE} test_debian_no_deps
+
+debug:
+  image: ${IMAGE_TEST}
+  stage: test
+  tags:
+    - docker_test
+  script:
+    - ${GITLAB_MAKE} test_coverage_debian_no_deps
+
+release_clang:
+  image: ${IMAGE_TEST}
+  stage: test
+  tags:
+    - docker_test
+  variables:
+    CC: clang
+    CXX: clang++
+  script:
+    - ${GITLAB_MAKE} test_debian_no_deps
+
+release_lto:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  image: ${IMAGE_TEST_LTO}
+  stage: test
+  tags:
+    - docker_test
+  variables:
+    CMAKE_EXTRA_PARAMS: -DENABLE_LTO=ON
+  script:
+    - ${GITLAB_MAKE} test_debian_no_deps
+
+release_lto_clang8:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  image: ${IMAGE_TEST_LTO}
+  stage: test
+  tags:
+    - docker_test
+  variables:
+    CC: clang-8
+    CXX: clang++-8
+    CMAKE_EXTRA_PARAMS: -DENABLE_LTO=ON
+  script:
+    - ${GITLAB_MAKE} test_debian_no_deps
+
+osx_13_release:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: test
+  tags:
+    - vms_osx_13
+  variables:
+    VMS_NAME: 'osx_13'
+    VMS_USER: 'tarantool'
+    VMS_PORT: '2212'
+  before_script:
+    - ${GITLAB_MAKE} vms_start
+  script:
+    - ${GITLAB_MAKE} vms_test_osx
+  after_script:
+    - ${GITLAB_MAKE} vms_shutdown
+
+osx_14_release:
+  stage: test
+  tags:
+    - vms_osx_14
+  variables:
+    VMS_NAME: 'osx_14'
+    VMS_USER: 'tarantool'
+    VMS_PORT: '2222'
+  before_script:
+    - ${GITLAB_MAKE} vms_start
+  script:
+    - ${GITLAB_MAKE} vms_test_osx
+  after_script:
+    - ${GITLAB_MAKE} vms_shutdown
+
+osx_14_release_lto:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: test
+  tags:
+    - vms_osx_14
+  variables:
+    EXTRA_ENV: "export CMAKE_EXTRA_PARAMS=-DENABLE_LTO=ON ;"
+    VMS_NAME: 'osx_14'
+    VMS_USER: 'tarantool'
+    VMS_PORT: '2222'
+  before_script:
+    - ${GITLAB_MAKE} vms_start
+  script:
+    - ${GITLAB_MAKE} vms_test_osx
+  after_script:
+    - ${GITLAB_MAKE} vms_shutdown
+
+freebsd_12_release:
+  stage: test
+  tags:
+    - vms_freebsd_12
+  variables:
+    VMS_NAME: 'freebsd_12'
+    VMS_USER: 'vagrant'
+    VMS_PORT: '2232'
+    MAKE: 'gmake'
+  before_script:
+    - ${GITLAB_MAKE} vms_start
+  script:
+    - ${GITLAB_MAKE} vms_test_freebsd
+  after_script:
+    - ${GITLAB_MAKE} vms_shutdown
+
+# Packs
+
+centos_6:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'el'
+    DIST: '6'
+  script:
+    - ${GITLAB_MAKE} package
+
+centos_7:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy_test
+  variables:
+    OS: 'el'
+    DIST: '7'
+  script:
+    - ${GITLAB_MAKE} package
+
+fedora_28:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy_test
+  variables:
+    OS: 'fedora'
+    DIST: '28'
+  script:
+    - ${GITLAB_MAKE} package
+
+fedora_29:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy_test
+  variables:
+    OS: 'fedora'
+    DIST: '29'
+  script:
+    - ${GITLAB_MAKE} package
+
+fedora_30:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy_test
+  variables:
+    OS: 'fedora'
+    DIST: '30'
+  script:
+    - ${GITLAB_MAKE} package
+
+ubuntu_14_04:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'ubuntu'
+    DIST: 'trusty'
+  script:
+    - ${GITLAB_MAKE} package
+
+ubuntu_16_04:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'ubuntu'
+    DIST: 'xenial'
+  script:
+    - ${GITLAB_MAKE} package
+
+ubuntu_18_04:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'ubuntu'
+    DIST: 'bionic'
+  script:
+    - ${GITLAB_MAKE} package
+
+ubuntu_18_10:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'ubuntu'
+    DIST: 'cosmic'
+  script:
+    - ${GITLAB_MAKE} package
+
+ubuntu_19_04:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'ubuntu'
+    DIST: 'disco'
+  script:
+    - ${GITLAB_MAKE} package
+
+debian_8:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'debian'
+    DIST: 'jessie'
+  script:
+    - ${GITLAB_MAKE} package
+
+debian_9:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'debian'
+    DIST: 'stretch'
+  script:
+    - ${GITLAB_MAKE} package
+
+debian_10:
+  only:
+    refs:
+      - master
+      - /^.*-full-ci$/
+  stage: deploy
+  tags:
+    - deploy
+  variables:
+    OS: 'debian'
+    DIST: 'buster'
+  script:
+    - ${GITLAB_MAKE} package
diff --git a/.gitlab.mk b/.gitlab.mk
new file mode 100644
index 0000000000..7199adf942
--- /dev/null
+++ b/.gitlab.mk
@@ -0,0 +1,107 @@
+GITLAB_MAKE:=${MAKE} -f .gitlab.mk
+TRAVIS_MAKE:=${MAKE} -f .travis.mk
+
+# #####
+# Utils
+# #####
+
+# Update submodules.
+#
+# Note: There is no --force option for `git submodule` on git
+# 1.7.1, which is shiped in CentOS 6.
+git_submodule_update:
+	git submodule update --force --recursive --init 2>/dev/null || \
+		git submodule update --recursive --init
+
+# Pass *_no_deps goals to .travis.mk.
+test_%_no_deps: git_submodule_update
+	${TRAVIS_MAKE} $@
+
+# #######################################################
+# Build and push testing docker images to GitLab Registry
+# #######################################################
+
+# These images contains tarantool dependencies and testing
+# dependencies to run tests in them.
+#
+# How to run:
+#
+# make GITLAB_USER=foo -f .gitlab.mk docker_bootstrap
+#
+# The command will prompt for a password. If two-factor
+# authentication is enabled an access token with 'api' scope
+# should be entered here instead of a password.
+#
+# When to run:
+#
+# When some of deps_* goals in .travis.mk are updated.
+#
+# Keep in a mind that the resulting image is used to run tests on
+# all branches, so avoid removing packages: only add them.
+
+GITLAB_REGISTRY?=registry.gitlab.com
+DOCKER_BUILD=docker build --network=host -f - .
+
+define DEBIAN_STRETCH_DOCKERFILE
+FROM packpack/packpack:debian-stretch
+COPY .travis.mk .
+RUN make -f .travis.mk deps_debian
+endef
+export DEBIAN_STRETCH_DOCKERFILE
+
+define DEBIAN_BUSTER_DOCKERFILE
+FROM packpack/packpack:debian-buster
+COPY .travis.mk .
+RUN make -f .travis.mk deps_buster_clang_8
+endef
+export DEBIAN_BUSTER_DOCKERFILE
+
+IMAGE_PREFIX:=${GITLAB_REGISTRY}/tarantool/tarantool/testing
+DEBIAN_STRETCH_IMAGE:=${IMAGE_PREFIX}/debian-stretch
+DEBIAN_BUSTER_IMAGE:=${IMAGE_PREFIX}/debian-buster
+
+TRAVIS_CI_MD5SUM:=$(firstword $(shell md5sum .travis.mk))
+
+docker_bootstrap:
+	# Login.
+	docker login -u ${GITLAB_USER} ${GITLAB_REGISTRY}
+	# Build images.
+	echo "$${DEBIAN_STRETCH_DOCKERFILE}" | ${DOCKER_BUILD} \
+		-t ${DEBIAN_STRETCH_IMAGE}:${TRAVIS_CI_MD5SUM} \
+		-t ${DEBIAN_STRETCH_IMAGE}:latest
+	echo "$${DEBIAN_BUSTER_DOCKERFILE}" | ${DOCKER_BUILD} \
+		-t ${DEBIAN_BUSTER_IMAGE}:${TRAVIS_CI_MD5SUM} \
+		-t ${DEBIAN_BUSTER_IMAGE}:latest
+	# Push images.
+	docker push ${DEBIAN_STRETCH_IMAGE}:${TRAVIS_CI_MD5SUM}
+	docker push ${DEBIAN_BUSTER_IMAGE}:${TRAVIS_CI_MD5SUM}
+	docker push ${DEBIAN_STRETCH_IMAGE}:latest
+	docker push ${DEBIAN_BUSTER_IMAGE}:latest
+
+# #################################
+# Run tests under a virtual machine
+# #################################
+
+vms_start:
+	VBoxManage controlvm ${VMS_NAME} poweroff || true
+	VBoxManage snapshot ${VMS_NAME} restore ${VMS_NAME}
+	VBoxManage startvm ${VMS_NAME} --type headless
+
+vms_test_%:
+	tar czf - ../tarantool | ssh ${VMS_USER}@127.0.0.1 -p ${VMS_PORT} tar xzf -
+	ssh ${VMS_USER}@127.0.0.1 -p ${VMS_PORT} "/bin/bash -c \
+		'${EXTRA_ENV} \
+		cd tarantool && \
+		${GITLAB_MAKE} git_submodule_update && \
+		${TRAVIS_MAKE} $(subst vms_,,$@)'"
+
+vms_shutdown:
+	VBoxManage controlvm ${VMS_NAME} poweroff
+
+# ########################
+# Build RPM / Deb packages
+# ########################
+
+package: git_submodule_update
+	git clone https://github.com/packpack/packpack.git packpack
+	PACKPACK_EXTRA_DOCKER_RUN_PARAMS='--network=host' ./packpack/packpack
diff --git a/.travis.mk b/.travis.mk
index 6d0c42207c..90eb22555f 100644
--- a/.travis.mk
+++ b/.travis.mk
@@ -3,6 +3,7 @@
 #
 
 DOCKER_IMAGE?=packpack/packpack:debian-stretch
+TEST_RUN_EXTRA_PARAMS?=
 
 all: package
 
@@ -13,8 +14,8 @@ package:
 test: test_$(TRAVIS_OS_NAME)
 
 # Redirect some targets via docker
-test_linux: docker_test_ubuntu
-coverage: docker_coverage_ubuntu
+test_linux: docker_test_debian
+coverage: docker_coverage_debian
 
 docker_%:
 	mkdir -p ~/.cache/ccache
@@ -33,8 +34,12 @@ docker_%:
 		${DOCKER_IMAGE} \
 		make -f .travis.mk $(subst docker_,,$@)
 
-deps_ubuntu:
-	sudo apt-get update && apt-get install -y -f \
+#########
+# Linux #
+#########
+
+deps_debian:
+	apt-get update && apt-get install -y -f \
 		build-essential cmake coreutils sed \
 		libreadline-dev libncurses5-dev libyaml-dev libssl-dev \
 		libcurl4-openssl-dev libunwind-dev libicu-dev \
@@ -42,34 +47,29 @@ deps_ubuntu:
 		python-msgpack python-yaml python-argparse python-six python-gevent \
 		lcov ruby clang llvm llvm-dev
 
-test_ubuntu: deps_ubuntu
+deps_buster_clang_8: deps_debian
+	echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-8 main" > /etc/apt/sources.list.d/clang_8.list
+	echo "deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster-8 main" >> /etc/apt/sources.list.d/clang_8.list
+	wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
+	apt-get update
+	apt-get install -y clang-8 llvm-8-dev
+
+build_debian:
 	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
-	make -j8
-	cd test && /usr/bin/python test-run.py --force -j 1
+	make -j
 
-deps_osx:
-	brew update
-	brew install openssl readline curl icu4c --force
-	python2 -V || brew install python2 --force
-	curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | python
-	pip install -r test-run/requirements.txt
+test_debian_no_deps: build_debian
+	cd test && /usr/bin/python test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
 
-test_osx: deps_osx
-	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
-	# Increase the maximum number of open file descriptors on macOS
-	sudo sysctl -w kern.maxfiles=20480 || :
-	sudo sysctl -w kern.maxfilesperproc=20480 || :
-	sudo launchctl limit maxfiles 20480 || :
-	ulimit -S -n 20480 || :
-	ulimit -n
-	make -j8
-	cd test && ./test-run.py --force -j 1 unit/ app/ app-tap/ box/ box-tap/
+test_debian: deps_debian test_debian_no_deps
 
-coverage_ubuntu: deps_ubuntu
+build_coverage_debian:
 	cmake . -DCMAKE_BUILD_TYPE=Debug -DENABLE_GCOV=ON
-	make -j8
+	make -j
+
+test_coverage_debian_no_deps: build_coverage_debian
 	# Enable --long tests for coverage
-	cd test && /usr/bin/python test-run.py --force -j 1 --long
+	cd test && /usr/bin/python test-run.py --force $(TEST_RUN_EXTRA_PARAMS) --long
 	lcov --compat-libtool --directory src/ --capture --output-file coverage.info.tmp
 	lcov --compat-libtool --remove coverage.info.tmp 'tests/*' 'third_party/*' '/usr/*' \
 		--output-file coverage.info
@@ -81,6 +81,59 @@ coverage_ubuntu: deps_ubuntu
 		coveralls-lcov --service-name travis-ci --service-job-id $(TRAVIS_JOB_ID) --repo-token $(COVERALLS_TOKEN) coverage.info; \
 	fi;
 
+coverage_debian: deps_debian test_coverage_debian_no_deps
+
+#######
+# OSX #
+#######
+
+deps_osx:
+	brew update
+	brew install openssl readline curl icu4c --force
+	python2 -V || brew install python2 --force
+	curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py >get-pip.py
+	python get-pip.py --user
+	pip install --user --force-reinstall -r test-run/requirements.txt
+
+build_osx:
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
+	make -j
+
+test_osx_no_deps: build_osx
+	# Increase the maximum number of open file descriptors on macOS
+	sudo sysctl -w kern.maxfiles=20480 || :
+	sudo sysctl -w kern.maxfilesperproc=20480 || :
+	sudo launchctl limit maxfiles 20480 || :
+	ulimit -S -n 20480 || :
+	ulimit -n
+	cd test && ./test-run.py --force $(TEST_RUN_EXTRA_PARAMS) unit/ app/ app-tap/ box/ box-tap/
+
+test_osx: deps_osx test_osx_no_deps
+
+###########
+# FreeBSD #
+###########
+
+deps_freebsd:
+	sudo pkg install -y git cmake gmake gcc coreutils \
+		readline ncurses libyaml openssl curl libunwind icu \
+		python27 py27-pip py27-setuptools py27-daemon \
+		py27-yaml py27-argparse py27-six py27-gevent \
+		gdb bash
+
+build_freebsd:
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
+	gmake -j
+
+test_freebsd_no_deps: build_freebsd
+	cd test && /usr/bin/python test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
+
+test_freebsd: deps_freebsd test_freebsd_no_deps
+
+####################
+# Sources tarballs #
+####################
+
 source:
 	git clone https://github.com/packpack/packpack.git packpack
 	TARBALL_COMPRESSOR=gz packpack/packpack tarball
diff --git a/.travis.yml b/.travis.yml
index e94d02ef5f..4b39dbd56d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,6 +17,9 @@ cache:
 git:
     depth: 100500
 
+env: >
+    TEST_RUN_EXTRA_PARAMS="-j 1"
+
 jobs:
     include:
       # Testing targets (just run tests on Debian Stretch or OS X).
diff --git a/test/app-tap/console.skipcond b/test/app-tap/console.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/app-tap/console.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app-tap/debug.skipcond b/test/app-tap/debug.skipcond
new file mode 100644
index 0000000000..7950a5d93b
--- /dev/null
+++ b/test/app-tap/debug.skipcond
@@ -0,0 +1,8 @@
+import platform
+
+# Disabled on FreeBSD due to fail #4271:
+#   Data segment size exceeds process limit
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app-tap/http_client.skipcond b/test/app-tap/http_client.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/app-tap/http_client.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app-tap/minimal.skipcond b/test/app-tap/minimal.skipcond
new file mode 100644
index 0000000000..7950a5d93b
--- /dev/null
+++ b/test/app-tap/minimal.skipcond
@@ -0,0 +1,8 @@
+import platform
+
+# Disabled on FreeBSD due to fail #4271:
+#   Data segment size exceeds process limit
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app-tap/pwd.skipcond b/test/app-tap/pwd.skipcond
new file mode 100644
index 0000000000..7950a5d93b
--- /dev/null
+++ b/test/app-tap/pwd.skipcond
@@ -0,0 +1,8 @@
+import platform
+
+# Disabled on FreeBSD due to fail #4271:
+#   Data segment size exceeds process limit
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app-tap/tarantoolctl.skipcond b/test/app-tap/tarantoolctl.skipcond
new file mode 100644
index 0000000000..7950a5d93b
--- /dev/null
+++ b/test/app-tap/tarantoolctl.skipcond
@@ -0,0 +1,8 @@
+import platform
+
+# Disabled on FreeBSD due to fail #4271:
+#   Data segment size exceeds process limit
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app/crypto.skipcond b/test/app/crypto.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/app/crypto.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app/digest.skipcond b/test/app/digest.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/app/digest.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/app/socket.skipcond b/test/app/socket.skipcond
index 89a293f81f..774b7e01ae 100644
--- a/test/app/socket.skipcond
+++ b/test/app/socket.skipcond
@@ -5,6 +5,7 @@ import os.path
 import socket
 import os
 import tempfile
+import platform
 
 test_dir = tempfile.mkdtemp(prefix='tarantool-test-socket')
 test_path = os.path.join(test_dir, 'socket')
@@ -20,3 +21,7 @@ s.close()
 if os.path.exists(test_path):
     os.remove(test_path)
     os.rmdir(test_dir)
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
diff --git a/test/box-tap/cfg.skipcond b/test/box-tap/cfg.skipcond
new file mode 100644
index 0000000000..7950a5d93b
--- /dev/null
+++ b/test/box-tap/cfg.skipcond
@@ -0,0 +1,8 @@
+import platform
+
+# Disabled on FreeBSD due to fail #4271:
+#   Data segment size exceeds process limit
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/box/net.box.skipcond b/test/box/net.box.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/box/net.box.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/box/net_msg_max.skipcond b/test/box/net_msg_max.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/box/net_msg_max.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/replication/misc.skipcond b/test/replication/misc.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/replication/misc.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/replication/skip_conflict_row.skipcond b/test/replication/skip_conflict_row.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/replication/skip_conflict_row.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
diff --git a/test/wal_off/snapshot_stress.skipcond b/test/wal_off/snapshot_stress.skipcond
new file mode 100644
index 0000000000..48e17903e8
--- /dev/null
+++ b/test/wal_off/snapshot_stress.skipcond
@@ -0,0 +1,7 @@
+import platform
+
+# Disabled on FreeBSD due to flaky fail #4271.
+if platform.system() == 'FreeBSD':
+    self.skip = 1
+
+# vim: set ft=python:
-- 
GitLab