add docsum example e2e test for GMC. (#347)
* add docsum example e2e test for GMC. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * fix curl error for docsum. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * change the manifest e2e yaml. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * change the image format. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * fixing image mapping error. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * change the gmc e2e test. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * accelarate the e2e test. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * change the gmc e2e configuration. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * retrigger. Signed-off-by: zhlsunshine <huailong.zhang@intel.com> Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Yingchun Guo <yingchun.guo@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Malini Bhandaru <malini.bhandaru@intel.com>
This commit is contained in:
8
.github/workflows/gmc-e2e.yaml
vendored
8
.github/workflows/gmc-e2e.yaml
vendored
@@ -93,12 +93,12 @@ jobs:
|
||||
if: always()
|
||||
run: |
|
||||
if $should_cleanup; then
|
||||
if ! kubectl delete ns $APP_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
|
||||
kubectl delete pods --namespace $APP_NAMESPACE --force --grace-period=0 --all
|
||||
kubectl delete ns $APP_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
|
||||
fi
|
||||
if ! kubectl delete ns $SYSTEM_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
|
||||
kubectl delete pods --namespace $SYSTEM_NAMESPACE --force --grace-period=0 --all
|
||||
kubectl delete ns $SYSTEM_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
|
||||
fi
|
||||
if ! kubectl delete ns $APP_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
|
||||
kubectl delete pods --namespace $APP_NAMESPACE --force --grace-period=0 --all
|
||||
kubectl delete ns $APP_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
|
||||
fi
|
||||
fi
|
||||
|
||||
2
.github/workflows/manifest-e2e.yml
vendored
2
.github/workflows/manifest-e2e.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
||||
- name: Set variables
|
||||
run: |
|
||||
if [ ${{ matrix.hardware }} == "gaudi" ]; then IMAGE_REPO=${{ vars.IMAGE_REPO_GAUDI }}; else IMAGE_REPO=${{ vars.IMAGE_REPO_XEON }}; fi
|
||||
echo "IMAGE_REPO=${IMAGE_REPO}" >> $GITHUB_ENV
|
||||
echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV
|
||||
echo "IMAGE_TAG=${{needs.mega-image-build.outputs.image_tag}}" >> $GITHUB_ENV
|
||||
lower_example=$(echo "${{ matrix.example }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
|
||||
|
||||
74
ChatQnA/kubernetes/manifests/docsum_gaudi_llm.yaml
Normal file
74
ChatQnA/kubernetes/manifests/docsum_gaudi_llm.yaml
Normal file
@@ -0,0 +1,74 @@
|
||||
# Source: llm-uservice/charts/tgi/templates/service.yaml
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: docsum-llm-uservice
|
||||
labels:
|
||||
helm.sh/chart: llm-uservice-0.1.0
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
app.kubernetes.io/version: "1.0.0"
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 9000
|
||||
targetPort: 9000
|
||||
protocol: TCP
|
||||
name: llm-uservice
|
||||
selector:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
---
|
||||
# Source: llm-uservice/templates/deployment.yaml
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: docsum-llm-uservice
|
||||
labels:
|
||||
helm.sh/chart: llm-uservice-0.1.0
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
app.kubernetes.io/version: "1.0.0"
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
spec:
|
||||
securityContext: {}
|
||||
containers:
|
||||
- name: docsum
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: qna-config
|
||||
env:
|
||||
- name: HUGGING_FACE_HUB_TOKEN
|
||||
value: $(HUGGINGFACEHUB_API_TOKEN)
|
||||
- name: HF_TOKEN
|
||||
value: $(HUGGINGFACEHUB_API_TOKEN)
|
||||
- name: LANGCHAIN_TRACING_V2
|
||||
value: "false"
|
||||
- name: LANGCHAIN_PROJECT
|
||||
value: "opea-llm-service"
|
||||
securityContext: {}
|
||||
image: "opea/llm-docsum-tgi:latest"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: llm-uservice
|
||||
containerPort: 9000
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
74
ChatQnA/kubernetes/manifests/docsum_llm.yaml
Normal file
74
ChatQnA/kubernetes/manifests/docsum_llm.yaml
Normal file
@@ -0,0 +1,74 @@
|
||||
# Source: llm-uservice/charts/tgi/templates/service.yaml
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: docsum-llm-uservice
|
||||
labels:
|
||||
helm.sh/chart: llm-uservice-0.1.0
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
app.kubernetes.io/version: "1.0.0"
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 9000
|
||||
targetPort: 9000
|
||||
protocol: TCP
|
||||
name: llm-uservice
|
||||
selector:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
---
|
||||
# Source: llm-uservice/templates/deployment.yaml
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: docsum-llm-uservice
|
||||
labels:
|
||||
helm.sh/chart: llm-uservice-0.1.0
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
app.kubernetes.io/version: "1.0.0"
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: llm-uservice
|
||||
app.kubernetes.io/instance: docsum
|
||||
spec:
|
||||
securityContext: {}
|
||||
containers:
|
||||
- name: docsum
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: qna-config
|
||||
env:
|
||||
- name: HUGGING_FACE_HUB_TOKEN
|
||||
value: $(HUGGINGFACEHUB_API_TOKEN)
|
||||
- name: HF_TOKEN
|
||||
value: $(HUGGINGFACEHUB_API_TOKEN)
|
||||
- name: LANGCHAIN_TRACING_V2
|
||||
value: "false"
|
||||
- name: LANGCHAIN_PROJECT
|
||||
value: "opea-llm-service"
|
||||
securityContext: {}
|
||||
image: "opea/llm-docsum-tgi:latest"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: llm-uservice
|
||||
containerPort: 9000
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
@@ -22,7 +22,7 @@ function init_chatqna() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
@@ -22,7 +22,7 @@ function init_chatqna() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
@@ -22,7 +22,7 @@ function init_codegen() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
@@ -22,7 +22,7 @@ function init_codegen() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
@@ -22,7 +22,7 @@ function init_codetrans() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
@@ -22,7 +22,7 @@ function init_codetrans() {
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: ${IMAGE_REPO}opea\"/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
|
||||
35
DocSum/kubernetes/docsum_gaudi.yaml
Normal file
35
DocSum/kubernetes/docsum_gaudi.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: gmc.opea.io/v1alpha3
|
||||
kind: GMConnector
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: gmconnector
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
gmc/platform: gaudi
|
||||
name: docsum
|
||||
namespace: docsum
|
||||
spec:
|
||||
routerConfig:
|
||||
name: router
|
||||
serviceName: router-service
|
||||
nodes:
|
||||
root:
|
||||
routerType: Sequence
|
||||
steps:
|
||||
- name: DocSumGaudi
|
||||
data: $response
|
||||
internalService:
|
||||
serviceName: docsum-llm-uservice
|
||||
config:
|
||||
endpoint: /v1/chat/docsum
|
||||
PORT: "9009"
|
||||
- name: TgiGaudi
|
||||
internalService:
|
||||
serviceName: tgi-gaudi-svc
|
||||
config:
|
||||
LANGCHAIN_TRACING_V2: "false"
|
||||
LANGCHAIN_PROJECT: "opea-llm-service"
|
||||
endpoint: /generate
|
||||
isDownstreamService: true
|
||||
35
DocSum/kubernetes/docsum_xeon.yaml
Normal file
35
DocSum/kubernetes/docsum_xeon.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: gmc.opea.io/v1alpha3
|
||||
kind: GMConnector
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: gmconnector
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
gmc/platform: xeon
|
||||
name: docsum
|
||||
namespace: docsum
|
||||
spec:
|
||||
routerConfig:
|
||||
name: router
|
||||
serviceName: router-service
|
||||
nodes:
|
||||
root:
|
||||
routerType: Sequence
|
||||
steps:
|
||||
- name: DocSum
|
||||
data: $response
|
||||
internalService:
|
||||
serviceName: docsum-llm-uservice
|
||||
config:
|
||||
endpoint: /v1/chat/docsum
|
||||
PORT: "9009"
|
||||
- name: Tgi
|
||||
internalService:
|
||||
serviceName: tgi-svc
|
||||
config:
|
||||
LANGCHAIN_TRACING_V2: "false"
|
||||
LANGCHAIN_PROJECT: "opea-llm-service"
|
||||
endpoint: /generate
|
||||
isDownstreamService: true
|
||||
167
DocSum/tests/test_gmc_on_gaudi.sh
Executable file
167
DocSum/tests/test_gmc_on_gaudi.sh
Executable file
@@ -0,0 +1,167 @@
|
||||
#!/bin/bash
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -xe
|
||||
USER_ID=$(whoami)
|
||||
LOG_PATH=/home/$(whoami)/logs
|
||||
MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub
|
||||
IMAGE_REPO=${IMAGE_REPO:-}
|
||||
|
||||
function init_docsum() {
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/crd/bases/gmc.opea.io_gmconnectors.yaml
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/rbac/gmc-manager-rbac.yaml
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/manager/gmc-manager.yaml
|
||||
wget -O manifests/gmc-router.yaml https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/gmcrouter/gmc-router.yaml
|
||||
|
||||
# replace namespace for gmc-router and gmc-manager
|
||||
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" ./gmc-manager.yaml
|
||||
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" ./gmc-manager-rbac.yaml
|
||||
sed -i "s|name: system|name: $SYSTEM_NAMESPACE|g" ./gmc-manager-rbac.yaml
|
||||
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#default.svc#$APP_NAMESPACE.svc#g" {} \;
|
||||
}
|
||||
|
||||
function install_docsum() {
|
||||
# Make sure you have to use image tag $VERSION for microservice-connector installation
|
||||
echo "install microservice-connector, using repo $DOCKER_REGISTRY and tag $VERSION"
|
||||
echo "using namespace $SYSTEM_NAMESPACE and $APP_NAMESPACE"
|
||||
|
||||
kubectl apply -f ./gmc.opea.io_gmconnectors.yaml
|
||||
kubectl apply -f ./gmc-manager-rbac.yaml
|
||||
kubectl create configmap gmcyaml -n $SYSTEM_NAMESPACE --from-file $(pwd)/../kubernetes/manifests
|
||||
kubectl apply -f ./gmc-manager.yaml
|
||||
|
||||
# Wait until the gmc controller pod is ready
|
||||
wait_until_pod_ready "gmc-controller" $SYSTEM_NAMESPACE "gmc-controller"
|
||||
kubectl get pods -n $SYSTEM_NAMESPACE
|
||||
rm -f ./gmc.opea.io_gmconnectors.yaml ./gmc-manager-rbac.yaml ./gmc-manager.yaml manifests/gmc-router.yaml
|
||||
}
|
||||
|
||||
function validate_docsum() {
|
||||
kubectl create ns $APP_NAMESPACE
|
||||
sed -i "s|namespace: docsum|namespace: $APP_NAMESPACE|g" ./docsum_gaudi.yaml
|
||||
kubectl apply -f ./docsum_gaudi.yaml
|
||||
|
||||
# Wait until the router service is ready
|
||||
echo "Waiting for the docsum router service to be ready..."
|
||||
wait_until_pod_ready "docsum router" $APP_NAMESPACE "router-service"
|
||||
output=$(kubectl get pods -n $APP_NAMESPACE)
|
||||
echo $output
|
||||
|
||||
# deploy client pod for testing
|
||||
kubectl create deployment client-test -n $APP_NAMESPACE --image=python:3.8.13 -- sleep infinity
|
||||
|
||||
# wait for client pod ready
|
||||
wait_until_pod_ready "client-test" $APP_NAMESPACE "client-test"
|
||||
# giving time to populating data
|
||||
sleep 60
|
||||
|
||||
kubectl get pods -n $APP_NAMESPACE
|
||||
# send request to codetrans
|
||||
export CLIENT_POD=$(kubectl get pod -n $APP_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name})
|
||||
echo "$CLIENT_POD"
|
||||
accessUrl=$(kubectl get gmc -n $APP_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='docsum')].status.accessUrl}")
|
||||
kubectl exec "$CLIENT_POD" -n $APP_NAMESPACE -- curl $accessUrl -X POST -d '{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}' -H 'Content-Type: application/json' > $LOG_PATH/gmc_docsum.log
|
||||
exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "docsum failed, please check the logs in ${LOG_PATH}!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat $LOG_PATH/gmc_docsum.log
|
||||
echo "Checking response results, make sure the output is reasonable. "
|
||||
local status=false
|
||||
if [[ -f $LOG_PATH/gmc_docsum.log ]] && \
|
||||
[[ $(grep -c "[DONE]" $LOG_PATH/gmc_docsum.log) != 0 ]]; then
|
||||
status=true
|
||||
fi
|
||||
if [ $status == false ]; then
|
||||
if [[ -f $LOG_PATH/gmc_docsum.log ]]; then
|
||||
cat $LOG_PATH/gmc_docsum.log
|
||||
fi
|
||||
echo "Response check failed, please check the logs in artifacts!"
|
||||
exit 1
|
||||
else
|
||||
echo "Response check succeed!"
|
||||
fi
|
||||
}
|
||||
|
||||
function wait_until_pod_ready() {
|
||||
echo "Waiting for the $1 to be ready..."
|
||||
max_retries=30
|
||||
retry_count=0
|
||||
while ! is_pod_ready $2 $3; do
|
||||
if [ $retry_count -ge $max_retries ]; then
|
||||
echo "$1 is not ready after waiting for a significant amount of time"
|
||||
get_gmc_controller_logs
|
||||
exit 1
|
||||
fi
|
||||
echo "$1 is not ready yet. Retrying in 10 seconds..."
|
||||
sleep 10
|
||||
output=$(kubectl get pods -n $2)
|
||||
echo $output
|
||||
retry_count=$((retry_count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
function is_pod_ready() {
|
||||
if [ "$2" == "gmc-controller" ]; then
|
||||
pod_status=$(kubectl get pods -n $1 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
|
||||
else
|
||||
pod_status=$(kubectl get pods -n $1 -l app=$2 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
|
||||
fi
|
||||
if [ "$pod_status" == "True" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function get_gmc_controller_logs() {
|
||||
# Fetch the name of the pod with the app-name gmc-controller in the specified namespace
|
||||
pod_name=$(kubectl get pods -n $SYSTEM_NAMESPACE -l control-plane=gmc-controller -o jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
# Check if the pod name was found
|
||||
if [ -z "$pod_name" ]; then
|
||||
echo "No pod found with app-name gmc-controller in namespace $SYSTEM_NAMESPACE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get the logs of the found pod
|
||||
echo "Fetching logs for pod $pod_name in namespace $SYSTEM_NAMESPACE..."
|
||||
kubectl logs $pod_name -n $SYSTEM_NAMESPACE
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <function_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
init_DocSum)
|
||||
pushd ChatQnA/kubernetes
|
||||
init_docsum
|
||||
popd
|
||||
;;
|
||||
install_DocSum)
|
||||
pushd ChatQnA/kubernetes
|
||||
install_docsum
|
||||
popd
|
||||
;;
|
||||
validate_DocSum)
|
||||
pushd DocSum/kubernetes
|
||||
validate_docsum
|
||||
popd
|
||||
;;
|
||||
*)
|
||||
echo "Unknown function: $1"
|
||||
;;
|
||||
esac
|
||||
168
DocSum/tests/test_gmc_on_xeon.sh
Executable file
168
DocSum/tests/test_gmc_on_xeon.sh
Executable file
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -xe
|
||||
USER_ID=$(whoami)
|
||||
LOG_PATH=/home/$(whoami)/logs
|
||||
MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub
|
||||
IMAGE_REPO=${IMAGE_REPO:-}
|
||||
|
||||
function init_docsum() {
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/crd/bases/gmc.opea.io_gmconnectors.yaml
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/rbac/gmc-manager-rbac.yaml
|
||||
wget https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/manager/gmc-manager.yaml
|
||||
wget -O manifests/gmc-router.yaml https://raw.githubusercontent.com/opea-project/GenAIInfra/main/microservices-connector/config/gmcrouter/gmc-router.yaml
|
||||
|
||||
# replace namespace for gmc-router and gmc-manager
|
||||
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" ./gmc-manager.yaml
|
||||
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" ./gmc-manager-rbac.yaml
|
||||
sed -i "s|name: system|name: $SYSTEM_NAMESPACE|g" ./gmc-manager-rbac.yaml
|
||||
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
|
||||
# replace the repository "image: opea/*" with "image: ${IMAGE_REPO}opea/"
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" {} \;
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}opea/#g" {} \;
|
||||
# set huggingface token
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#\${HUGGINGFACEHUB_API_TOKEN}#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
|
||||
# replace namespace "default" with real namespace
|
||||
find . -name '*.yaml' -type f -exec sed -i "s#default.svc#$APP_NAMESPACE.svc#g" {} \;
|
||||
}
|
||||
|
||||
function install_docsum() {
|
||||
# Make sure you have to use image tag $VERSION for microservice-connector installation
|
||||
echo "install microservice-connector, using repo $DOCKER_REGISTRY and tag $VERSION"
|
||||
echo "using namespace $SYSTEM_NAMESPACE and $APP_NAMESPACE"
|
||||
|
||||
kubectl apply -f ./gmc.opea.io_gmconnectors.yaml
|
||||
kubectl apply -f ./gmc-manager-rbac.yaml
|
||||
kubectl create configmap gmcyaml -n $SYSTEM_NAMESPACE --from-file $(pwd)/../kubernetes/manifests
|
||||
kubectl apply -f ./gmc-manager.yaml
|
||||
|
||||
# Wait until the gmc controller pod is ready
|
||||
wait_until_pod_ready "gmc-controller" $SYSTEM_NAMESPACE "gmc-controller"
|
||||
kubectl get pods -n $SYSTEM_NAMESPACE
|
||||
rm -f ./gmc.opea.io_gmconnectors.yaml ./gmc-manager-rbac.yaml ./gmc-manager.yaml manifests/gmc-router.yaml
|
||||
}
|
||||
|
||||
function validate_docsum() {
|
||||
kubectl create ns $APP_NAMESPACE
|
||||
sed -i "s|namespace: docsum|namespace: $APP_NAMESPACE|g" ./docsum_xeon.yaml
|
||||
kubectl apply -f ./docsum_xeon.yaml
|
||||
|
||||
# Wait until the router service is ready
|
||||
echo "Waiting for the docsum router service to be ready..."
|
||||
wait_until_pod_ready "docsum router" $APP_NAMESPACE "router-service"
|
||||
output=$(kubectl get pods -n $APP_NAMESPACE)
|
||||
echo $output
|
||||
|
||||
|
||||
# deploy client pod for testing
|
||||
kubectl create deployment client-test -n $APP_NAMESPACE --image=python:3.8.13 -- sleep infinity
|
||||
|
||||
# wait for client pod ready
|
||||
wait_until_pod_ready "client-test" $APP_NAMESPACE "client-test"
|
||||
# giving time to populating data
|
||||
sleep 60
|
||||
|
||||
kubectl get pods -n $APP_NAMESPACE
|
||||
# send request to docsum
|
||||
export CLIENT_POD=$(kubectl get pod -n $APP_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name})
|
||||
echo "$CLIENT_POD"
|
||||
accessUrl=$(kubectl get gmc -n $APP_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='docsum')].status.accessUrl}")
|
||||
kubectl exec "$CLIENT_POD" -n $APP_NAMESPACE -- curl $accessUrl -X POST -d '{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}' -H 'Content-Type: application/json' > $LOG_PATH/gmc_docsum.log
|
||||
exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "docsum failed, please check the logs in ${LOG_PATH}!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat $LOG_PATH/gmc_docsum.log
|
||||
echo "Checking response results, make sure the output is reasonable. "
|
||||
local status=false
|
||||
if [[ -f $LOG_PATH/gmc_docsum.log ]] && \
|
||||
[[ $(grep -c "[DONE]" $LOG_PATH/gmc_docsum.log) != 0 ]]; then
|
||||
status=true
|
||||
fi
|
||||
if [ $status == false ]; then
|
||||
if [[ -f $LOG_PATH/gmc_docsum.log ]]; then
|
||||
cat $LOG_PATH/gmc_docsum.log
|
||||
fi
|
||||
echo "Response check failed, please check the logs in artifacts!"
|
||||
exit 1
|
||||
else
|
||||
echo "Response check succeed!"
|
||||
fi
|
||||
}
|
||||
|
||||
function wait_until_pod_ready() {
|
||||
echo "Waiting for the $1 to be ready..."
|
||||
max_retries=30
|
||||
retry_count=0
|
||||
while ! is_pod_ready $2 $3; do
|
||||
if [ $retry_count -ge $max_retries ]; then
|
||||
echo "$1 is not ready after waiting for a significant amount of time"
|
||||
get_gmc_controller_logs
|
||||
exit 1
|
||||
fi
|
||||
echo "$1 is not ready yet. Retrying in 10 seconds..."
|
||||
sleep 10
|
||||
output=$(kubectl get pods -n $2)
|
||||
echo $output
|
||||
retry_count=$((retry_count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
function is_pod_ready() {
|
||||
if [ "$2" == "gmc-controller" ]; then
|
||||
pod_status=$(kubectl get pods -n $1 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
|
||||
else
|
||||
pod_status=$(kubectl get pods -n $1 -l app=$2 -o jsonpath='{.items[].status.conditions[?(@.type=="Ready")].status}')
|
||||
fi
|
||||
if [ "$pod_status" == "True" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function get_gmc_controller_logs() {
|
||||
# Fetch the name of the pod with the app-name gmc-controller in the specified namespace
|
||||
pod_name=$(kubectl get pods -n $SYSTEM_NAMESPACE -l control-plane=gmc-controller -o jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
# Check if the pod name was found
|
||||
if [ -z "$pod_name" ]; then
|
||||
echo "No pod found with app-name gmc-controller in namespace $SYSTEM_NAMESPACE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get the logs of the found pod
|
||||
echo "Fetching logs for pod $pod_name in namespace $SYSTEM_NAMESPACE..."
|
||||
kubectl logs $pod_name -n $SYSTEM_NAMESPACE
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <function_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
init_DocSum)
|
||||
pushd ChatQnA/kubernetes
|
||||
init_docsum
|
||||
popd
|
||||
;;
|
||||
install_DocSum)
|
||||
pushd ChatQnA/kubernetes
|
||||
install_docsum
|
||||
popd
|
||||
;;
|
||||
validate_DocSum)
|
||||
pushd DocSum/kubernetes
|
||||
validate_docsum
|
||||
popd
|
||||
;;
|
||||
*)
|
||||
echo "Unknown function: $1"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user