Skip to content

Commit 2913e30

Browse files
committed
Moved shared memory tests to their own test script; Generated a hash map for the different subtests of the L0_backend_python test
1 parent 75588dc commit 2913e30

File tree

2 files changed

+307
-221
lines changed

2 files changed

+307
-221
lines changed

qa/L0_backend_python/test.sh

Lines changed: 39 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -177,235 +177,53 @@ fi
177177

178178
pip3 install pytest requests virtualenv
179179

180-
prev_num_pages=`get_shm_pages`
181-
run_server
182-
if [ "$SERVER_PID" == "0" ]; then
183-
cat $SERVER_LOG
184-
echo -e "\n***\n*** Failed to start $SERVER\n***"
185-
exit 1
186-
fi
187-
188-
set +e
189-
python3 -m pytest --junitxml=L0_backend_python.report.xml $CLIENT_PY >> $CLIENT_LOG 2>&1
190-
if [ $? -ne 0 ]; then
191-
cat $CLIENT_LOG
192-
RET=1
193-
fi
194-
set -e
195-
196-
kill_server
197-
198-
current_num_pages=`get_shm_pages`
199-
if [ $current_num_pages -ne $prev_num_pages ]; then
200-
ls /dev/shm
201-
cat $CLIENT_LOG
202-
echo -e "\n***\n*** Test Failed. Shared memory pages where not cleaned properly.
203-
Shared memory pages before starting triton equals to $prev_num_pages
204-
and shared memory pages after starting triton equals to $current_num_pages \n***"
205-
RET=1
206-
fi
207-
208-
prev_num_pages=`get_shm_pages`
209-
# Triton non-graceful exit
210-
run_server
211-
if [ "$SERVER_PID" == "0" ]; then
212-
cat $SERVER_LOG
213-
echo -e "\n***\n*** Failed to start $SERVER\n***"
214-
exit 1
215-
fi
216-
217-
sleep 5
218-
219-
readarray -t triton_procs < <(pgrep --parent ${SERVER_PID})
220-
221-
set +e
222-
223-
# Trigger non-graceful termination of Triton
224-
kill -9 $SERVER_PID
225-
226-
# Wait 10 seconds so that Python stub can detect non-graceful exit
227-
sleep 10
228-
229-
for triton_proc in $triton_procs; do
230-
kill -0 $triton_proc > /dev/null 2>&1
231-
if [ $? -eq 0 ]; then
232-
cat $CLIENT_LOG
233-
echo -e "\n***\n*** Python backend non-graceful exit test failed \n***"
234-
RET=1
235-
break
236-
fi
237-
done
238-
set -e
239-
240-
#
241-
# Test KIND_GPU
242-
# Disable env test for Jetson & Windows since GPU Tensors are not supported
243-
if [ "$TEST_JETSON" == "0" ] && [[ ${TEST_WINDOWS} == 0 ]]; then
244-
rm -rf models/
245-
mkdir -p models/add_sub_gpu/1/
246-
cp ../python_models/add_sub/model.py ./models/add_sub_gpu/1/
247-
cp ../python_models/add_sub_gpu/config.pbtxt ./models/add_sub_gpu/
248-
249-
prev_num_pages=`get_shm_pages`
250-
run_server
251-
if [ "$SERVER_PID" == "0" ]; then
252-
cat $SERVER_LOG
253-
echo -e "\n***\n*** Failed to start $SERVER\n***"
254-
exit 1
255-
fi
256-
257-
if [ $? -ne 0 ]; then
258-
cat $SERVER_LOG
259-
echo -e "\n***\n*** KIND_GPU model test failed \n***"
260-
RET=1
261-
fi
262-
263-
kill_server
264-
265-
current_num_pages=`get_shm_pages`
266-
if [ $current_num_pages -ne $prev_num_pages ]; then
267-
cat $CLIENT_LOG
268-
ls /dev/shm
269-
echo -e "\n***\n*** Test Failed. Shared memory pages where not cleaned properly.
270-
Shared memory pages before starting triton equals to $prev_num_pages
271-
and shared memory pages after starting triton equals to $current_num_pages \n***"
272-
exit 1
273-
fi
274-
fi
275-
276-
# Test Multi file models
277-
rm -rf models/
278-
mkdir -p models/multi_file/1/
279-
cp ../python_models/multi_file/*.py ./models/multi_file/1/
280-
cp ../python_models/identity_fp32/config.pbtxt ./models/multi_file/
281-
(cd models/multi_file && \
282-
sed -i "s/^name:.*/name: \"multi_file\"/" config.pbtxt)
283-
284-
prev_num_pages=`get_shm_pages`
285-
run_server
286-
if [ "$SERVER_PID" == "0" ]; then
287-
cat $SERVER_LOG
288-
echo -e "\n***\n*** Failed to start $SERVER\n***"
289-
exit 1
290-
fi
291-
292-
if [ $? -ne 0 ]; then
293-
cat $SERVER_LOG
294-
echo -e "\n***\n*** multi-file model test failed \n***"
295-
RET=1
296-
fi
297-
298-
kill_server
299-
300-
current_num_pages=`get_shm_pages`
301-
if [ $current_num_pages -ne $prev_num_pages ]; then
302-
cat $SERVER_LOG
303-
ls /dev/shm
304-
echo -e "\n***\n*** Test Failed. Shared memory pages where not cleaned properly.
305-
Shared memory pages before starting triton equals to $prev_num_pages
306-
and shared memory pages after starting triton equals to $current_num_pages \n***"
307-
exit 1
308-
fi
309-
310-
# Test environment variable propagation
311-
rm -rf models/
312-
mkdir -p models/model_env/1/
313-
cp ../python_models/model_env/model.py ./models/model_env/1/
314-
cp ../python_models/model_env/config.pbtxt ./models/model_env/
315-
316-
export MY_ENV="MY_ENV"
317-
if [[ ${TEST_WINDOWS} == 1 ]]; then
318-
# This will run in WSL, but Triton will run in windows, so environment
319-
# variables meant for loaded models must be exported using WSLENV.
320-
# The /w flag indicates the value should only be included when invoking
321-
# Win32 from WSL.
322-
export WSLENV=MY_ENV/w
323-
fi
324-
325-
prev_num_pages=`get_shm_pages`
326-
run_server
327-
if [ "$SERVER_PID" == "0" ]; then
328-
cat $SERVER_LOG
329-
echo -e "\n***\n*** Failed to start $SERVER\n***"
330-
echo -e "\n***\n*** Environment variable test failed \n***"
331-
exit 1
332-
fi
333-
334-
kill_server
335-
336-
current_num_pages=`get_shm_pages`
337-
if [ $current_num_pages -ne $prev_num_pages ]; then
338-
cat $CLIENT_LOG
339-
ls /dev/shm
340-
echo -e "\n***\n*** Test Failed. Shared memory pages where not cleaned properly.
341-
Shared memory pages before starting triton equals to $prev_num_pages
342-
and shared memory pages after starting triton equals to $current_num_pages \n***"
343-
exit 1
180+
# Set up the tests to execute.
181+
declare -A subtest_properties
182+
subtest_properties["shared_memory"]=""
183+
subtest_properties["lifecycle"]=""
184+
subtest_properties["argument_validation"]=""
185+
subtest_properties["logging"]=""
186+
subtest_properties["custom_metrics"]=""
187+
188+
# Add tests depending on which environment is being run.
189+
# If not running in igpu mode add these
190+
if [ "$TEST_JETSON" == "0" ]; then
191+
subtest_properties["ensemble"]=""
192+
subtest_properties["bls"]=""
193+
subtest_properties["decoupled"]=""
194+
subtest_properties["response_sender"]=""
195+
subtest_properties["env"]=""
344196
fi
345197

346-
rm -fr ./models
347-
mkdir -p models/identity_fp32/1/
348-
cp ../python_models/identity_fp32/model.py ./models/identity_fp32/1/model.py
349-
cp ../python_models/identity_fp32/config.pbtxt ./models/identity_fp32/config.pbtxt
350-
351-
shm_default_byte_size=$((1024*1024*4))
352-
SERVER_ARGS="$BASE_SERVER_ARGS --backend-config=python,shm-default-byte-size=$shm_default_byte_size"
353-
354-
run_server
355-
if [ "$SERVER_PID" == "0" ]; then
356-
cat $SERVER_LOG
357-
echo -e "\n***\n*** Failed to start $SERVER\n***"
358-
exit 1
198+
# If not running on windows add these
199+
if [[ ${TEST_WINDOWS} == 0 ]]; then
200+
subtest_properties["variants"]=""
201+
subtest_properties["io"]=""
202+
subtest_properties["python_based_backends"]=""
203+
subtest_properties["async_execute"]=""
204+
subtest_properties["model_control"]=""
205+
subtest_properties["examples"]=""
206+
subtest_properties["request_rescheduling"]=""
207+
fi
208+
209+
if [[ -n "${SUBTESTS}" ]]; then
210+
ALL_SUBTESTS=$(echo "${!subtest_properties[@]}")
211+
for subtest in $(echo "${!subtest_properties[@]}"); do
212+
if [[ ! "${SUBTESTS}" =~ "${subtest}" ]]; then
213+
unset "subtest_properties[${subtest}]"
214+
fi
215+
done
359216
fi
360217

361-
for shm_page in `ls /dev/shm/`; do
362-
if [[ $shm_page != triton_python_backend_shm* ]]; then
363-
continue
364-
fi
365-
page_size=`ls -l /dev/shm/$shm_page 2>&1 | awk '{print $5}'`
366-
if [ $page_size -ne $shm_default_byte_size ]; then
367-
echo -e "Shared memory region size is not equal to
368-
$shm_default_byte_size for page $shm_page. Region size is
369-
$page_size."
370-
RET=1
371-
fi
218+
echo "Executing the following subtests: "
219+
for subtest in $(echo "${!subtest_properties[@]}"); do
220+
echo " ${subtest}: ${subtest_properties[${subtest}]}"
372221
done
373222

374-
kill_server
375-
376-
# Test model getting killed during initialization
377-
rm -fr ./models
378-
mkdir -p models/init_exit/1/
379-
cp ../python_models/init_exit/model.py ./models/init_exit/1/model.py
380-
cp ../python_models/init_exit/config.pbtxt ./models/init_exit/config.pbtxt
223+
exit 0
224+
bash -ex test_shared_memory.sh
381225

382-
ERROR_MESSAGE="Stub process 'init_exit_0_0' is not healthy."
383226

384-
prev_num_pages=`get_shm_pages`
385-
run_server
386-
if [ "$SERVER_PID" != "0" ]; then
387-
echo -e "*** FAILED: unexpected success starting $SERVER" >> $CLIENT_LOG
388-
RET=1
389-
kill_server
390-
else
391-
if grep "$ERROR_MESSAGE" $SERVER_LOG; then
392-
echo -e "Found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
393-
else
394-
echo $CLIENT_LOG
395-
echo -e "Not found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
396-
RET=1
397-
fi
398-
fi
399-
400-
current_num_pages=`get_shm_pages`
401-
if [ $current_num_pages -ne $prev_num_pages ]; then
402-
cat $SERVER_LOG
403-
ls /dev/shm
404-
echo -e "\n***\n*** Test Failed. Shared memory pages where not cleaned properly.
405-
Shared memory pages before starting triton equals to $prev_num_pages
406-
and shared memory pages after starting triton equals to $current_num_pages \n***"
407-
exit 1
408-
fi
409227

410228
# Disable env test for Jetson since cloud storage repos are not supported
411229
# Disable ensemble, io and bls tests for Jetson since GPU Tensors are not supported

0 commit comments

Comments
 (0)