Skip to content

Commit 82ba06a

Browse files
author
irisdingbj
committed
add gmce2e
Signed-off-by: irisdingbj <shaojun.ding@intel.com>
1 parent bc9abac commit 82ba06a

File tree

3 files changed

+140
-3
lines changed

3 files changed

+140
-3
lines changed

.github/workflows/scripts/e2e/go_test.sh

+138-1
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,167 @@ function install_gmc() {
1212
# Make sure you have to use image tag $VERSION for microservice-connector installation
1313
echo "install microservice-connector, using repo $DOCKER_REGISTRY and tag $VERSION"
1414
echo "using namespace $SYSTEM_NAMESPACE and $APP_NAMESPACE"
15+
16+
init_gmc
17+
18+
kubectl apply -f $(pwd)/config/crd/bases/gmc.opea.io_gmconnectors.yaml
19+
kubectl apply -f $(pwd)/config/rbac/gmc-manager-rbac.yaml
20+
kubectl create configmap gmcyaml -n $SYSTEM_NAMESPACE --from-file $(pwd)/config/manifests
21+
kubectl apply -f $(pwd)/config/manager/gmc-manager.yaml
22+
23+
# Wait until the gmc conroller pod is ready
24+
wait_until_pod_ready "gmc-controller" $SYSTEM_NAMESPACE "gmc-controller"
1525
}
1626

1727
function validate_gmc() {
18-
echo "validate microservice-connector"
28+
echo "validate chat-qna"
29+
validate_chatqna
30+
1931
}
2032

2133
function cleanup_gmc() {
2234
echo "clean up microservice-connector"
35+
kubectl delete ns $APP_NAMESPACE
36+
kubectl delete ns $SYSTEM_NAMESPACE
37+
kubectl delete crd gmconnectors.gmc.opea.io
2338
# clean up the images
2439
docker rmi $DOCKER_REGISTRY/gmcrouter:$VERSION
2540
docker rmi $DOCKER_REGISTRY/gmcmanager:$VERSION
2641
}
2742

43+
function validate_chatqna() {
44+
45+
46+
# todo select gaudi or xeon
47+
kubectl create ns $APP_NAMESPACE
48+
sed -i "s|namespace: chatqa|namespace: $APP_NAMESPACE|g" $(pwd)/config/samples/chatQnA_xeon.yaml
49+
kubectl apply -f $(pwd)/config/samples/chatQnA_xeon.yaml
50+
51+
52+
53+
output=$(kubectl get pods)
54+
echo $output
55+
56+
# Wait until the router service is ready
57+
echo "Waiting for the chatqa router service to be ready..."
58+
wait_until_pod_ready "chatqna router" $APP_NAMESPACE "router-service"
59+
60+
61+
# deploy client pod for testing
62+
kubectl create deployment client-test -n $APP_NAMESPACE --image=python:3.8.13 -- sleep infinity
63+
64+
# wait for client pod ready
65+
wait_until_pod_ready "client-test" $APP_NAMESPACE "client-test"
66+
# giving time to populating data
67+
sleep 120
68+
69+
# send request to chatqnA
70+
export CLIENT_POD=$(kubectl get pod -n $APP_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name})
71+
echo "$CLIENT_POD"
72+
accessUrl=$(kubectl get gmc -n $APP_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='chatqa')].status.accessUrl}")
73+
kubectl exec "$CLIENT_POD" -n $APP_NAMESPACE -- curl $accessUrl -X POST -d '{"text":"What is the revenue of Nike in 2023?","parameters":{"max_new_tokens":17, "do_sample": true}}' -H 'Content-Type: application/json' > $LOG_PATH/curl_chatqna.log
74+
exit_code=$?
75+
if [ $exit_code -ne 0 ]; then
76+
echo "chatqna failed, please check the logs in ${LOG_PATH}!"
77+
exit 1
78+
fi
79+
80+
echo "Checking response results, make sure the output is reasonable. "
81+
local status=false
82+
if [[ -f $LOG_PATH/curl_chatqna.log ]] && \
83+
[[ $(grep -c "billion" $LOG_PATH/curl_chatqna.log) != 0 ]]; then
84+
status=true
85+
fi
86+
if [ $status == false ]; then
87+
echo "Response check failed, please check the logs in artifacts!"
88+
exit 1
89+
else
90+
echo "Response check succeed!"
91+
fi
92+
}
93+
94+
function init_gmc() {
95+
# Copy manifest into gmc
96+
mkdir -p $(pwd)/config/manifests
97+
cp $(dirname $(pwd))/manifests/ChatQnA/*.yaml -p $(pwd)/config/manifests/
98+
99+
# replace tag with for the gmc-router and gmc-manager image
100+
sed -i "s|opea/\(.*\):latest|opea/\1:$VERSION|g" $(pwd)/config/gmcrouter/gmc-router.yaml
101+
sed -i "s|opea/\(.*\):latest|opea/\1:$VERSION|g" $(pwd)/config/manager/gmc-manager.yaml
102+
cp $(pwd)/config/gmcrouter/gmc-router.yaml -p $(pwd)/config/manifests/
103+
104+
105+
106+
# replace namespace for gmc-router and gmc-manager
107+
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" $(pwd)/config/manager/gmc-manager.yaml
108+
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" $(pwd)/config/rbac/gmc-manager-rbac.yaml
109+
sed -i "s|name: system|name: $SYSTEM_NAMESPACE|g" $(pwd)/config/rbac/gmc-manager-rbac.yaml
110+
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
111+
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt#path: $MOUNT_DIR#g" {} \;
112+
# replace the repository "image: opea/*" with "image: $IMAGE_REPO/opea/"
113+
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: $IMAGE_REPO/opea/#g" {} \;
114+
# set huggingface token
115+
# find . -name '*.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
116+
find . -name '*.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
117+
# replace namespace "default" with real namespace
118+
find . -name '*.yaml' -type f -exec sed -i "s#default.svc#$APP_NAMESPACE.svc#g" {} \;
119+
}
120+
121+
122+
function wait_until_pod_ready() {
123+
echo "Waiting for the $1 to be ready..."
124+
max_retries=3000
125+
retry_count=0
126+
while ! is_pod_ready $2 $3; do
127+
if [ $retry_count -ge $max_retries ]; then
128+
echo "$1 is not ready after waiting for a significant amount of time"
129+
exit 1
130+
fi
131+
echo "$1 is not ready yet. Retrying in 10 seconds..."
132+
sleep 10
133+
output=$(kubectl get pods -n $2)
134+
# Check if the command was successful
135+
if [ $? -eq 0 ]; then
136+
echo "Successfully retrieved $1 information:"
137+
echo "$output"
138+
else
139+
echo "Failed to retrieve $1 information"
140+
exit 1
141+
fi
142+
retry_count=$((retry_count + 1))
143+
done
144+
}
145+
146+
function is_pod_ready() {
147+
if [ "$2" == "gmc-controller" ]; then
148+
pod_status=$(kubectl get pods -n $1 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
149+
else
150+
pod_status=$(kubectl get pods -n $1 -l app=$2 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
151+
fi
152+
if [ "$pod_status" == "True" ]; then
153+
return 0
154+
else
155+
return 1
156+
fi
157+
}
158+
159+
160+
28161
if [ $# -eq 0 ]; then
29162
echo "Usage: $0 <function_name>"
30163
exit 1
31164
fi
32165

33166
case "$1" in
34167
install_gmc)
168+
pushd microservices-connector
35169
install_gmc
170+
popd
36171
;;
37172
validate_gmc)
173+
pushd microservices-connector
38174
validate_gmc
175+
popd
39176
;;
40177
cleanup_gmc)
41178
cleanup_gmc

microservices-connector/config/gmcrouter/gmc-router.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
serviceAccountName: default
3333
containers:
3434
- name: router-server
35-
image: zhlsunshine/gmcrouter:latest
35+
image: opea/gmcrouter:latest
3636
imagePullPolicy: IfNotPresent
3737
ports:
3838
- containerPort: 8080

microservices-connector/config/manager/gmc-manager.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec:
2727
containers:
2828
- command:
2929
- /manager
30-
image: zhlsunshine/gmcmanager:latest
30+
image: opea/gmcmanager:latest
3131
name: manager
3232
volumeMounts:
3333
- name: yaml-file

0 commit comments

Comments
 (0)