memgraph/tests/jepsen/setup-local-docker-cluster.sh
antonio2368 60d742a2dc Jepsen test infrastracture improvements and bank test (#62)
* Define replication config for tests

* Add support for final generator

* Add bank test

* Add host name resolution and basic replication setup

* Add timeout support

* Define helper macros for replication tests

* Add nemesis configuration
2021-01-21 15:56:21 +01:00

56 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
set -Eeuo pipefail
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# NOTE: docker and docker-compose have to be installed on the system.
if [ ! -d "$script_dir/jepsen" ]; then
git clone https://github.com/jepsen-io/jepsen.git -b "0.2.1" "$script_dir/jepsen"
fi
# Initialize testing context by copying source/binary files. Inside CI,
# Memgraph is tested on a single machine cluster based on Docker containers.
# Once these tests will be part of the official Jepsen repo, the majority of
# functionalities inside this script won't be needed because each node clones
# the public repo.
case $1 in
# Start Jepsen Docker cluster.
up)
"$script_dir/jepsen/docker/bin/up" --daemon
;;
# Copy Memgraph Jepsen project files and Memgraph binary if specified.
copy)
shift 1
binary_path=$1
if [ -L "$binary_path" ]; then
binary_path=$(readlink "$binary_path")
fi
binary_name=$(basename -- "$binary_path")
# Copy Memgraph build binary.
docker exec jepsen-n1 mkdir -p /opt/memgraph
docker exec jepsen-n2 mkdir -p /opt/memgraph
docker exec jepsen-n3 mkdir -p /opt/memgraph
docker exec jepsen-n4 mkdir -p /opt/memgraph
docker exec jepsen-n5 mkdir -p /opt/memgraph
docker cp "$binary_path" jepsen-n1:/opt/memgraph/"$binary_name"
docker exec jepsen-n1 bash -c "rm -f /opt/memgraph/memgraph && ln -s /opt/memgraph/$binary_name /opt/memgraph/memgraph"
docker cp "$binary_path" jepsen-n2:/opt/memgraph/"$binary_name"
docker exec jepsen-n2 bash -c "rm -f /opt/memgraph/memgraph && ln -s /opt/memgraph/$binary_name /opt/memgraph/memgraph"
docker cp "$binary_path" jepsen-n3:/opt/memgraph/"$binary_name"
docker exec jepsen-n3 bash -c "rm -f /opt/memgraph/memgraph && ln -s /opt/memgraph/$binary_name /opt/memgraph/memgraph"
docker cp "$binary_path" jepsen-n4:/opt/memgraph/"$binary_name"
docker exec jepsen-n4 bash -c "rm -f /opt/memgraph/memgraph && ln -s /opt/memgraph/$binary_name /opt/memgraph/memgraph"
docker cp "$binary_path" jepsen-n5:/opt/memgraph/"$binary_name"
docker exec jepsen-n5 bash -c "rm -f /opt/memgraph/memgraph && ln -s /opt/memgraph/$binary_name /opt/memgraph/memgraph"
# Copy tests/jepsen/memgraph required files into the control node.
docker exec jepsen-control mkdir -p /jepsen/memgraph
docker cp "$script_dir/src/." jepsen-control:/jepsen/memgraph/src/
docker cp "$script_dir/test/." jepsen-control:/jepsen/memgraph/test/
docker cp "$script_dir/resources/." jepsen-control:/jepsen/memgraph/resources/
docker cp "$script_dir/project.clj" jepsen-control:/jepsen/memgraph/project.clj
;;
esac