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:
parent
eb272f0b67
commit
52a9be3cc8
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@
|
||||
Testing/
|
||||
build
|
||||
build/
|
||||
release/examples/build
|
||||
cmake-build-*
|
||||
cmake/DownloadProject/
|
||||
dist/
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
44
release/examples/build_examples
Executable 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
|
4615
release/examples/queries/TEDTalk/populate.cyp
Normal file
4615
release/examples/queries/TEDTalk/populate.cyp
Normal file
File diff suppressed because it is too large
Load Diff
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user