Skip to content

Commit 36ae9f8

Browse files
committed
doctest
Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
1 parent 2e20797 commit 36ae9f8

File tree

3 files changed

+212
-0
lines changed

3 files changed

+212
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
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+
# This file is a part of the vllm-ascend project.
16+
#
17+
18+
name: 'e2e test'
19+
20+
on:
21+
pull_request:
22+
branches:
23+
- 'main'
24+
- '*-dev'
25+
paths:
26+
- '.github/workflows/vllm_ascend_doctest.yaml'
27+
28+
# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
29+
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
30+
# It's used to activate ascend-toolkit environment variables.
31+
defaults:
32+
run:
33+
shell: bash -el {0}
34+
35+
jobs:
36+
test:
37+
strategy:
38+
matrix:
39+
vllm_verison: [main, v0.7.3-dev, v0.8.4rc2, v0.8.4rc1]
40+
name: vLLM Ascend test
41+
runs-on: linux-arm64-npu-1
42+
container:
43+
image: m.daocloud.io/quay.io/ascend/vllm-ascend:${{ matrix.vllm_verison }}
44+
steps:
45+
- name: Check npu and CANN info
46+
run: |
47+
pwd
48+
npu-smi info
49+
cat /usr/local/Ascend/ascend-toolkit/latest/"$(uname -i)"-linux/ascend_toolkit_install.info
50+
51+
- name: Config mirrors
52+
run: |
53+
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
54+
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
55+
apt-get update -y
56+
apt install git curl -y
57+
git config --global url."https://gh-proxy.test.osinfra.cn/https://github.com/".insteadOf https://github.com/
58+
59+
- name: Checkout vllm-project/vllm-ascend repo
60+
uses: actions/checkout@v4
61+
62+
- name: Run vllm-project/vllm test for V0 Engine
63+
run: |
64+
pwd
65+
ls -la
66+
if [ ! -d /workspace/vllm-ascend/tests/doctest ]; then
67+
echo "Warning: the doctest path doesn't exists, copy now"
68+
cp -r tests/doctest /workspace/vllm-ascend/tests/
69+
fi
70+
cd /workspace
71+
./vllm-ascend/tests/doctest/run_tests.sh
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
# This file is a part of the vllm-ascend project.
18+
#
19+
20+
CURL_TIMEOUT=1
21+
CURL_COOLDOWN=5
22+
CURL_MAX_TRIES=120
23+
24+
function wait_url_ready() {
25+
local serve_name="$1"
26+
local url="$2"
27+
i=0
28+
while true; do
29+
_info "===> Waiting for ${serve_name} to be ready...${i}s"
30+
i=$((i + ${CURL_COOLDOWN}))
31+
32+
set +e
33+
34+
curl \
35+
--silent \
36+
--max-time "$CURL_TIMEOUT" \
37+
${url} \
38+
>/dev/null
39+
40+
result=$?
41+
42+
set -e
43+
44+
if [ "$result" -eq 0 ]; then
45+
break
46+
fi
47+
48+
if [ "$i" -gt "$CURL_MAX_TRIES" ]; then
49+
_info "===> \$CURL_MAX_TRIES exceeded waiting for ${serve_name} to be ready"
50+
return 1
51+
fi
52+
53+
sleep "$CURL_COOLDOWN"
54+
done
55+
56+
_info "===> ${serve_name} is ready."
57+
}
58+
59+
function wait_for_exit() {
60+
local VLLM_PID="$1"
61+
while kill -0 $VLLM_PID; do
62+
_info "===> Wait for ${VLLM_PID} to exit."
63+
sleep 1
64+
done
65+
_info "===> Wait for ${VLLM_PID} to exit."
66+
}
67+
68+
function simple_test() {
69+
python3 -c "import vllm; print(vllm.__version__)"
70+
}
71+
72+
function quickstart_offline_test() {
73+
export VLLM_USE_MODELSCOPE=true
74+
python3 ${SCRIPT_DIR}/../../examples/offline_inference_npu.py
75+
}
76+
77+
function quickstart_online_test() {
78+
export VLLM_USE_MODELSCOPE=true
79+
vllm serve Qwen/Qwen2.5-0.5B-Instruct &
80+
wait_url_ready "vllm serve" "localhost:8000/v1/models"
81+
curl http://localhost:8000/v1/completions \
82+
-H "Content-Type: application/json" \
83+
-d '{
84+
"model": "Qwen/Qwen2.5-0.5B-Instruct",
85+
"prompt": "Beijing is a",
86+
"max_tokens": 5,
87+
"temperature": 0
88+
}' | python3 -m json.tool
89+
ps -ef | grep "vllm serve" | grep -v grep
90+
VLLM_PID=$(ps -ef | grep "vllm serve" | grep -v grep | awk '{print $2}')
91+
kill -2 $VLLM_PID
92+
wait_for_exit $VLLM_PID
93+
}
94+
95+
_info "====> Start simple_test"
96+
simple_test
97+
_info "====> Start quickstart_offline_test"
98+
quickstart_offline_test
99+
_info "====> Start quickstart_online_test"
100+
quickstart_online_test

tests/doctest/run_tests.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
# This file is a part of the vllm-ascend project.
18+
#
19+
20+
set -eo errexit
21+
22+
# bash fonts colors
23+
cyan='\e[96m'
24+
yellow='\e[33m'
25+
red='\e[31m'
26+
none='\e[0m'
27+
28+
_cyan() { echo -e "${cyan}$*${none}"; }
29+
_yellow() { echo -e "${yellow}$*${none}"; }
30+
_red() { echo -e "${red}$*${none}"; }
31+
32+
_info() { _cyan "Info: $*"; }
33+
_warn() { _yellow "Warn: $*"; }
34+
_err() { _red "Error: $*" && exit 1; }
35+
36+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
37+
38+
_info "====> Start Quickstart test"
39+
. "${SCRIPT_DIR}/001-quickstart-test.sh"
40+
41+
_info "Test passed."

0 commit comments

Comments
 (0)