From 9c97fad977450ceeae0b2c4c1bf52593ea298707 Mon Sep 17 00:00:00 2001 From: Xin Huang Date: Tue, 2 Jul 2024 13:27:25 +0800 Subject: [PATCH] Optimize app namesapces and fix some typos in gmc e2e test. (#145) * Optimize app namesapces and fix some typos in gmc e2e test. Signed-off-by: Huang Xin * Fix error. Signed-off-by: Huang Xin * Add CHATQNA_NAMESPACE in gmc_xeon_test.sh and gmc_gaudi_test.sh Signed-off-by: Xin Huang --------- Signed-off-by: Huang Xin Signed-off-by: Xin Huang --- .github/workflows/go-e2e-gaudi.yaml | 2 +- .github/workflows/go-e2e.yaml | 2 +- .../workflows/scripts/e2e/gmc_gaudi_test.sh | 37 ++++++++++--------- .../workflows/scripts/e2e/gmc_xeon_test.sh | 35 +++++++++--------- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/.github/workflows/go-e2e-gaudi.yaml b/.github/workflows/go-e2e-gaudi.yaml index 2f123d8c..c9838b00 100644 --- a/.github/workflows/go-e2e-gaudi.yaml +++ b/.github/workflows/go-e2e-gaudi.yaml @@ -68,7 +68,7 @@ jobs: - name: Set variables run: | echo "SYSTEM_NAMESPACE=opea-system-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV - echo "APP_NAMESPACE=chatqna-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + echo "APP_NAMESPACE=opea-app-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV echo "DOCKER_REGISTRY=${{ needs.image-build.outputs.docker_registry }}" >> $GITHUB_ENV echo "VERSION=${{ needs.image-build.outputs.version }}" >> $GITHUB_ENV echo "should_cleanup=false" >> $GITHUB_ENV diff --git a/.github/workflows/go-e2e.yaml b/.github/workflows/go-e2e.yaml index 267ed0ea..4d1570e2 100644 --- a/.github/workflows/go-e2e.yaml +++ b/.github/workflows/go-e2e.yaml @@ -68,7 +68,7 @@ jobs: - name: Set variables run: | echo "SYSTEM_NAMESPACE=opea-system-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV - echo "APP_NAMESPACE=chatqna-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + echo "APP_NAMESPACE=opea-app-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV echo "DOCKER_REGISTRY=${{ needs.image-build.outputs.docker_registry }}" >> $GITHUB_ENV echo "VERSION=${{ needs.image-build.outputs.version }}" >> $GITHUB_ENV echo "should_cleanup=false" >> $GITHUB_ENV diff --git a/.github/workflows/scripts/e2e/gmc_gaudi_test.sh b/.github/workflows/scripts/e2e/gmc_gaudi_test.sh index 8ef05ad5..fe139cd0 100755 --- a/.github/workflows/scripts/e2e/gmc_gaudi_test.sh +++ b/.github/workflows/scripts/e2e/gmc_gaudi_test.sh @@ -8,6 +8,7 @@ LOG_PATH=/home/$(whoami)/logs MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub IMAGE_REPO=${OPEA_IMAGE_REPO:-""} +CHATQNA_NAMESPACE="${APP_NAMESPACE}-chatqna" CODEGEN_NAMESPACE="${APP_NAMESPACE}-codegen" CODETRANS_NAMESPACE="${APP_NAMESPACE}-codetrans" DOCSUM_NAMESPACE="${APP_NAMESPACE}-docsum" @@ -16,7 +17,7 @@ DOCSUM_NAMESPACE="${APP_NAMESPACE}-docsum" function install_gmc() { # 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" + echo "using namespace $SYSTEM_NAMESPACE, $CHATQNA_NAMESPACE, $CODEGEN_NAMESPACE, $CODETRANS_NAMESPACE and $DOCSUM_NAMESPACE" init_gmc @@ -48,7 +49,7 @@ function validate_gmc() { function cleanup_gmc() { echo "clean up microservice-connector" - namespaces=("$APP_NAMESPACE" "$CODEGEN_NAMESPACE" "$CODETRANS_NAMESPACE" "$DOCSUM_NAMESPACE" "$SYSTEM_NAMESPACE") + namespaces=("$CHATQNA_NAMESPACE" "$CODEGEN_NAMESPACE" "$CODETRANS_NAMESPACE" "$DOCSUM_NAMESPACE" "$SYSTEM_NAMESPACE") for ns in "${namespaces[@]}"; do kubectl get namespace "$ns" &> /dev/null if [ $? -eq 0 ]; then @@ -62,36 +63,36 @@ function cleanup_gmc() { } function validate_chatqna() { - kubectl create ns $APP_NAMESPACE - sed -i "s|namespace: chatqa|namespace: $APP_NAMESPACE|g" $(pwd)/config/samples/chatQnA_gaudi.yaml + kubectl create ns $CHATQNA_NAMESPACE + sed -i "s|namespace: chatqa|namespace: $CHATQNA_NAMESPACE|g" $(pwd)/config/samples/chatQnA_gaudi.yaml kubectl apply -f $(pwd)/config/samples/chatQnA_gaudi.yaml # Wait until the router service is ready echo "Waiting for the chatqa router service to be ready..." - wait_until_pod_ready "chatqna router" $APP_NAMESPACE "router-service" - output=$(kubectl get pods -n $APP_NAMESPACE) + wait_until_pod_ready "chatqna router" $CHATQNA_NAMESPACE "router-service" + output=$(kubectl get pods -n $CHATQNA_NAMESPACE) echo $output # Wait until the tgi pod is ready - TGI_POD_NAME=$(kubectl get pods --namespace=$APP_NAMESPACE | grep ^tgi-gaudi-svc | awk '{print $1}') - kubectl describe pod $TGI_POD_NAME -n $APP_NAMESPACE - kubectl wait --for=condition=ready pod/$TGI_POD_NAME --namespace=$APP_NAMESPACE --timeout=300s + TGI_POD_NAME=$(kubectl get pods --namespace=$CHATQNA_NAMESPACE | grep ^tgi-gaudi-svc | awk '{print $1}') + kubectl describe pod $TGI_POD_NAME -n $CHATQNA_NAMESPACE + kubectl wait --for=condition=ready pod/$TGI_POD_NAME --namespace=$CHATQNA_NAMESPACE --timeout=300s # deploy client pod for testing - kubectl create deployment client-test -n $APP_NAMESPACE --image=python:3.8.13 -- sleep infinity + kubectl create deployment client-test -n $CHATQNA_NAMESPACE --image=python:3.8.13 -- sleep infinity # wait for client pod ready - wait_until_pod_ready "client-test" $APP_NAMESPACE "client-test" + wait_until_pod_ready "client-test" $CHATQNA_NAMESPACE "client-test" # giving time to populating data sleep 120 - kubectl get pods -n $APP_NAMESPACE - # send request to chatqnA - export CLIENT_POD=$(kubectl get pod -n $APP_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name}) + kubectl get pods -n $CHATQNA_NAMESPACE + # send request to chatqna + export CLIENT_POD=$(kubectl get pod -n $CHATQNA_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=='chatqa')].status.accessUrl}") - 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 + accessUrl=$(kubectl get gmc -n $CHATQNA_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='chatqa')].status.accessUrl}") + kubectl exec "$CLIENT_POD" -n $CHATQNA_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 exit_code=$? if [ $exit_code -ne 0 ]; then echo "chatqna failed, please check the logs in ${LOG_PATH}!" @@ -143,7 +144,7 @@ function validate_codegen() { kubectl exec "$CLIENT_POD" -n $CODEGEN_NAMESPACE -- curl $accessUrl -X POST -d '{"messages": "def print_hello_world():"}' -H 'Content-Type: application/json' > $LOG_PATH/gmc_codegen.log exit_code=$? if [ $exit_code -ne 0 ]; then - echo "chatqna failed, please check the logs in ${LOG_PATH}!" + echo "codegen failed, please check the logs in ${LOG_PATH}!" exit 1 fi @@ -234,7 +235,7 @@ function validate_docsum() { sleep 60 kubectl get pods -n $DOCSUM_NAMESPACE - # send request to codetrans + # send request to docsum export CLIENT_POD=$(kubectl get pod -n $DOCSUM_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name}) echo "$CLIENT_POD" accessUrl=$(kubectl get gmc -n $DOCSUM_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='docsum')].status.accessUrl}") diff --git a/.github/workflows/scripts/e2e/gmc_xeon_test.sh b/.github/workflows/scripts/e2e/gmc_xeon_test.sh index 3cbdf939..c44a6d7b 100755 --- a/.github/workflows/scripts/e2e/gmc_xeon_test.sh +++ b/.github/workflows/scripts/e2e/gmc_xeon_test.sh @@ -8,6 +8,7 @@ LOG_PATH=/home/$(whoami)/logs MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub IMAGE_REPO=${OPEA_IMAGE_REPO:-""} +CHATQNA_NAMESPACE="${APP_NAMESPACE}-chatqna" CODEGEN_NAMESPACE="${APP_NAMESPACE}-codegen" CODETRANS_NAMESPACE="${APP_NAMESPACE}-codetrans" DOCSUM_NAMESPACE="${APP_NAMESPACE}-docsum" @@ -16,7 +17,7 @@ DOCSUM_NAMESPACE="${APP_NAMESPACE}-docsum" function install_gmc() { # 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" + echo "using namespace $SYSTEM_NAMESPACE, $CHATQNA_NAMESPACE, $CODEGEN_NAMESPACE, $CODETRANS_NAMESPACE and $DOCSUM_NAMESPACE" init_gmc @@ -48,7 +49,7 @@ function validate_gmc() { function cleanup_gmc() { echo "clean up microservice-connector" - namespaces=("$APP_NAMESPACE" "$CODEGEN_NAMESPACE" "$CODETRANS_NAMESPACE" "$DOCSUM_NAMESPACE" "$SYSTEM_NAMESPACE") + namespaces=("$CHATQNA_NAMESPACE" "$CODEGEN_NAMESPACE" "$CODETRANS_NAMESPACE" "$DOCSUM_NAMESPACE" "$SYSTEM_NAMESPACE") for ns in "${namespaces[@]}"; do kubectl get namespace "$ns" &> /dev/null if [ $? -eq 0 ]; then @@ -62,36 +63,36 @@ function cleanup_gmc() { } function validate_chatqna() { - kubectl create ns $APP_NAMESPACE - sed -i "s|namespace: chatqa|namespace: $APP_NAMESPACE|g" $(pwd)/config/samples/chatQnA_xeon.yaml + kubectl create ns $CHATQNA_NAMESPACE + sed -i "s|namespace: chatqa|namespace: $CHATQNA_NAMESPACE|g" $(pwd)/config/samples/chatQnA_xeon.yaml kubectl apply -f $(pwd)/config/samples/chatQnA_xeon.yaml # Wait until the router service is ready echo "Waiting for the chatqa router service to be ready..." - wait_until_pod_ready "chatqna router" $APP_NAMESPACE "router-service" - output=$(kubectl get pods -n $APP_NAMESPACE) + wait_until_pod_ready "chatqna router" $CHATQNA_NAMESPACE "router-service" + output=$(kubectl get pods -n $CHATQNA_NAMESPACE) echo $output # Wait until the tgi pod is ready - TGI_POD_NAME=$(kubectl get pods --namespace=$APP_NAMESPACE | grep ^tgi-service | awk '{print $1}') - kubectl describe pod $TGI_POD_NAME -n $APP_NAMESPACE - kubectl wait --for=condition=ready pod/$TGI_POD_NAME --namespace=$APP_NAMESPACE --timeout=300s + TGI_POD_NAME=$(kubectl get pods --namespace=$CHATQNA_NAMESPACE | grep ^tgi-service | awk '{print $1}') + kubectl describe pod $TGI_POD_NAME -n $CHATQNA_NAMESPACE + kubectl wait --for=condition=ready pod/$TGI_POD_NAME --namespace=$CHATQNA_NAMESPACE --timeout=300s # deploy client pod for testing - kubectl create deployment client-test -n $APP_NAMESPACE --image=python:3.8.13 -- sleep infinity + kubectl create deployment client-test -n $CHATQNA_NAMESPACE --image=python:3.8.13 -- sleep infinity # wait for client pod ready - wait_until_pod_ready "client-test" $APP_NAMESPACE "client-test" + wait_until_pod_ready "client-test" $CHATQNA_NAMESPACE "client-test" # giving time to populating data sleep 120 - kubectl get pods -n $APP_NAMESPACE + kubectl get pods -n $CHATQNA_NAMESPACE # send request to chatqnA - export CLIENT_POD=$(kubectl get pod -n $APP_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name}) + export CLIENT_POD=$(kubectl get pod -n $CHATQNA_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=='chatqa')].status.accessUrl}") - 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 + accessUrl=$(kubectl get gmc -n $CHATQNA_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='chatqa')].status.accessUrl}") + kubectl exec "$CLIENT_POD" -n $CHATQNA_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 exit_code=$? if [ $exit_code -ne 0 ]; then echo "chatqna failed, please check the logs in ${LOG_PATH}!" @@ -143,7 +144,7 @@ function validate_codegen() { kubectl exec "$CLIENT_POD" -n $CODEGEN_NAMESPACE -- curl $accessUrl -X POST -d '{"messages": "def print_hello_world():"}' -H 'Content-Type: application/json' > $LOG_PATH/gmc_codegen.log exit_code=$? if [ $exit_code -ne 0 ]; then - echo "chatqna failed, please check the logs in ${LOG_PATH}!" + echo "codegen failed, please check the logs in ${LOG_PATH}!" exit 1 fi @@ -235,7 +236,7 @@ function validate_docsum() { sleep 60 kubectl get pods -n $DOCSUM_NAMESPACE - # send request to codetrans + # send request to docsum export CLIENT_POD=$(kubectl get pod -n $DOCSUM_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name}) echo "$CLIENT_POD" accessUrl=$(kubectl get gmc -n $DOCSUM_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='docsum')].status.accessUrl}")