mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-14 17:08:31 +08:00
fix: test drift on go specific proxy scheme (#16796)
### Summary certain tests fail because of test drift and were fixed, other because of go issues --------- Co-authored-by: Wang Qi <wangq8@outlook.com>
This commit is contained in:
188
.github/workflows/sep-tests.yml
vendored
188
.github/workflows/sep-tests.yml
vendored
@@ -40,6 +40,7 @@ jobs:
|
||||
has_go_changes: ${{ steps.detect_changes.outputs.has_go_changes }}
|
||||
has_python_changes: ${{ steps.detect_changes.outputs.has_python_changes }}
|
||||
has_web_changes: ${{ steps.detect_changes.outputs.has_web_changes }}
|
||||
api_proxy_schemes: ${{ steps.detect_changes.outputs.api_proxy_schemes }}
|
||||
steps:
|
||||
- name: Ensure workspace ownership
|
||||
run: |
|
||||
@@ -176,16 +177,24 @@ jobs:
|
||||
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
|
||||
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }})
|
||||
else
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
||||
BASE_SHA="${{ github.event.before }}"
|
||||
if [[ -n "${BASE_SHA}" && ! "${BASE_SHA}" =~ ^0+$ ]]; then
|
||||
CHANGED_FILES=$(git diff --name-only "${BASE_SHA}" "${GITHUB_SHA}")
|
||||
else
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
||||
fi
|
||||
fi
|
||||
|
||||
while IFS= read -r file; do
|
||||
case "$file" in
|
||||
*.go|go.mod|go.sum) has_go=true ;;
|
||||
# Docker, test, SDK, and workflow changes can alter either server path.
|
||||
Dockerfile|docker/**|.github/workflows/**|test/**|sdk/**)
|
||||
has_go=true
|
||||
has_python=true
|
||||
;;
|
||||
*.go|go.mod|go.sum|build.sh) has_go=true ;;
|
||||
*.py|pyproject.toml|requirements*.txt) has_python=true ;;
|
||||
web/*) has_web=true ;;
|
||||
Dockerfile|docker-compose*.yml) has_go=true; has_python=true ;;
|
||||
build.sh) has_go=true ;;
|
||||
esac
|
||||
done <<< "$CHANGED_FILES"
|
||||
|
||||
@@ -196,10 +205,19 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$has_go" == "true" && "$has_python" == "true" ]]; then
|
||||
api_proxy_schemes='["go","python"]'
|
||||
elif [[ "$has_go" == "true" ]]; then
|
||||
api_proxy_schemes='["go"]'
|
||||
else
|
||||
api_proxy_schemes='["python"]'
|
||||
fi
|
||||
|
||||
echo "has_go_changes=${has_go}" >> $GITHUB_OUTPUT
|
||||
echo "has_python_changes=${has_python}" >> $GITHUB_OUTPUT
|
||||
echo "has_web_changes=${has_web}" >> $GITHUB_OUTPUT
|
||||
echo "Go: ${has_go}, Python: ${has_python}, Web: ${has_web}"
|
||||
echo "api_proxy_schemes=${api_proxy_schemes}" >> $GITHUB_OUTPUT
|
||||
echo "Go: ${has_go}, Python: ${has_python}, Web: ${has_web}, proxy schemes: ${api_proxy_schemes}"
|
||||
|
||||
- name: Prepare Python test environment
|
||||
if: steps.detect_changes.outputs.has_python_changes == 'true'
|
||||
@@ -218,13 +236,18 @@ jobs:
|
||||
|
||||
|
||||
ragflow_tests_infinity:
|
||||
name: ragflow_tests_infinity
|
||||
name: ragflow_tests_infinity (${{ matrix.api_proxy_scheme }})
|
||||
needs: ragflow_preflight
|
||||
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'ci') && (github.event.action != 'labeled' || github.event.label.name == 'ci')) }}
|
||||
runs-on: [ "self-hosted", "ragflow-test" ]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
api_proxy_scheme: ${{ fromJSON(needs.ragflow_preflight.outputs.api_proxy_schemes) }}
|
||||
env:
|
||||
DOC_ENGINE: infinity
|
||||
RAGFLOW_IMAGE: infiniflow/ragflow:${{ github.run_id }}-infinity
|
||||
API_PROXY_SCHEME: ${{ matrix.api_proxy_scheme }}
|
||||
RAGFLOW_IMAGE: infiniflow/ragflow:${{ github.run_id }}-infinity-${{ matrix.api_proxy_scheme }}
|
||||
HTTP_API_TEST_LEVEL: ${{ needs.ragflow_preflight.outputs.http_api_test_level }}
|
||||
HAS_GO: ${{ needs.ragflow_preflight.outputs.has_go_changes }}
|
||||
HAS_PYTHON: ${{ needs.ragflow_preflight.outputs.has_python_changes }}
|
||||
@@ -245,7 +268,7 @@ jobs:
|
||||
fetch-tags: true
|
||||
|
||||
- name: Build ragflow go server
|
||||
if: env.HAS_GO == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'go'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
BUILDER_CONTAINER=ragflow_build_${GITHUB_RUN_ID}_${DOC_ENGINE}_$(od -An -N4 -tx4 /dev/urandom | tr -d ' ')
|
||||
@@ -267,7 +290,7 @@ jobs:
|
||||
./build.sh --go
|
||||
|
||||
- name: Run Go unit tests
|
||||
if: env.HAS_GO == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'go'
|
||||
# Runs after `./build.sh --go`, which guarantees the C++ static
|
||||
# library (librag_tokenizer_c_api.a) is present on disk. The Go
|
||||
# test binaries link against it transitively through
|
||||
@@ -297,20 +320,24 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Build ragflow:nightly
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo docker pull ubuntu:24.04
|
||||
sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} .
|
||||
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-${HOME}}
|
||||
BUILD_LOCK_FILE=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/docker-build.lock
|
||||
mkdir -p "$(dirname "${BUILD_LOCK_FILE}")"
|
||||
(
|
||||
flock -w 10800 9 || { echo "Timed out waiting for the shared Docker build slot" >&2; exit 1; }
|
||||
echo "Acquired Docker build slot for ${DOC_ENGINE}/${API_PROXY_SCHEME}"
|
||||
sudo docker pull ubuntu:24.04
|
||||
sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} .
|
||||
) 9>"${BUILD_LOCK_FILE}"
|
||||
|
||||
- name: Prepare Python test environment
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
run: |
|
||||
uv sync --python 3.13 --group test --frozen
|
||||
uv pip install -e sdk/python
|
||||
|
||||
- name: Prepare function test environment
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
working-directory: docker
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -318,10 +345,10 @@ jobs:
|
||||
sudo chmod 1777 /tmp
|
||||
sudo apt update && sudo apt install -y iproute2
|
||||
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-${HOME}}
|
||||
COMPOSE_PROJECT_NAME="${GITHUB_RUN_ID}-${DOC_ENGINE}"
|
||||
COMPOSE_PROJECT_NAME="${GITHUB_RUN_ID}-${DOC_ENGINE}-${API_PROXY_SCHEME}"
|
||||
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >> ${GITHUB_ENV}
|
||||
echo "RAGFLOW_CONTAINER=${COMPOSE_PROJECT_NAME}-ragflow-cpu-1" >> ${GITHUB_ENV}
|
||||
ARTIFACTS_DIR=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}/${DOC_ENGINE}
|
||||
ARTIFACTS_DIR=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}/${DOC_ENGINE}/${API_PROXY_SCHEME}
|
||||
echo "ARTIFACTS_DIR=${ARTIFACTS_DIR}" >> ${GITHUB_ENV}
|
||||
rm -rf "${ARTIFACTS_DIR}" && mkdir -p "${ARTIFACTS_DIR}"
|
||||
|
||||
@@ -332,7 +359,7 @@ jobs:
|
||||
# Engine-specific offset partitions keep concurrent engine jobs from
|
||||
# choosing the same host ports when they land on the same self-hosted runner.
|
||||
# A lock plus reservation file closes the check/start race between parallel jobs.
|
||||
PORT_BASES=(1200 1201 23817 23820 5432 5455 9000 9001 6379 6380 6601 9380 9381 9382 9384 9383 9385 80 443 4222)
|
||||
PORT_BASES=(1200 1201 23817 23820 5432 5455 9000 9001 6379 6380 6601 9380 9381 9382 9384 9383 9385 80 443 4222 8222)
|
||||
PARTITION_SIZE=6000
|
||||
case "${DOC_ENGINE}" in
|
||||
elasticsearch) PARTITION_BASE=1000 ;;
|
||||
@@ -400,7 +427,8 @@ jobs:
|
||||
MINIO_PORT=$((9000 + PORT_OFFSET))
|
||||
MINIO_CONSOLE_PORT=$((9001 + PORT_OFFSET))
|
||||
REDIS_PORT=$((6379 + PORT_OFFSET))
|
||||
NATS_PORT=$((4222 + PORT_OFFSET))
|
||||
EXPOSE_NATS_PORT=$((4222 + PORT_OFFSET))
|
||||
NATS_MONITORING_PORT=$((8222 + PORT_OFFSET))
|
||||
TEI_PORT=$((6380 + PORT_OFFSET))
|
||||
KIBANA_PORT=$((6601 + PORT_OFFSET))
|
||||
SVR_HTTP_PORT=$((9380 + PORT_OFFSET))
|
||||
@@ -414,7 +442,7 @@ jobs:
|
||||
|
||||
# Persist computed ports into .env so docker-compose uses the correct host bindings.
|
||||
# Remove previous CI overrides first; docker compose uses the last duplicate key.
|
||||
sed -i '/^ES_PORT=/d;/^OS_PORT=/d;/^INFINITY_THRIFT_PORT=/d;/^INFINITY_HTTP_PORT=/d;/^INFINITY_PSQL_PORT=/d;/^EXPOSE_MYSQL_PORT=/d;/^MINIO_PORT=/d;/^MINIO_CONSOLE_PORT=/d;/^REDIS_PORT=/d;/^TEI_PORT=/d;/^KIBANA_PORT=/d;/^SVR_HTTP_PORT=/d;/^ADMIN_SVR_HTTP_PORT=/d;/^SVR_MCP_PORT=/d;/^GO_HTTP_PORT=/d;/^GO_ADMIN_PORT=/d;/^SANDBOX_EXECUTOR_MANAGER_PORT=/d;/^SVR_WEB_HTTP_PORT=/d;/^SVR_WEB_HTTPS_PORT=/d;/^NATS_PORT=/d;/^COMPOSE_PROFILES=/d;/^TEI_MODEL=/d;/^RAGFLOW_IMAGE=/d;/^DOC_ENGINE=/d' .env
|
||||
sed -i '/^ES_PORT=/d;/^OS_PORT=/d;/^INFINITY_THRIFT_PORT=/d;/^INFINITY_HTTP_PORT=/d;/^INFINITY_PSQL_PORT=/d;/^EXPOSE_MYSQL_PORT=/d;/^MINIO_PORT=/d;/^MINIO_CONSOLE_PORT=/d;/^REDIS_PORT=/d;/^EXPOSE_NATS_PORT=/d;/^NATS_MONITORING_PORT=/d;/^TEI_PORT=/d;/^KIBANA_PORT=/d;/^SVR_HTTP_PORT=/d;/^ADMIN_SVR_HTTP_PORT=/d;/^SVR_MCP_PORT=/d;/^GO_HTTP_PORT=/d;/^GO_ADMIN_PORT=/d;/^SANDBOX_EXECUTOR_MANAGER_PORT=/d;/^SVR_WEB_HTTP_PORT=/d;/^SVR_WEB_HTTPS_PORT=/d;/^COMPOSE_PROFILES=/d;/^TEI_MODEL=/d;/^RAGFLOW_IMAGE=/d;/^DOC_ENGINE=/d;/^API_PROXY_SCHEME=/d' .env
|
||||
{
|
||||
echo ""
|
||||
echo "ES_PORT=${ES_PORT}"
|
||||
@@ -426,7 +454,8 @@ jobs:
|
||||
echo "MINIO_PORT=${MINIO_PORT}"
|
||||
echo "MINIO_CONSOLE_PORT=${MINIO_CONSOLE_PORT}"
|
||||
echo "REDIS_PORT=${REDIS_PORT}"
|
||||
echo "NATS_PORT=${NATS_PORT}"
|
||||
echo "EXPOSE_NATS_PORT=${EXPOSE_NATS_PORT}"
|
||||
echo "NATS_MONITORING_PORT=${NATS_MONITORING_PORT}"
|
||||
echo "TEI_PORT=${TEI_PORT}"
|
||||
echo "KIBANA_PORT=${KIBANA_PORT}"
|
||||
echo "SVR_HTTP_PORT=${SVR_HTTP_PORT}"
|
||||
@@ -437,26 +466,37 @@ jobs:
|
||||
echo "SANDBOX_EXECUTOR_MANAGER_PORT=${SANDBOX_EXECUTOR_MANAGER_PORT}"
|
||||
echo "SVR_WEB_HTTP_PORT=${SVR_WEB_HTTP_PORT}"
|
||||
echo "SVR_WEB_HTTPS_PORT=${SVR_WEB_HTTPS_PORT}"
|
||||
echo "COMPOSE_PROFILES=${DOC_ENGINE},cpu,tei-cpu,deepdoc"
|
||||
echo "COMPOSE_PROFILES=${DOC_ENGINE},cpu,ragflow-go,tei-cpu,deepdoc"
|
||||
echo "TEI_MODEL=BAAI/bge-small-en-v1.5"
|
||||
echo "RAGFLOW_IMAGE=${RAGFLOW_IMAGE}"
|
||||
echo "DOC_ENGINE=${DOC_ENGINE}"
|
||||
echo "API_PROXY_SCHEME=${API_PROXY_SCHEME}"
|
||||
} >> .env
|
||||
echo "HOST_ADDRESS=http://host.docker.internal:${SVR_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
if [[ "${API_PROXY_SCHEME}" == "go" ]]; then
|
||||
RAGFLOW_HTTP_PORT=${SVR_WEB_HTTP_PORT}
|
||||
else
|
||||
RAGFLOW_HTTP_PORT=${SVR_HTTP_PORT}
|
||||
fi
|
||||
echo "RAGFLOW_HTTP_PORT=${RAGFLOW_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
echo "HOST_ADDRESS=http://host.docker.internal:${RAGFLOW_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
|
||||
sed -i \
|
||||
-e 's#${NATS_PORT:-4222}:4222#${EXPOSE_NATS_PORT}:4222#' \
|
||||
-e 's#"8222:8222"#"${NATS_MONITORING_PORT}:8222"#' \
|
||||
docker-compose-base.yml
|
||||
|
||||
# Patch entrypoint.sh for coverage
|
||||
sed -i '/"\$PY" api\/ragflow_server.py \${INIT_SUPERUSER_ARGS} &/c\ echo "Ensuring coverage is installed..."\n "$PY" -m pip install coverage -i https://mirrors.aliyun.com/pypi/simple\n export COVERAGE_FILE=/ragflow/logs/.coverage\n echo "Starting ragflow_server with coverage..."\n "$PY" -m coverage run --source=./api/apps --omit="*/tests/*,*/migrations/*" -a api/ragflow_server.py ${INIT_SUPERUSER_ARGS} &' ./entrypoint.sh
|
||||
|
||||
|
||||
- name: Start ragflow:nightly for Infinity
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
run: |
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} down -v || true
|
||||
sudo docker ps -a --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}" -q | xargs -r sudo docker rm -f
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} up -d
|
||||
|
||||
- name: Run sdk tests against Infinity
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
run: |
|
||||
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
||||
svc_ready=0
|
||||
@@ -477,7 +517,6 @@ jobs:
|
||||
source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-infinity-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-infinity-sdk.xml test/testcases/test_sdk_api 2>&1 | tee infinity_sdk_test.log
|
||||
|
||||
- name: Run New RESTFUL api tests against Infinity
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
run: |
|
||||
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
||||
svc_ready=0
|
||||
@@ -497,7 +536,7 @@ jobs:
|
||||
source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/restful_api 2>&1 | tee infinity_restful_api_test.log
|
||||
|
||||
- name: RAGFlow CLI retrieval test Infinity
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
env:
|
||||
PYTHONPATH: ${{ github.workspace }}
|
||||
run: |
|
||||
@@ -551,9 +590,8 @@ jobs:
|
||||
source docker/.env
|
||||
set +a
|
||||
|
||||
HOST_ADDRESS="http://host.docker.internal:${SVR_HTTP_PORT}"
|
||||
USER_HOST="$(echo "${HOST_ADDRESS}" | sed -E 's#^https?://([^:/]+).*#\1#')"
|
||||
USER_PORT="${SVR_HTTP_PORT}"
|
||||
USER_PORT="${RAGFLOW_HTTP_PORT}"
|
||||
ADMIN_HOST="${USER_HOST}"
|
||||
ADMIN_PORT="${ADMIN_SVR_HTTP_PORT}"
|
||||
|
||||
@@ -609,7 +647,7 @@ jobs:
|
||||
run_cli "${LOG_FILE}" $CLI --type user --host "$USER_HOST" --port "$USER_PORT" --username "$EMAIL" --password "$PASS" command "Benchmark 16 100 search 'what are these documents about' on datasets '$DATASET'"
|
||||
|
||||
- name: Stop ragflow to save coverage Infinity
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() && env.API_PROXY_SCHEME == 'python' }}
|
||||
run: |
|
||||
# Send SIGINT to ragflow_server.py to trigger coverage save
|
||||
PID=$(sudo docker exec ${RAGFLOW_CONTAINER} ps aux | grep "ragflow_server.py" | grep -v grep | awk '{print $2}' | head -n 1)
|
||||
@@ -624,7 +662,7 @@ jobs:
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} stop
|
||||
|
||||
- name: Generate server coverage report Infinity
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() && env.API_PROXY_SCHEME == 'python' }}
|
||||
run: |
|
||||
# .coverage file should be in docker/ragflow-logs/.coverage
|
||||
if [ -f docker/ragflow-logs/.coverage ]; then
|
||||
@@ -650,18 +688,20 @@ jobs:
|
||||
fail_ci_if_error: false
|
||||
|
||||
- name: Collect ragflow log Infinity
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
if [ -d docker/ragflow-logs ]; then
|
||||
cp -r docker/ragflow-logs ${ARTIFACTS_DIR}/ragflow-logs-infinity
|
||||
echo "ragflow log" && tail -n 200 docker/ragflow-logs/ragflow_server.log || true
|
||||
destination="${ARTIFACTS_DIR}/ragflow-logs-infinity"
|
||||
sudo cp -r docker/ragflow-logs "${destination}"
|
||||
sudo chown -R "$(id -u):$(id -g)" "${destination}"
|
||||
echo "ragflow log" && sudo tail -n 200 docker/ragflow-logs/ragflow_server.log || true
|
||||
else
|
||||
echo "No docker/ragflow-logs directory found; skipping log collection"
|
||||
fi
|
||||
sudo rm -rf docker/ragflow-logs || true
|
||||
|
||||
- name: Stop ragflow:nightly for Infinity
|
||||
if: ${{ always() && (env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true') }}
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
# Sometimes `docker compose down` fail due to hang container, heavy load etc. Need to remove such containers to release resources(for example, listen ports).
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} down -v || true
|
||||
@@ -676,13 +716,18 @@ jobs:
|
||||
|
||||
|
||||
ragflow_tests_elasticsearch:
|
||||
name: ragflow_tests_elasticsearch
|
||||
name: ragflow_tests_elasticsearch (${{ matrix.api_proxy_scheme }})
|
||||
needs: ragflow_preflight
|
||||
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'ci') && (github.event.action != 'labeled' || github.event.label.name == 'ci')) }}
|
||||
runs-on: [ "self-hosted", "ragflow-test" ]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
api_proxy_scheme: ${{ fromJSON(needs.ragflow_preflight.outputs.api_proxy_schemes) }}
|
||||
env:
|
||||
DOC_ENGINE: elasticsearch
|
||||
RAGFLOW_IMAGE: infiniflow/ragflow:${{ github.run_id }}-elasticsearch
|
||||
API_PROXY_SCHEME: ${{ matrix.api_proxy_scheme }}
|
||||
RAGFLOW_IMAGE: infiniflow/ragflow:${{ github.run_id }}-elasticsearch-${{ matrix.api_proxy_scheme }}
|
||||
HTTP_API_TEST_LEVEL: ${{ needs.ragflow_preflight.outputs.http_api_test_level }}
|
||||
HAS_GO: ${{ needs.ragflow_preflight.outputs.has_go_changes }}
|
||||
HAS_PYTHON: ${{ needs.ragflow_preflight.outputs.has_python_changes }}
|
||||
@@ -703,7 +748,7 @@ jobs:
|
||||
fetch-tags: true
|
||||
|
||||
- name: Build ragflow go server
|
||||
if: env.HAS_GO == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'go'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
BUILDER_CONTAINER=ragflow_build_${GITHUB_RUN_ID}_${DOC_ENGINE}_$(od -An -N4 -tx4 /dev/urandom | tr -d ' ')
|
||||
@@ -725,7 +770,7 @@ jobs:
|
||||
./build.sh --go
|
||||
|
||||
- name: Run Go unit tests
|
||||
if: env.HAS_GO == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'go'
|
||||
# Runs after `./build.sh --go`, which guarantees the C++ static
|
||||
# library (librag_tokenizer_c_api.a) is present on disk. The Go
|
||||
# test binaries link against it transitively through
|
||||
@@ -755,20 +800,24 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Build ragflow:nightly
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo docker pull ubuntu:24.04
|
||||
sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} .
|
||||
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-${HOME}}
|
||||
BUILD_LOCK_FILE=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/docker-build.lock
|
||||
mkdir -p "$(dirname "${BUILD_LOCK_FILE}")"
|
||||
(
|
||||
flock -w 10800 9 || { echo "Timed out waiting for the shared Docker build slot" >&2; exit 1; }
|
||||
echo "Acquired Docker build slot for ${DOC_ENGINE}/${API_PROXY_SCHEME}"
|
||||
sudo docker pull ubuntu:24.04
|
||||
sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} .
|
||||
) 9>"${BUILD_LOCK_FILE}"
|
||||
|
||||
- name: Prepare Python test environment
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
run: |
|
||||
uv sync --python 3.13 --group test --frozen
|
||||
uv pip install -e sdk/python
|
||||
|
||||
- name: Prepare function test environment
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
working-directory: docker
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -776,10 +825,10 @@ jobs:
|
||||
sudo chmod 1777 /tmp
|
||||
sudo apt update && sudo apt install -y iproute2
|
||||
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-${HOME}}
|
||||
COMPOSE_PROJECT_NAME="${GITHUB_RUN_ID}-${DOC_ENGINE}"
|
||||
COMPOSE_PROJECT_NAME="${GITHUB_RUN_ID}-${DOC_ENGINE}-${API_PROXY_SCHEME}"
|
||||
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >> ${GITHUB_ENV}
|
||||
echo "RAGFLOW_CONTAINER=${COMPOSE_PROJECT_NAME}-ragflow-cpu-1" >> ${GITHUB_ENV}
|
||||
ARTIFACTS_DIR=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}/${DOC_ENGINE}
|
||||
ARTIFACTS_DIR=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}/${DOC_ENGINE}/${API_PROXY_SCHEME}
|
||||
echo "ARTIFACTS_DIR=${ARTIFACTS_DIR}" >> ${GITHUB_ENV}
|
||||
rm -rf "${ARTIFACTS_DIR}" && mkdir -p "${ARTIFACTS_DIR}"
|
||||
|
||||
@@ -790,7 +839,7 @@ jobs:
|
||||
# Engine-specific offset partitions keep concurrent engine jobs from
|
||||
# choosing the same host ports when they land on the same self-hosted runner.
|
||||
# A lock plus reservation file closes the check/start race between parallel jobs.
|
||||
PORT_BASES=(1200 1201 23817 23820 5432 5455 9000 9001 6379 6380 6601 9380 9381 9382 9384 9383 9385 80 443 4222)
|
||||
PORT_BASES=(1200 1201 23817 23820 5432 5455 9000 9001 6379 6380 6601 9380 9381 9382 9384 9383 9385 80 443 4222 8222)
|
||||
PARTITION_SIZE=6000
|
||||
case "${DOC_ENGINE}" in
|
||||
elasticsearch) PARTITION_BASE=1000 ;;
|
||||
@@ -858,7 +907,8 @@ jobs:
|
||||
MINIO_PORT=$((9000 + PORT_OFFSET))
|
||||
MINIO_CONSOLE_PORT=$((9001 + PORT_OFFSET))
|
||||
REDIS_PORT=$((6379 + PORT_OFFSET))
|
||||
NATS_PORT=$((4222 + PORT_OFFSET))
|
||||
EXPOSE_NATS_PORT=$((4222 + PORT_OFFSET))
|
||||
NATS_MONITORING_PORT=$((8222 + PORT_OFFSET))
|
||||
TEI_PORT=$((6380 + PORT_OFFSET))
|
||||
KIBANA_PORT=$((6601 + PORT_OFFSET))
|
||||
SVR_HTTP_PORT=$((9380 + PORT_OFFSET))
|
||||
@@ -872,7 +922,7 @@ jobs:
|
||||
|
||||
# Persist computed ports into .env so docker-compose uses the correct host bindings.
|
||||
# Remove previous CI overrides first; docker compose uses the last duplicate key.
|
||||
sed -i '/^ES_PORT=/d;/^OS_PORT=/d;/^INFINITY_THRIFT_PORT=/d;/^INFINITY_HTTP_PORT=/d;/^INFINITY_PSQL_PORT=/d;/^EXPOSE_MYSQL_PORT=/d;/^MINIO_PORT=/d;/^MINIO_CONSOLE_PORT=/d;/^REDIS_PORT=/d;/^TEI_PORT=/d;/^KIBANA_PORT=/d;/^SVR_HTTP_PORT=/d;/^ADMIN_SVR_HTTP_PORT=/d;/^SVR_MCP_PORT=/d;/^GO_HTTP_PORT=/d;/^GO_ADMIN_PORT=/d;/^SANDBOX_EXECUTOR_MANAGER_PORT=/d;/^SVR_WEB_HTTP_PORT=/d;/^SVR_WEB_HTTPS_PORT=/d;/^NATS_PORT=/d;/^COMPOSE_PROFILES=/d;/^TEI_MODEL=/d;/^RAGFLOW_IMAGE=/d;/^DOC_ENGINE=/d' .env
|
||||
sed -i '/^ES_PORT=/d;/^OS_PORT=/d;/^INFINITY_THRIFT_PORT=/d;/^INFINITY_HTTP_PORT=/d;/^INFINITY_PSQL_PORT=/d;/^EXPOSE_MYSQL_PORT=/d;/^MINIO_PORT=/d;/^MINIO_CONSOLE_PORT=/d;/^REDIS_PORT=/d;/^EXPOSE_NATS_PORT=/d;/^NATS_MONITORING_PORT=/d;/^TEI_PORT=/d;/^KIBANA_PORT=/d;/^SVR_HTTP_PORT=/d;/^ADMIN_SVR_HTTP_PORT=/d;/^SVR_MCP_PORT=/d;/^GO_HTTP_PORT=/d;/^GO_ADMIN_PORT=/d;/^SANDBOX_EXECUTOR_MANAGER_PORT=/d;/^SVR_WEB_HTTP_PORT=/d;/^SVR_WEB_HTTPS_PORT=/d;/^COMPOSE_PROFILES=/d;/^TEI_MODEL=/d;/^RAGFLOW_IMAGE=/d;/^DOC_ENGINE=/d;/^API_PROXY_SCHEME=/d' .env
|
||||
{
|
||||
echo ""
|
||||
echo "ES_PORT=${ES_PORT}"
|
||||
@@ -884,7 +934,8 @@ jobs:
|
||||
echo "MINIO_PORT=${MINIO_PORT}"
|
||||
echo "MINIO_CONSOLE_PORT=${MINIO_CONSOLE_PORT}"
|
||||
echo "REDIS_PORT=${REDIS_PORT}"
|
||||
echo "NATS_PORT=${NATS_PORT}"
|
||||
echo "EXPOSE_NATS_PORT=${EXPOSE_NATS_PORT}"
|
||||
echo "NATS_MONITORING_PORT=${NATS_MONITORING_PORT}"
|
||||
echo "TEI_PORT=${TEI_PORT}"
|
||||
echo "KIBANA_PORT=${KIBANA_PORT}"
|
||||
echo "SVR_HTTP_PORT=${SVR_HTTP_PORT}"
|
||||
@@ -895,26 +946,37 @@ jobs:
|
||||
echo "SANDBOX_EXECUTOR_MANAGER_PORT=${SANDBOX_EXECUTOR_MANAGER_PORT}"
|
||||
echo "SVR_WEB_HTTP_PORT=${SVR_WEB_HTTP_PORT}"
|
||||
echo "SVR_WEB_HTTPS_PORT=${SVR_WEB_HTTPS_PORT}"
|
||||
echo "COMPOSE_PROFILES=${DOC_ENGINE},cpu,tei-cpu,deepdoc"
|
||||
echo "COMPOSE_PROFILES=${DOC_ENGINE},cpu,ragflow-go,tei-cpu,deepdoc"
|
||||
echo "TEI_MODEL=BAAI/bge-small-en-v1.5"
|
||||
echo "RAGFLOW_IMAGE=${RAGFLOW_IMAGE}"
|
||||
echo "DOC_ENGINE=${DOC_ENGINE}"
|
||||
echo "API_PROXY_SCHEME=${API_PROXY_SCHEME}"
|
||||
} >> .env
|
||||
echo "HOST_ADDRESS=http://host.docker.internal:${SVR_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
if [[ "${API_PROXY_SCHEME}" == "go" ]]; then
|
||||
RAGFLOW_HTTP_PORT=${SVR_WEB_HTTP_PORT}
|
||||
else
|
||||
RAGFLOW_HTTP_PORT=${SVR_HTTP_PORT}
|
||||
fi
|
||||
echo "RAGFLOW_HTTP_PORT=${RAGFLOW_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
echo "HOST_ADDRESS=http://host.docker.internal:${RAGFLOW_HTTP_PORT}" >> ${GITHUB_ENV}
|
||||
|
||||
sed -i \
|
||||
-e 's#${NATS_PORT:-4222}:4222#${EXPOSE_NATS_PORT}:4222#' \
|
||||
-e 's#"8222:8222"#"${NATS_MONITORING_PORT}:8222"#' \
|
||||
docker-compose-base.yml
|
||||
|
||||
# Patch entrypoint.sh for coverage
|
||||
sed -i '/"\$PY" api\/ragflow_server.py \${INIT_SUPERUSER_ARGS} &/c\ echo "Ensuring coverage is installed..."\n "$PY" -m pip install coverage -i https://mirrors.aliyun.com/pypi/simple\n export COVERAGE_FILE=/ragflow/logs/.coverage\n echo "Starting ragflow_server with coverage..."\n "$PY" -m coverage run --source=./api/apps --omit="*/tests/*,*/migrations/*" -a api/ragflow_server.py ${INIT_SUPERUSER_ARGS} &' ./entrypoint.sh
|
||||
|
||||
|
||||
- name: Start ragflow:nightly for Elasticsearch
|
||||
if: env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true'
|
||||
run: |
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} down -v || true
|
||||
sudo docker ps -a --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}" -q | xargs -r sudo docker rm -f
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} up -d
|
||||
|
||||
- name: Run sdk tests against Elasticsearch
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
run: |
|
||||
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
||||
svc_ready=0
|
||||
@@ -935,7 +997,6 @@ jobs:
|
||||
source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-es-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-es-sdk.xml test/testcases/test_sdk_api 2>&1 | tee es_sdk_test.log
|
||||
|
||||
- name: Run New RESTFUL api tests against Elasticsearch
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
run: |
|
||||
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
||||
svc_ready=0
|
||||
@@ -955,7 +1016,7 @@ jobs:
|
||||
source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/restful_api 2>&1 | tee es_restful_api_test.log
|
||||
|
||||
- name: RAGFlow CLI retrieval test Elasticsearch
|
||||
if: env.HAS_PYTHON == 'true'
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
env:
|
||||
PYTHONPATH: ${{ github.workspace }}
|
||||
run: |
|
||||
@@ -1009,9 +1070,8 @@ jobs:
|
||||
source docker/.env
|
||||
set +a
|
||||
|
||||
HOST_ADDRESS="http://host.docker.internal:${SVR_HTTP_PORT}"
|
||||
USER_HOST="$(echo "${HOST_ADDRESS}" | sed -E 's#^https?://([^:/]+).*#\1#')"
|
||||
USER_PORT="${SVR_HTTP_PORT}"
|
||||
USER_PORT="${RAGFLOW_HTTP_PORT}"
|
||||
ADMIN_HOST="${USER_HOST}"
|
||||
ADMIN_PORT="${ADMIN_SVR_HTTP_PORT}"
|
||||
|
||||
@@ -1067,7 +1127,7 @@ jobs:
|
||||
run_cli "${LOG_FILE}" $CLI --type user --host "$USER_HOST" --port "$USER_PORT" --username "$EMAIL" --password "$PASS" command "Benchmark 16 100 search 'what are these documents about' on datasets '$DATASET'"
|
||||
|
||||
- name: Stop ragflow to save coverage Elasticsearch
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() && env.API_PROXY_SCHEME == 'python' }}
|
||||
run: |
|
||||
# Send SIGINT to ragflow_server.py to trigger coverage save
|
||||
PID=$(sudo docker exec ${RAGFLOW_CONTAINER} ps aux | grep "ragflow_server.py" | grep -v grep | awk '{print $2}' | head -n 1)
|
||||
@@ -1082,7 +1142,7 @@ jobs:
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} stop
|
||||
|
||||
- name: Generate server coverage report Elasticsearch
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() && env.API_PROXY_SCHEME == 'python' }}
|
||||
run: |
|
||||
# .coverage file should be in docker/ragflow-logs/.coverage
|
||||
if [ -f docker/ragflow-logs/.coverage ]; then
|
||||
@@ -1103,18 +1163,20 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Collect ragflow log Elasticsearch
|
||||
if: ${{ !cancelled() && env.HAS_PYTHON == 'true' }}
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
if [ -d docker/ragflow-logs ]; then
|
||||
cp -r docker/ragflow-logs ${ARTIFACTS_DIR}/ragflow-logs-es
|
||||
echo "ragflow log" && tail -n 200 docker/ragflow-logs/ragflow_server.log || true
|
||||
destination="${ARTIFACTS_DIR}/ragflow-logs-es"
|
||||
sudo cp -r docker/ragflow-logs "${destination}"
|
||||
sudo chown -R "$(id -u):$(id -g)" "${destination}"
|
||||
echo "ragflow log" && sudo tail -n 200 docker/ragflow-logs/ragflow_server.log || true
|
||||
else
|
||||
echo "No docker/ragflow-logs directory found; skipping log collection"
|
||||
fi
|
||||
sudo rm -rf docker/ragflow-logs || true
|
||||
|
||||
- name: Stop ragflow:nightly for Elasticsearch
|
||||
if: ${{ always() && (env.HAS_GO == 'true' || env.HAS_PYTHON == 'true' || env.HAS_WEB == 'true') }}
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
# Sometimes `docker compose down` fail due to hang container, heavy load etc. Need to remove such containers to release resources(for example, listen ports).
|
||||
sudo docker compose -f docker/docker-compose.yml -p ${COMPOSE_PROJECT_NAME} down -v || true
|
||||
|
||||
Reference in New Issue
Block a user