|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without |
| 5 | +# modification, are permitted provided that the following conditions |
| 6 | +# are met: |
| 7 | +# * Redistributions of source code must retain the above copyright |
| 8 | +# notice, this list of conditions and the following disclaimer. |
| 9 | +# * Redistributions in binary form must reproduce the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer in the |
| 11 | +# documentation and/or other materials provided with the distribution. |
| 12 | +# * Neither the name of NVIDIA CORPORATION nor the names of its |
| 13 | +# contributors may be used to endorse or promote products derived |
| 14 | +# from this software without specific prior written permission. |
| 15 | +# |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY |
| 17 | +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 19 | +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 20 | +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 | +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 24 | +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | + |
| 28 | +CLIENT_PY=../python_unittest.py |
| 29 | +CLIENT_LOG="./client.log" |
| 30 | +EXPECTED_NUM_TESTS="1" |
| 31 | +TEST_RESULT_FILE='test_results.txt' |
| 32 | +source ../../common/util.sh |
| 33 | + |
| 34 | +TRITON_DIR=${TRITON_DIR:="/opt/tritonserver"} |
| 35 | +SERVER=${TRITON_DIR}/bin/tritonserver |
| 36 | +BACKEND_DIR=${TRITON_DIR}/backends |
| 37 | +SERVER_ARGS="--model-repository=`pwd`/models --backend-directory=${BACKEND_DIR} --log-verbose=1" |
| 38 | +SERVER_LOG="./inference_server.log" |
| 39 | + |
| 40 | +RET=0 |
| 41 | +rm -fr *.log ./models *.txt |
| 42 | + |
| 43 | +mkdir -p models/custom_metrics/1/ |
| 44 | +cp ../../python_models/custom_metrics/model.py models/custom_metrics/1/ |
| 45 | +cp ../../python_models/custom_metrics/config.pbtxt models/custom_metrics |
| 46 | + |
| 47 | +run_server |
| 48 | +if [ "$SERVER_PID" == "0" ]; then |
| 49 | + echo -e "\n***\n*** Failed to start $SERVER\n***" |
| 50 | + cat $SERVER_LOG |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
| 54 | +set +e |
| 55 | + |
| 56 | +export MODEL_NAME='custom_metrics' |
| 57 | +python3 $CLIENT_PY >> $CLIENT_LOG 2>&1 |
| 58 | +if [ $? -ne 0 ]; then |
| 59 | + echo -e "\n***\n*** 'Custom Metrics' test FAILED. \n***" |
| 60 | + cat $CLIENT_LOG |
| 61 | + RET=1 |
| 62 | +else |
| 63 | + check_test_results $TEST_RESULT_FILE $EXPECTED_NUM_TESTS |
| 64 | + if [ $? -ne 0 ]; then |
| 65 | + cat $CLIENT_LOG |
| 66 | + echo -e "\n***\n*** Test Result Verification Failed\n***" |
| 67 | + RET=1 |
| 68 | + fi |
| 69 | +fi |
| 70 | + |
| 71 | +set -e |
| 72 | + |
| 73 | +kill $SERVER_PID |
| 74 | +wait $SERVER_PID |
| 75 | + |
| 76 | + |
| 77 | +if [ $RET -eq 1 ]; then |
| 78 | + cat $CLIENT_LOG |
| 79 | + cat $SERVER_LOG |
| 80 | + echo -e "\n***\n*** Custom Metrics test FAILED. \n***" |
| 81 | +else |
| 82 | + echo -e "\n***\n*** Custom Metrics test PASSED. \n***" |
| 83 | +fi |
| 84 | + |
| 85 | +exit $RET |
0 commit comments