|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2020 Alibaba Group Holding Limited. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +set -e |
| 16 | +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) |
| 17 | +FLEX_HOME=${SCRIPT_DIR}/../../ |
| 18 | +BULK_LOADER=${FLEX_HOME}/build/bin/bulk_loader |
| 19 | +SERVER_BIN=${FLEX_HOME}/build/bin/interactive_server |
| 20 | +GIE_HOME=${FLEX_HOME}/../interactive_engine/ |
| 21 | + |
| 22 | +# |
| 23 | +if [ $# -ne 3 ]; then |
| 24 | + echo "Receives: $# args, need 3 args" |
| 25 | + echo "Usage: $0 <INTERACTIVE_WORKSPACE> <GRAPH_NAME> <ENGINE_CONFIG>" |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +INTERACTIVE_WORKSPACE=$1 |
| 30 | +GRAPH_NAME=$2 |
| 31 | +ENGINE_CONFIG_PATH=$3 |
| 32 | +# if ENGINE_CONFIG_PATH is not absolute path, convert it to absolute path |
| 33 | +if [[ ! ${ENGINE_CONFIG_PATH} == /* ]]; then |
| 34 | + ENGINE_CONFIG_PATH=$(cd $(dirname ${ENGINE_CONFIG_PATH}) && pwd)/$(basename ${ENGINE_CONFIG_PATH}) |
| 35 | +fi |
| 36 | + |
| 37 | + |
| 38 | +if [ ! -d ${INTERACTIVE_WORKSPACE} ]; then |
| 39 | + echo "INTERACTIVE_WORKSPACE: ${INTERACTIVE_WORKSPACE} not exists" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +if [ ! -d ${INTERACTIVE_WORKSPACE}/data/${GRAPH_NAME} ]; then |
| 44 | + echo "GRAPH: ${GRAPH_NAME} not exists" |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | +if [ ! -f ${INTERACTIVE_WORKSPACE}/data/${GRAPH_NAME}/graph.yaml ]; then |
| 48 | + echo "GRAPH_SCHEMA_FILE: ${BULK_LOAD_FILE} not exists" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | +if [ ! -f ${ENGINE_CONFIG_PATH} ]; then |
| 52 | + echo "ENGINE_CONFIG: ${ENGINE_CONFIG_PATH} not exists" |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | + |
| 56 | +GRAPH_SCHEMA_YAML=${INTERACTIVE_WORKSPACE}/data/${GRAPH_NAME}/graph.yaml |
| 57 | +GRAPH_CSR_DATA_DIR=${INTERACTIVE_WORKSPACE}/data/${GRAPH_NAME}/indices |
| 58 | +rm -rf ${GRAPH_CSR_DATA_DIR}/wal |
| 59 | + |
| 60 | +RED='\033[0;31m' |
| 61 | +GREEN='\033[0;32m' |
| 62 | +NC='\033[0m' # No Color |
| 63 | +err() { |
| 64 | + echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] -ERROR- $* ${NC}" >&2 |
| 65 | +} |
| 66 | + |
| 67 | +info() { |
| 68 | + echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')] -INFO- $* ${NC}" |
| 69 | +} |
| 70 | + |
| 71 | + |
| 72 | +kill_service(){ |
| 73 | + info "Kill Service first" |
| 74 | + ps -ef | grep "com.alibaba.graphscope.GraphServer" | awk '{print $2}' | xargs kill -9 || true |
| 75 | + ps -ef | grep "interactive_server" | awk '{print $2}' | xargs kill -9 || true |
| 76 | + sleep 3 |
| 77 | + sed -i "s/default_graph: .*/default_graph: modern_graph/g" ${ENGINE_CONFIG_PATH} |
| 78 | + rm -rf ${INTERACTIVE_WORKSPACE}/METADATA || (err "rm METADATA failed") |
| 79 | + rm ${INTERACTIVE_WORKSPACE}/data/1 || (err "rm builtin graph failed") |
| 80 | + info "Kill Service success" |
| 81 | + rm -rf /tmp/neo4j-* || true |
| 82 | + # clean the wal |
| 83 | + rm -rf ${GRAPH_CSR_DATA_DIR}/wal || true |
| 84 | + rm -rf ${GRAPH_CSR_DATA_DIR}/runtime || true |
| 85 | +} |
| 86 | + |
| 87 | +# kill service when exit |
| 88 | +trap kill_service EXIT |
| 89 | + |
| 90 | + |
| 91 | +# start engine service and load ldbc graph |
| 92 | +start_engine_service(){ |
| 93 | + # suppose graph has been loaded, check ${GRAPH_CSR_DATA_DIR} exists |
| 94 | + rm -rf ${INTERACTIVE_WORKSPACE}/metadata/ |
| 95 | + rm ${INTERACTIVE_WORKSPACE}/data/1 || true |
| 96 | + if [ ! -d ${GRAPH_CSR_DATA_DIR} ]; then |
| 97 | + err "GRAPH_CSR_DATA_DIR not found" |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | + |
| 101 | + #check SERVER_BIN exists |
| 102 | + if [ ! -f ${SERVER_BIN} ]; then |
| 103 | + err "SERVER_BIN not found" |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + sed -i "s/default_graph: .*/default_graph: ${GRAPH_NAME}/g" ${ENGINE_CONFIG_PATH} |
| 107 | + |
| 108 | + cmd="${SERVER_BIN} -c ${ENGINE_CONFIG_PATH} " |
| 109 | + cmd="${cmd} -w ${INTERACTIVE_WORKSPACE} --enable-admin-service true --start-compiler true" |
| 110 | + |
| 111 | + info "Start engine service with command: ${cmd}" |
| 112 | + ${cmd} & |
| 113 | + sleep 5 |
| 114 | + #check interactive_server is running, if not, exit |
| 115 | + ps -ef | grep "interactive_server" | grep -v grep |
| 116 | + |
| 117 | + info "Start engine service success" |
| 118 | +} |
| 119 | + |
| 120 | + |
| 121 | +start_compiler_service(){ |
| 122 | + echo "try to start compiler service" |
| 123 | + pushd ${GIE_HOME}/compiler |
| 124 | + cmd="make run graph.schema=${GRAPH_SCHEMA_YAML} config.path=${ENGINE_CONFIG_PATH}" |
| 125 | + echo "Start compiler service with command: ${cmd}" |
| 126 | + ${cmd} & |
| 127 | + sleep 5 |
| 128 | + # check if Graph Server is running, if not exist |
| 129 | + ps -ef | grep "com.alibaba.graphscope.GraphServer" | grep -v grep |
| 130 | + info "Start compiler service success" |
| 131 | + popd |
| 132 | +} |
| 133 | + |
| 134 | +run_cypher_write_test(){ |
| 135 | + echo "run cypher write test" |
| 136 | + pushd ${GIE_HOME}/compiler |
| 137 | + cmd="mvn test -Dskip.ir.core=true -Dtest=com.alibaba.graphscope.cypher.integration.modern.ModernGraphWriteTest" |
| 138 | + echo "Run cypher write test with command: ${cmd}" |
| 139 | + ${cmd} |
| 140 | + info "Run cypher write test success" |
| 141 | + popd |
| 142 | +} |
| 143 | + |
| 144 | + |
| 145 | +kill_service |
| 146 | +start_engine_service |
| 147 | +start_compiler_service |
| 148 | +run_cypher_write_test |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | +kill_service |
0 commit comments