Skip to content

Commit

Permalink
Add test for shutdown while unloading in background (#6835)
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui authored Jan 27, 2024
1 parent 4bc15c9 commit b0e7e50
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
21 changes: 21 additions & 0 deletions qa/L0_lifecycle/lifecycle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3326,6 +3326,27 @@ def test_model_config_overwite(self):
updated_config = triton_client.get_model_config(model_name)
self.assertEqual(original_config, updated_config)

def test_shutdown_while_background_unloading(self):
model_name = "identity_fp32"
triton_client = self._get_client()
self.assertTrue(triton_client.is_server_live())
self.assertTrue(triton_client.is_server_ready())
# Check the Python version of the model is loaded.
self.assertTrue(triton_client.is_model_ready(model_name, "1"))
python_model_config = triton_client.get_model_config(model_name)
self.assertEqual(python_model_config["backend"], "python")
# Load the Identity version, which will put the Python version into the
# background and unload it, the unload will take at least 10 seconds.
override_config = "{\n"
override_config += '"name": "identity_fp32",\n'
override_config += '"backend": "identity"\n'
override_config += "}"
triton_client.load_model(model_name, config=override_config)
identity_model_config = triton_client.get_model_config(model_name)
self.assertEqual(identity_model_config["backend"], "identity")
# The server will shutdown after this sub-test exits. The server must shutdown
# without any hang or runtime error.


if __name__ == "__main__":
unittest.main()
41 changes: 38 additions & 3 deletions qa/L0_lifecycle/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1990,8 +1990,7 @@ wait $SERVER_PID

LOG_IDX=$((LOG_IDX+1))

# LifeCycleTest.test_model_config_overwite

# LifeCycleTest.test_model_config_overwrite
rm -rf models
mkdir models
MODEL_NAME="identity_fp32"
Expand Down Expand Up @@ -2025,7 +2024,43 @@ wait $SERVER_PID

LOG_IDX=$((LOG_IDX+1))

### End Test Definitions ###
# LifeCycleTest.test_shutdown_while_background_unloading
rm -rf models
mkdir models
MODEL_NAME="identity_fp32"
cp -r ../python_models/${MODEL_NAME} models/ && (cd models/${MODEL_NAME} && \
mkdir 1 && mv model.py 1 && \
echo " def finalize(self):" >> 1/model.py && \
echo " import time" >> 1/model.py && \
echo " time.sleep(10)" >> 1/model.py)

SERVER_ARGS="--model-repository=`pwd`/models --model-control-mode=explicit --load-model ${MODEL_NAME} --log-verbose=2"
SERVER_LOG="./inference_server_$LOG_IDX.log"
run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
cat $SERVER_LOG
exit 1
fi

set +e
python $LC_TEST LifeCycleTest.test_shutdown_while_background_unloading >>$CLIENT_LOG 2>&1
if [ $? -ne 0 ]; then
cat $CLIENT_LOG
echo -e "\n***\n*** Test Failed\n***"
RET=1
fi
set -e

kill $SERVER_PID
wait $SERVER_PID

NUMBER_OF_MODELS_UNLOADED=`grep -o "successfully unloaded" $SERVER_LOG | wc -l`
if [ $NUMBER_OF_MODELS_UNLOADED -ne 2 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Unexpected number of successfully unloaded models\n***"
RET=1
fi

if [ $RET -eq 0 ]; then
echo -e "\n***\n*** Test Passed\n***"
Expand Down

0 comments on commit b0e7e50

Please sign in to comment.