Skip to content
8 changes: 6 additions & 2 deletions .github/workflows/server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ jobs:

- name: Run api test
run: |
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
if [ "$BACKEND" = "rocksdb" ]; then
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR true
else
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
fi

# TODO: disable raft test in normal PR due to the always timeout problem
- name: Run raft test
Expand Down Expand Up @@ -154,7 +158,7 @@ jobs:

- name: Run RocksDB API test
run: |
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR true

- name: Show server log on failure
if: failure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set -ev
BACKEND=$1
REPORT_DIR=$2
REPORT_FILE=$REPORT_DIR/jacoco-api-test-for-raft.xml
RUN_GREMLIN_CONSOLE_SMOKE_TEST=${3:-false}

TRAVIS_DIR=$(cd "$(dirname "$0")" && pwd)
REPO_ROOT=$(cd "$TRAVIS_DIR/../../../../.." && pwd)
Expand Down Expand Up @@ -98,6 +99,11 @@ $TRAVIS_DIR/start-server.sh $SERVER_DIR $BACKEND $JACOCO_PORT || (cat $SERVER_DI
# run api-test
mvn test -pl hugegraph-server/hugegraph-test -am -P api-test,$BACKEND || (cat $SERVER_DIR/logs/hugegraph-server.log && exit 1)

if [ "$RUN_GREMLIN_CONSOLE_SMOKE_TEST" == "true" ]; then
bash "$TRAVIS_DIR/run-gremlin-console-smoke-test.sh" "$SERVER_DIR" || \
(cat "$SERVER_DIR/logs/hugegraph-server.log" && exit 1)
fi

$TRAVIS_DIR/build-report.sh $BACKEND $JACOCO_PORT $REPORT_FILE

# stop server
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -euo pipefail

SERVER_DIR=${1:?Usage: run-gremlin-console-smoke-test.sh <server-dir>}
SMOKE_MARKER="gremlin-console-smoke-ok"
REMOTE_CONFIG="$SERVER_DIR/conf/remote.yaml"

if [ ! -d "$SERVER_DIR" ]; then
echo "Server directory does not exist: $SERVER_DIR"
exit 1
fi

if [ ! -x "$SERVER_DIR/bin/gremlin-console.sh" ]; then
echo "Gremlin Console script is not executable: $SERVER_DIR/bin/gremlin-console.sh"
exit 1
fi

if [ ! -f "$REMOTE_CONFIG" ]; then
echo "Gremlin Console remote config does not exist: $REMOTE_CONFIG"
exit 1
fi

TMP_DIR=${TMPDIR:-/tmp}
TMP_WORK_DIR=$(mktemp -d "${TMP_DIR}/hugegraph-gremlin-console-smoke.XXXXXX")
REMOTE_CONFIG_BACKUP="${TMP_WORK_DIR}/remote.yaml.orig"
SMOKE_SCRIPT="${TMP_WORK_DIR}/smoke.groovy"
SMOKE_LOG="${TMP_WORK_DIR}/smoke.log"

cleanup() {
if [ -f "$REMOTE_CONFIG_BACKUP" ]; then
cp "$REMOTE_CONFIG_BACKUP" "$REMOTE_CONFIG"
fi
rm -rf "$TMP_WORK_DIR"
}
trap cleanup EXIT

cp "$REMOTE_CONFIG" "$REMOTE_CONFIG_BACKUP"
cat >> "$REMOTE_CONFIG" <<EOF

username: admin
password: pa
EOF

cat > "$SMOKE_SCRIPT" <<EOF
Comment thread
contrueCT marked this conversation as resolved.
import org.apache.tinkerpop.gremlin.driver.Cluster

cluster = Cluster.open('conf/remote.yaml')
client = cluster.connect().alias(['g': '__g_DEFAULT-hugegraph'])
try {
remoteScript = "def count = g.V().count().next(); " +
"if (count < 0L) " +
"throw new IllegalStateException('Unexpected vertex count: ' + count); " +
"'${SMOKE_MARKER}-' + count"
results = client.submit(remoteScript).all().get()
println(results[0].object)
} finally {
client.close()
cluster.close()
}
EOF

(
cd "$SERVER_DIR"
bin/gremlin-console.sh -- -e "$SMOKE_SCRIPT"
) | tee "$SMOKE_LOG"

grep -q "$SMOKE_MARKER" "$SMOKE_LOG"
Loading