memgraph/run
Mislav Bradac 16d8a5b447 Refactor scripts
Reviewers: buda, teon.banek, florijan

Reviewed By: teon.banek

Differential Revision: https://phabricator.memgraph.io/D313
2017-04-26 14:51:56 +02:00

91 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
function print_usage_and_exit {
echo "./run [--unstable] [--no-test-hardcoded]"
echo "Optional arguments:"
echo -e " --unstable\trun unstable scenarios"
echo -e " --no-test-hardcoded\tdon't run dressipi tests"
exit 1
}
# read arguments
unstable=false
test_hardcoded=true
while [[ $# -gt 0 ]]; do
case $1 in
--unstable)
unstable=true
shift
;;
--no-test-hardcoded)
test_hardcoded=false
shift
;;
*)
# unknown option
print_usage_and_exit
;;
esac
done
# exit if any subcommand returns a non-zero status
set -e
## build memgraph
# save the path where this script is
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
memgraph_src_dir=${script_dir}/dbms/memgraph
memgraph_build_dir=${script_dir}/dbms/memgraph/build
# activate virtualenv
source $script_dir/ve3/bin/activate
function cleanup_and_exit {
pkill -9 -f "${binary_name}"
exit $1
}
cd ${memgraph_build_dir}
# binary is available after the build
binary_name=$(find ${memgraph_build_dir}/ -maxdepth 1 -executable -name "memgraph*")
# the script has to be careful because memgraph process will be detached
set +e
# run dressipi tests
if [[ $test_hardcoded = true ]]; then
# get full path to memgraph config for hardcoded queries
hardcoded_queries_config_path="${memgraph_src_dir}/config/hardcoded_queries_memgraph.yaml"
# run memgraph
MEMGRAPH_CONFIG=${hardcoded_queries_config_path} ${binary_name} 1>&2 &
# run Dressipi test
cd ${script_dir}/tests/pilot_dressipi
python run.py
exit_code=$?
if [[ ${exit_code} != 0 ]]; then
cleanup_and_exit ${exit_code}
fi
# kill memgraph for hardcoded queries
pkill -9 -f "${binary_name}"
fi
# get full path to memgraph config for interpreted queries
config_path="${memgraph_src_dir}/config/memgraph.yaml"
# run memgraph
MEMGRAPH_CONFIG=${config_path} ${binary_name} 1>&2 &
# run custom scenarios
cd ${script_dir}
tck_flags="--root tck_engine/tests/memgraph_V1/features
--graphs-root tck_engine/tests/memgraph_V1/graphs
--no-side-effects
--db memgraph"
if [[ $unstable = true ]]; then
tck_flags="$tck_flags --unstable"
fi
python tck_engine/test_executor.py $tck_flags
cleanup_and_exit ${exit_code}