Add examples to installation

Summary:
Examples are added in release/examples directory. Each example
must have its own directory with populate.cyp file inside it.
This file contains graph creation queries written in OpenCypher.
When memgraph is built, database snapshots for each example are
created in release/examples/build directory. During memgraph
installation these snapshots are copied to share/memgraph/examples.

Reviewers: teon.banek, mferencevic

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1036
This commit is contained in:
Marko Culinovic 2017-12-12 13:34:27 +01:00
parent eb272f0b67
commit 52a9be3cc8
7 changed files with 4671 additions and 0 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@
Testing/
build
build/
release/examples/build
cmake-build-*
cmake/DownloadProject/
dist/

View File

@ -220,6 +220,7 @@ set(CPACK_DEBIAN_PACKAGE_HOMEPAGE https://memgraph.com)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/conffiles;"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/copyright;"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/prerm;"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postrm;"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postinst;")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

View File

@ -27,6 +27,8 @@ case "$1" in
chmod 750 /var/lib/memgraph || exit 1
chown memgraph:adm /var/log/memgraph || exit 1
chmod 750 /var/log/memgraph || exit 1
# Make examples directory immutable (optional)
chattr +i -R /usr/share/memgraph/examples || true
;;
abort-upgrade|abort-remove|abort-deconfigure)

View File

@ -18,6 +18,8 @@ set -e
case "$1" in
remove|upgrade|deconfigure|failed-upgrade)
# Remove optional immutability from examples directory to allow removal
chattr -i -R /usr/share/memgraph/examples || true
if [ -d /run/systemd/system ]; then
deb-systemd-invoke stop memgraph.service >/dev/null
fi

44
release/examples/build_examples Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash -e
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
cd ../../build/
./memgraph --durability-directory "$script_dir/$snapshots_dir/" \
--snapshot-on-exit > /dev/null 2>&1 &
memgraph_pid=$!
sleep 2 # wait for memgraph to start
cd tests/manual
# create data using bolt-client
./bolt_client < "$script_dir/$dir/$query" > /dev/null 2>&1 || exit 1
# kill memgraph
kill $memgraph_pid
# wait for memgraph to terminate
wait $memgraph_pid
done

File diff suppressed because it is too large Load Diff

View File

@ -118,3 +118,9 @@ install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE.md
install(FILES ${CMAKE_SOURCE_DIR}/release/memgraph.service
DESTINATION /lib/systemd/system)
# Install examples
set(examples ${CMAKE_SOURCE_DIR}/release/examples)
install(CODE "execute_process(COMMAND ${examples}/build_examples
WORKING_DIRECTORY ${examples})")
install(DIRECTORY ${examples}/build/ DESTINATION share/memgraph/examples)