2019-01-14 23:34:45 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-01-21 18:10:32 +08:00
|
|
|
## Helper functions
|
|
|
|
|
|
|
|
function wait_for_server {
|
|
|
|
port=$1
|
|
|
|
while ! nc -z -w 1 127.0.0.1 $port; do
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
|
2019-01-14 23:34:45 +08:00
|
|
|
function echo_info { printf "\033[1;36m~~ $1 ~~\033[0m\n"; }
|
|
|
|
function echo_success { printf "\033[1;32m~~ $1 ~~\033[0m\n\n"; }
|
|
|
|
function echo_failure { printf "\033[1;31m~~ $1 ~~\033[0m\n\n"; }
|
|
|
|
|
|
|
|
## Environment setup
|
|
|
|
|
|
|
|
# Get script location.
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
cd "$DIR"
|
|
|
|
|
|
|
|
# Find memgraph binaries.
|
2019-03-12 21:06:14 +08:00
|
|
|
binary_dir="$DIR/../../../../build"
|
2019-01-14 23:34:45 +08:00
|
|
|
if [ ! -d $binary_dir ]; then
|
2019-03-12 21:06:14 +08:00
|
|
|
binary_dir="$DIR/../../../../build_release"
|
2019-01-14 23:34:45 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Results for apollo
|
|
|
|
RESULTS="$DIR/.apollo_measurements"
|
|
|
|
|
|
|
|
# Benchmark parameters
|
2019-01-16 18:30:15 +08:00
|
|
|
DURATION=10
|
2019-01-14 23:34:45 +08:00
|
|
|
|
2019-01-31 20:40:17 +08:00
|
|
|
# Startup
|
2019-01-14 23:34:45 +08:00
|
|
|
declare -a HA_PIDS
|
|
|
|
|
|
|
|
for server_id in 1 2 3
|
|
|
|
do
|
|
|
|
$binary_dir/memgraph_ha --server_id $server_id \
|
|
|
|
--coordination_config_file="coordination.json" \
|
|
|
|
--raft_config_file="raft.json" \
|
|
|
|
--port $((7686 + $server_id)) \
|
2019-01-16 17:40:06 +08:00
|
|
|
--db-recover-on-startup=false \
|
2019-01-14 23:34:45 +08:00
|
|
|
--durability_directory=dur$server_id &
|
|
|
|
HA_PIDS[$server_id]=$!
|
2019-01-21 18:10:32 +08:00
|
|
|
wait_for_server $((7686 + $server_id))
|
2019-01-14 23:34:45 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
# Allow some time for leader election.
|
2019-01-21 18:10:32 +08:00
|
|
|
sleep 10
|
2019-01-14 23:34:45 +08:00
|
|
|
|
|
|
|
# Start the memgraph process and wait for it to start.
|
2019-03-12 21:06:14 +08:00
|
|
|
echo_info "Starting HA read benchmark"
|
|
|
|
$binary_dir/tests/feature_benchmark/ha/read/benchmark \
|
2019-01-16 18:30:15 +08:00
|
|
|
--duration=$DURATION \
|
2019-01-14 23:34:45 +08:00
|
|
|
--output-file=$RESULTS &
|
|
|
|
pid=$!
|
|
|
|
|
|
|
|
wait -n $pid
|
|
|
|
code=$?
|
|
|
|
|
|
|
|
# Shutdown
|
|
|
|
for server_id in 1 2 3
|
|
|
|
do
|
2019-02-12 15:45:52 +08:00
|
|
|
kill -15 ${HA_PIDS[$server_id]}
|
2019-01-14 23:34:45 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
for server_id in 1 2 3
|
|
|
|
do
|
|
|
|
wait -n ${HA_PIDS[$server_id]}
|
|
|
|
rm -r dur$server_id
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $code -eq 0 ]; then
|
|
|
|
echo_success "Benchmark finished successfully"
|
|
|
|
else
|
|
|
|
echo_failure "Benchmark didn't finish successfully"
|
|
|
|
exit $code
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|