Skip to content

Commit 00de814

Browse files
[Test][KubeRay] Add a deliberate failure test to ensure doctests fail on error (#51709)
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
1 parent 3ebb023 commit 00de814

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

ci/k8s/run-kuberay-doc-tests.sh

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,61 @@ pip install -c python/requirements_compiled.txt pytest nbval bash_kernel
1010
python -m bash_kernel.install
1111
pip install "ray[default]==2.41.0"
1212

13+
echo "--- Run a deliberate failure test to ensure the test script fails on error"
14+
# The following Jupyter notebook only contains a single cell that runs the `date` command.
15+
# The test script should fail because the output of the `date` command is different everytime.
16+
cat <<EOF > test.ipynb
17+
{
18+
"cells": [
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"id": "43a8bb95-f6f2-45a8-ba48-b16856b2106d",
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"name": "stdout",
27+
"output_type": "stream",
28+
"text": [
29+
"Wed Mar 26 06:28:51 PM CST 2025\n"
30+
]
31+
}
32+
],
33+
"source": [
34+
"date"
35+
]
36+
}
37+
],
38+
"metadata": {
39+
"kernelspec": {
40+
"display_name": "Bash",
41+
"language": "bash",
42+
"name": "bash"
43+
},
44+
"language_info": {
45+
"codemirror_mode": "shell",
46+
"file_extension": ".sh",
47+
"mimetype": "text/x-sh",
48+
"name": "bash"
49+
}
50+
},
51+
"nbformat": 4,
52+
"nbformat_minor": 5
53+
}
54+
EOF
55+
set +e
56+
if pytest --nbval test.ipynb --nbval-kernel-name bash; then
57+
echo "The test script should have failed but it didn't."
58+
exit 1
59+
fi
60+
set -e
61+
1362
echo "--- Run doc tests"
1463
cd doc/source/cluster/kubernetes
15-
py.test --nbval getting-started/raycluster-quick-start.ipynb --nbval-kernel-name bash --sanitize-with doc_sanitize.cfg
64+
TESTS=(
65+
"getting-started/raycluster-quick-start.ipynb"
66+
)
67+
for test in "${TESTS[@]}"; do
68+
echo "Running test: ${test}"
69+
pytest --nbval "${test}" --nbval-kernel-name bash --sanitize-with doc_sanitize.cfg
70+
done

0 commit comments

Comments
 (0)