-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.sh
executable file
·101 lines (85 loc) · 2.33 KB
/
test.sh
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
#!/usr/bin/env bash
# Run a Jepsen test locally.
#
# Usage:
#
# ./test.sh setup
# ./test.sh run JEPSEN_ARGS
#
# `setup` should be run only once to launch and initialize the jepsen
# container. JEPSEN_ARGS are passed directly to Jepsen (you can omit --no-ssh
# and --binary). For `./test.sh run`, set the env var and DQLITE_BRANCH to
# control which dqlite is built, e.g. DQLITE_BRANCH=cole/fix will build the
# `fix` branch of https://github.com/cole-miller/dqlite.
set -o errexit -o pipefail -o nounset
jepsen=jepsen
workspace=/root/workspace
push-this-repo() {
parent="$(dirname "${BASH_SOURCE[0]}")"
lxc file push -p -r "$parent"/* "$jepsen$workspace/jepsen.dqlite"
}
setup-inner() {
echo Set disable_coredump false >>/etc/sudo.conf
echo Defaults rlimit_core=infinity >/etc/sudoers.d/99-core
apt update
apt install -y \
autoconf \
build-essential \
git \
gnuplot \
graphviz \
iptables \
leiningen \
libjna-java \
liblz4-dev \
libsqlite3-dev \
libtool \
libuv1-dev \
make \
pkg-config \
snapd
snap install go --classic
pushd "$workspace"
git clone -o canonical https://github.com/canonical/dqlite
pushd dqlite
git remote add cole https://github.com/cole-miller/dqlite
git remote add mathieu https://github.com/MathieuBordere/dqlite
git remote add mohamed https://github.com/mwnsiri/dqlite
popd
popd
}
setup() {
lxc launch images:ubuntu/22.04 jepsen -c limits.kernel.core=-1
sleep 5
push-this-repo
lxc exec "$jepsen" -- "$workspace/jepsen.dqlite/test.sh" setup-inner "$@"
}
run-inner() {
pushd "$workspace"
pushd dqlite
git fetch --all
git checkout "$DQLITE_BRANCH"
autoreconf -i
./configure --enable-debug --enable-build-raft
make -j"$(nproc)"
make install
popd
pushd jepsen.dqlite
ip link show jepsen-br >/dev/null 2>&1 || resources/network.sh setup 5
go get golang.org/x/sync/semaphore
go get -tags libsqlite3 github.com/canonical/go-dqlite/app
ldconfig
CGO_LDFLAGS_ALLOW='-Wl,-z,now' go build -tags libsqlite3 -o resources/app resources/app.go
lein run test --no-ssh --binary "$(pwd)/resources/app" "$@"
popd
popd
}
run() {
test "$(sysctl -n kernel.core_pattern)" = core || exit 1
test "$(sysctl -n fs.suid_dumpable)" -gt 0 || exit 1
push-this-repo
lxc exec $jepsen -- \
env DQLITE_BRANCH="${DQLITE_BRANCH:-canonical/master}" \
"$workspace/jepsen.dqlite/test.sh" run-inner "$@"
}
"$@"