blob: 1f707604eaa0421cece61b2a7d27c65d31ae9bc3 [file]
name: Server backend tests
on:
workflow_call:
inputs:
backend:
type: string
required: true
java-versions:
type: string
required: true
permissions:
contents: read
jobs:
build-server:
name: Server ${{ inputs.backend }} tests (Java ${{ matrix.JAVA_VERSION }})
runs-on: ubuntu-24.04
env:
USE_STAGE: 'false' # Whether to include the stage repository.
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
REPORT_DIR: target/site/jacoco
BACKEND: ${{ inputs.backend }}
TRIGGER_BRANCH_NAME: ${{ github.ref_name }}
HEAD_BRANCH_NAME: ${{ github.head_ref }}
BASE_BRANCH_NAME: ${{ github.base_ref }}
TARGET_BRANCH_NAME: ${{ github.base_ref != '' && github.base_ref || github.ref_name }}
# Long TP suites run only on dedicated validation branches.
RUN_TINKERPOP_TESTS: >-
${{
startsWith(github.ref_name, 'release-') ||
startsWith(github.ref_name, 'test-') ||
startsWith(github.ref_name, 'tinkerpop-') ||
startsWith(github.head_ref, 'release-') ||
startsWith(github.head_ref, 'test-') ||
startsWith(github.head_ref, 'tinkerpop-') ||
startsWith(github.base_ref, 'release-') ||
startsWith(github.base_ref, 'test-') ||
startsWith(github.base_ref, 'tinkerpop-')
}}
RAFT_MODE: ${{ startsWith(github.ref_name, 'raft-') || startsWith(github.head_ref, 'raft-') }}
strategy:
fail-fast: false
matrix:
JAVA_VERSION: ${{ fromJSON(inputs.java-versions) }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 5
- name: Prepare HBase container
if: inputs.backend == 'hbase'
run: $TRAVIS_DIR/install-backend.sh hbase
- name: Install Java ${{ matrix.JAVA_VERSION }}
uses: actions/setup-java@v6
with:
java-version: ${{ matrix.JAVA_VERSION }}
distribution: 'zulu'
cache: maven
cache-jdk: false
- name: Use staged maven repo settings
if: ${{ env.USE_STAGE == 'true' }}
run: |
cp $HOME/.m2/settings.xml /tmp/settings.xml
cp -vf .github/configs/settings.xml $HOME/.m2/settings.xml && cat $HOME/.m2/settings.xml
- name: Compile
run: |
mvn clean compile -pl hugegraph-server/hugegraph-test -am -U -Dmaven.javadoc.skip=true -ntp
- name: Check startup and native runtime contracts
if: inputs.backend == 'rocksdb'
run: |
"$TRAVIS_DIR/test-wait-storage.sh"
"$TRAVIS_DIR/test-start-server.sh"
"$TRAVIS_DIR/test-riscv64-java-runtime.sh"
bash "$TRAVIS_DIR/test-tinkerpop-reports.sh"
- name: Validate Docker integration
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
bash hugegraph-server/hugegraph-dist/docker/docker-entrypoint-test.sh
bash docker/test-compose.sh render
- name: Run check_port unit tests
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
# Validates the ss/netstat port preflight that replaced lsof
$TRAVIS_DIR/test-check-port.sh \
hugegraph-server/hugegraph-dist/src/assembly/static \
hugegraph-store/hg-store-dist/src/assembly/static/bin/util.sh
- name: Run Java security properties tests
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
mvn package -Dmaven.test.skip=true -pl hugegraph-server/hugegraph-dist -am -ntp
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
$TRAVIS_DIR/test-java-security-properties.sh \
"$SERVER_DIR" "$GITHUB_WORKSPACE"
- name: Check bundled Arthas local CLI
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION
bash "$TRAVIS_DIR/test-arthas-cli.sh" "$SERVER_DIR"
- name: Verify Surefire single-class routing
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
SUREFIRE_DIR=hugegraph-server/hugegraph-test/target/surefire-reports
REPORT="$SUREFIRE_DIR/TEST-org.apache.hugegraph.unit.auth.HugeGraphAuthProxyTest.xml"
rm -f "$REPORT"
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
mvn test -pl hugegraph-server/hugegraph-test -am \
-P unit-test -Dtest=HugeGraphAuthProxyTest -ntp 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
test -s "$REPORT" || {
echo "::error::Server single-class test produced no report"
exit 1
}
NEGATIVE_LOG=$(mktemp)
trap 'rm -f "$NEGATIVE_LOG"' EXIT
if mvn test -pl hugegraph-server/hugegraph-test -am \
-P unit-test -Dtest=NoSuchJava17ContractTest -ntp \
>"$NEGATIVE_LOG" 2>&1; then
cat "$NEGATIVE_LOG"
echo "::error::Surefire accepted a missing Server test class"
exit 1
fi
cat "$NEGATIVE_LOG"
grep -Fq 'No tests matching pattern "NoSuchJava17ContractTest"' \
"$NEGATIVE_LOG"
grep -Fq '(unit-test) @ hugegraph-test' "$NEGATIVE_LOG"
- name: Check startup test prerequisites
id: server-preflight
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
# Note: lsof removed from prerequisites; check_port now uses ss, falling back
# to netstat, and warns without blocking when neither can answer.
# This job always runs on Linux (ubuntu-24.04), which uses fuser for port cleanup.
for tool in crontab curl java; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "can_run=false" >> "$GITHUB_OUTPUT"
echo "skip_reason=missing tool: $tool" >> "$GITHUB_OUTPUT"
exit 1
fi
done
if ! command -v fuser >/dev/null 2>&1; then
echo "can_run=false" >> "$GITHUB_OUTPUT"
echo "skip_reason=missing tool: fuser (required for Linux port cleanup)" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "can_run=true" >> "$GITHUB_OUTPUT"
- name: Run start-hugegraph.sh foreground mode tests
if: ${{ env.BACKEND == 'rocksdb' && steps.server-preflight.outputs.can_run == 'true' }}
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
bash $TRAVIS_DIR/test-ci-service-utils.sh "$TRAVIS_DIR/ci-service-utils.sh"
bash $TRAVIS_DIR/test-launcher-gc.sh "$GITHUB_WORKSPACE"
bash $TRAVIS_DIR/test-cgroup-memory.sh "$SERVER_DIR/bin/util.sh"
bash $TRAVIS_DIR/test-start-hugegraph-signal.sh "$SERVER_DIR/bin/start-hugegraph.sh"
$TRAVIS_DIR/test-start-hugegraph.sh $SERVER_DIR
- name: Startup tests skipped (missing prerequisites)
if: ${{ env.BACKEND == 'rocksdb' && steps.server-preflight.outputs.can_run == 'false' }}
run: |
echo "::notice::Server startup tests skipped — ${{ steps.server-preflight.outputs.skip_reason }}"
- name: Run unit test
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
$TRAVIS_DIR/run-unit-test.sh $BACKEND 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
- name: Run core test
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
$TRAVIS_DIR/run-core-test.sh $BACKEND 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
- name: Run api test
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
{
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
} 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
# TODO: disable raft test in normal PR due to the always timeout problem
- name: Run raft test
if: ${{ env.RAFT_MODE == 'true' && env.BACKEND == 'rocksdb' }}
timeout-minutes: 45
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
$TRAVIS_DIR/run-api-test-for-raft.sh $BACKEND $REPORT_DIR 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
- name: Run TinkerPop structure test
if: ${{ env.RUN_TINKERPOP_TESTS == 'true' && (env.BACKEND == 'memory' || env.BACKEND == 'rocksdb') }}
timeout-minutes: 60
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND structure 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
- name: Run TinkerPop process test
if: ${{ env.RUN_TINKERPOP_TESTS == 'true' && (env.BACKEND == 'memory' || env.BACKEND == 'rocksdb') }}
timeout-minutes: 180
run: |
set -o pipefail
RUNTIME_LOG=$(mktemp "$RUNNER_TEMP/java-runtime.XXXXXX")
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND process 2>&1 | tee "$RUNTIME_LOG"
bash "$TRAVIS_DIR/check-java-runtime-logs.sh" "$RUNTIME_LOG"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.REPORT_DIR }}/*.xml,hugegraph-server/target/site/jacoco/jacoco.xml
flags: server_${{ inputs.backend }}
disable_search: true
fail_ci_if_error: false
- name: Stop HBase container
if: ${{ always() && inputs.backend == 'hbase' }}
run: |
"$TRAVIS_DIR/install-hbase.sh" stop