From a8e89b7736bb52aa28b720c8bf9a671207fb213d Mon Sep 17 00:00:00 2001
From: Sergey Bronnikov <sergeyb@tarantool.org>
Date: Tue, 15 Sep 2020 12:23:03 +0000
Subject: [PATCH] ci: integrate Jepsen tests to GitLab CI

added a new stage with a single job to run Jepsen tests.
Job is not started automatically by default, one need to
trigger it manually. Directory with test results
(logs, graphs, operations history) published to artifacts.

Closes #5277
---
 .gitlab-ci.yml | 14 ++++++++++++++
 .travis.mk     | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 712e248fec..16528c1dce 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,7 @@
 stages:
   - static_analysis
   - test
+  - long_tests
   - perf
   - cleanup
 
@@ -213,6 +214,19 @@ freebsd_12_release:
     - ${GITLAB_MAKE} vms_start
     - ${GITLAB_MAKE} vms_test_freebsd
 
+jepsen:
+  <<: *docker_test_definition
+  script:
+    - ${GITLAB_MAKE} test_jepsen
+  stage: long_tests
+  when: manual
+  tags:
+    - mcs_jepsen_docker
+  artifacts:
+    paths:
+      - jepsen-tests-prefix/src/jepsen-tests/store
+    expire_in: 6 month
+
 # ####
 # Perf
 # ####
diff --git a/.travis.mk b/.travis.mk
index 58d0c15969..d8f97ef5c8 100644
--- a/.travis.mk
+++ b/.travis.mk
@@ -8,6 +8,12 @@ TEST_RUN_EXTRA_PARAMS?=
 MAX_FILES?=65534
 MAX_PROC?=2500
 OOS_SRC_PATH="/source"
+BIN_DIR=/usr/local/bin
+
+CLOJURE_URL="https://download.clojure.org/install/linux-install-1.10.1.561.sh"
+LEIN_URL="https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein"
+TERRAFORM_NAME="terraform_0.13.1_linux_amd64.zip"
+TERRAFORM_URL="https://releases.hashicorp.com/terraform/0.13.1/"$(TERRAFORM_NAME)
 
 all: package
 
@@ -76,6 +82,25 @@ deps_buster_clang_8: deps_debian
 	apt-get update
 	apt-get install -y clang-8 llvm-8-dev
 
+deps_debian_jepsen: $(BIN_DIR)/clojure $(BIN_DIR)/lein $(BIN_DIR)/terraform
+	apt-get update ${APT_EXTRA_FLAGS} && apt-get install -y -f \
+		openjdk-8-jre openjdk-8-jre-headless libjna-java gnuplot graphviz \
+		zip unzip openssh-client jq
+
+$(BIN_DIR)/clojure:
+	curl $(CLOJURE_URL) | sudo bash
+
+$(BIN_DIR)/lein:
+	curl $(LEIN_URL) > $@
+	chmod a+x $@
+
+$(BIN_DIR)/terraform:
+	apt-get update ${APT_EXTRA_FLAGS} && apt-get install -y -f \
+		unzip
+	curl -O $(TERRAFORM_URL)
+	unzip -o $(TERRAFORM_NAME) terraform -d $(dir $@)
+	rm -f $(TERRAFORM_NAME)
+
 # Release
 
 configure_debian:
@@ -262,3 +287,11 @@ test_freebsd_no_deps: build_freebsd
 	cd test && python2.7 test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
 
 test_freebsd: deps_freebsd test_freebsd_no_deps
+
+# ###################
+# Jepsen testing
+# ###################
+
+test_jepsen: deps_debian_jepsen
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON
+	make jepsen-single
-- 
GitLab