Skip to content

Commit

Permalink
improve manifest chaqna test (#565)
Browse files Browse the repository at this point in the history
Signed-off-by: Yingchun Guo <yingchun.guo@intel.com>
  • Loading branch information
daisy-ycguo authored Aug 10, 2024
1 parent ed48371 commit a072441
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ChatQnA/tests/test_manifest_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ function install_chatqna {
sleep 60
}

function get_end_point() {
# $1 is service name, $2 is namespace
ip_address=$(kubectl get svc $1 -n $2 -o jsonpath='{.spec.clusterIP}')
port=$(kubectl get svc $1 -n $2 -o jsonpath='{.spec.ports[0].port}')
echo "$ip_address:$port"
}

function validate_chatqna() {
max_retry=20
# make sure microservice retriever-usvc is ready
# try to curl retriever-svc for max_retry times
test_embedding=$(python3 -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)")
for ((i=1; i<=max_retry; i++))
do
curl http://chatqna-retriever-usvc.$NAMESPACE:7000/v1/retrieval -X POST \
endpoint_url=$(get_end_point "chatqna-retriever-usvc" $NAMESPACE)
curl http://$endpoint_url/v1/retrieval -X POST \
-d "{\"text\":\"What is the revenue of Nike in 2023?\",\"embedding\":${test_embedding}}" \
-H 'Content-Type: application/json' && break
sleep 30
Expand All @@ -47,7 +55,8 @@ function validate_chatqna() {
# make sure microservice tgi-svc is ready
for ((i=1; i<=max_retry; i++))
do
curl http://chatqna-tgi.$NAMESPACE:80/generate -X POST \
endpoint_url=$(get_end_point "chatqna-tgi" $NAMESPACE)
curl http://$endpoint_url/generate -X POST \
-d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":17, "do_sample": true}}' \
-H 'Content-Type: application/json' && break
sleep 10
Expand All @@ -61,7 +70,8 @@ function validate_chatqna() {
# check megaservice works
# generate a random logfile name to avoid conflict among multiple runners
LOGFILE=$LOG_PATH/curlmega_$NAMESPACE.log
curl http://chatqna.$NAMESPACE:8888/v1/chatqna -H "Content-Type: application/json" -d '{"messages": "What is the revenue of Nike in 2023?"}' > $LOGFILE
endpoint_url=$(get_end_point "chatqna" $NAMESPACE)
curl http://$endpoint_url/v1/chatqna -H "Content-Type: application/json" -d '{"messages": "What is the revenue of Nike in 2023?"}' > $LOGFILE
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Megaservice failed, please check the logs in $LOGFILE!"
Expand Down

0 comments on commit a072441

Please sign in to comment.