From a072441c06937a2a782ac94524ab54e166b4d86e Mon Sep 17 00:00:00 2001 From: Ying Chun Guo Date: Sun, 11 Aug 2024 00:26:32 +0800 Subject: [PATCH] improve manifest chaqna test (#565) Signed-off-by: Yingchun Guo --- ChatQnA/tests/test_manifest_on_gaudi.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ChatQnA/tests/test_manifest_on_gaudi.sh b/ChatQnA/tests/test_manifest_on_gaudi.sh index 0ce1409845..12a5a6febe 100755 --- a/ChatQnA/tests/test_manifest_on_gaudi.sh +++ b/ChatQnA/tests/test_manifest_on_gaudi.sh @@ -27,6 +27,13 @@ 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 @@ -34,7 +41,8 @@ function validate_chatqna() { 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 @@ -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 @@ -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!"