2017-12-12 20:34:27 +08:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2018-03-27 23:14:09 +08:00
|
|
|
function print_help () {
|
2018-04-20 20:58:49 +08:00
|
|
|
echo "Usage: $0 MEMGRAPH_EXE BOLT_CLIENT_EXE"
|
2018-03-27 23:14:09 +08:00
|
|
|
echo "Build example snapshots using the compiled memgraph."
|
|
|
|
}
|
|
|
|
|
2018-04-20 20:58:49 +08:00
|
|
|
if [[ $# -ne 2 ]]; then
|
2018-03-27 23:14:09 +08:00
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-04-20 20:58:49 +08:00
|
|
|
memgraph_exe="$1"
|
2018-03-27 23:14:09 +08:00
|
|
|
if [[ ! -x ${memgraph_exe} ]]; then
|
|
|
|
echo "Expected memgraph executable at '${memgraph_exe}'"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-04-20 20:58:49 +08:00
|
|
|
bolt_client_exe="$2"
|
2018-03-27 23:14:09 +08:00
|
|
|
if [[ ! -x ${bolt_client_exe} ]]; then
|
|
|
|
echo "Expected bolt_client executable at '${bolt_client_exe}'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-12-12 20:34:27 +08:00
|
|
|
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
build_dir="build"
|
|
|
|
query="populate.cyp"
|
|
|
|
|
|
|
|
cd $script_dir
|
|
|
|
|
|
|
|
if [ -d "$build_dir" ]; then
|
|
|
|
rm -rf "$build_dir"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir "$build_dir"
|
|
|
|
|
|
|
|
for dir in queries/*/
|
|
|
|
do
|
|
|
|
cd $script_dir # position to script execution dir
|
|
|
|
|
|
|
|
dir=${dir%*/}
|
|
|
|
example=${dir#*/}
|
|
|
|
|
|
|
|
# create snapshots directory for each example
|
|
|
|
snapshots_dir="$build_dir/$example"
|
|
|
|
mkdir -p "$snapshots_dir"
|
|
|
|
|
|
|
|
# run memgraph with durability_directory pointing
|
|
|
|
# to examples snapshots_dir
|
2018-03-27 23:14:09 +08:00
|
|
|
${memgraph_exe} --durability-directory "$script_dir/$snapshots_dir/" \
|
|
|
|
--snapshot-on-exit > /dev/null 2>&1 &
|
2017-12-12 20:34:27 +08:00
|
|
|
memgraph_pid=$!
|
|
|
|
sleep 2 # wait for memgraph to start
|
|
|
|
|
|
|
|
# create data using bolt-client
|
2018-03-27 23:14:09 +08:00
|
|
|
${bolt_client_exe} < "$script_dir/$dir/$query" > /dev/null 2>&1 || exit 1
|
2017-12-12 20:34:27 +08:00
|
|
|
|
|
|
|
# kill memgraph
|
|
|
|
kill $memgraph_pid
|
|
|
|
|
|
|
|
# wait for memgraph to terminate
|
|
|
|
wait $memgraph_pid
|
|
|
|
done
|