@@ -27,14 +27,22 @@ function install_chatqna {
27
27
sleep 60
28
28
}
29
29
30
+ function get_end_point() {
31
+ # $1 is service name, $2 is namespace
32
+ ip_address=$( kubectl get svc $1 -n $2 -o jsonpath=' {.spec.clusterIP}' )
33
+ port=$( kubectl get svc $1 -n $2 -o jsonpath=' {.spec.ports[0].port}' )
34
+ echo " $ip_address :$port "
35
+ }
36
+
30
37
function validate_chatqna() {
31
38
max_retry=20
32
39
# make sure microservice retriever-usvc is ready
33
40
# try to curl retriever-svc for max_retry times
34
41
test_embedding=$( python3 -c " import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)" )
35
42
for (( i= 1 ; i<= max_retry; i++ ))
36
43
do
37
- curl http://chatqna-retriever-usvc.$NAMESPACE :7000/v1/retrieval -X POST \
44
+ endpoint_url=$( get_end_point " chatqna-retriever-usvc" $NAMESPACE )
45
+ curl http://$endpoint_url /v1/retrieval -X POST \
38
46
-d " {\" text\" :\" What is the revenue of Nike in 2023?\" ,\" embedding\" :${test_embedding} }" \
39
47
-H ' Content-Type: application/json' && break
40
48
sleep 30
@@ -47,7 +55,8 @@ function validate_chatqna() {
47
55
# make sure microservice tgi-svc is ready
48
56
for (( i= 1 ; i<= max_retry; i++ ))
49
57
do
50
- curl http://chatqna-tgi.$NAMESPACE :80/generate -X POST \
58
+ endpoint_url=$( get_end_point " chatqna-tgi" $NAMESPACE )
59
+ curl http://$endpoint_url /generate -X POST \
51
60
-d ' {"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":17, "do_sample": true}}' \
52
61
-H ' Content-Type: application/json' && break
53
62
sleep 10
@@ -61,7 +70,8 @@ function validate_chatqna() {
61
70
# check megaservice works
62
71
# generate a random logfile name to avoid conflict among multiple runners
63
72
LOGFILE=$LOG_PATH /curlmega_$NAMESPACE .log
64
- curl http://chatqna.$NAMESPACE :8888/v1/chatqna -H " Content-Type: application/json" -d ' {"messages": "What is the revenue of Nike in 2023?"}' > $LOGFILE
73
+ endpoint_url=$( get_end_point " chatqna" $NAMESPACE )
74
+ curl http://$endpoint_url /v1/chatqna -H " Content-Type: application/json" -d ' {"messages": "What is the revenue of Nike in 2023?"}' > $LOGFILE
65
75
exit_code=$?
66
76
if [ $exit_code -ne 0 ]; then
67
77
echo " Megaservice failed, please check the logs in $LOGFILE !"
0 commit comments